flex自定义Log的输出,重写隐藏方法
来源:互联网 发布:阿里云app有域名交易吗 编辑:程序博客网 时间:2024/05/18 02:00
flex自带了mx.logging包,跟log4j很像。基本用法挺简单不讲了。
flex同时还实现了两种log的输出方式,在mx.logging.targets包,分别是MiniDebugTarget和TraceTarget(输出到LocalConnection和trace),可是有时候不想用这两种,比如想输出到TextArea显示。注意到这两个都是继承自LineFormattedTarget,看看这类忍不住有点激动了,因为它做了大部分的字符串格式化操作,直接拿来继承就行了。从文档上看它只有logEvent可以重写,而且又不大方便(因为LogEvent里的message不是格式化好的,要了有啥意思)。翻看源码才知道它有一个方法是mx_internal命名空间的,即隐藏的。(不过可以重写)
/** * Descendants of this class should override this method to direct the * specified message to the desired output. * * @param message String containing preprocessed log message which may * include time, date, category, etc. based on property settings, * such as <code>includeDate</code>, <code>includeCategory</code>, * etc. */ mx_internal function internalLog(message:String):void { // override this method to perform the redirection to the desired output }
重写它就显得很简单,看看TraceTarget的源码也是重写它的。下面是自定义输出类
package myvocal.log{import mx.controls.TextArea;import mx.core.mx_internal;import mx.logging.targets.LineFormattedTarget;import mx.logging.LogEventLevel; use namespace mx_internal; public class LogTarget extends LineFormattedTarget{public function LogTarget(tarea:TextArea){//TODO: implement functionsuper();this.level = LogEventLevel.INFO;this.includeDate = true;this.includeLevel = true;this.includeTime = true; _textArea = tarea;} private var _textArea:TextArea; mx_internal override function internalLog(message:String):void{_textArea.text += message + "/n";} }}
- flex自定义Log的输出,重写隐藏方法
- Unreal输出Log的方法
- iOS开发-重写description方法,自定义控制台(log)信息
- 方法的重载、隐藏与重写辨析
- 隐藏和重写方法的区别
- 成员变量的隐藏和方法重写
- 成员变量的隐藏和方法重写
- 自定义 Unity3d 的Log 输出 (unity自己的Log)
- 重写Android Log的输出,只在debug的时候输出,release 的版本不输出
- 自定义Log输出
- Unity log 自定义输出
- swift 自定义log输出
- Android中Log信息的输出方法
- VC Log中输出时间的方法
- Log 使用以及输出行号的方法
- cocos2dx输出Log的几种方法
- Android中Log信息的输出方法
- cocos2dx输出Log的几种方法
- System.Runtime.Remoting.Channels
- 《开源合辑-(软件开发->框架)之(Delphi/Kylix)》 (3)
- 《开源合辑-(企业应用)之(Delphi/Kylix)》
- 编码规范(自己的要求啦)
- 《开源合辑-(安全)之(Delphi/Kylix)》 (1)
- flex自定义Log的输出,重写隐藏方法
- public TcpChannel
- 女人永远都不会懂的12件事
- 《开源合辑-(安全)之(Delphi/Kylix)》 (2)
- Linux共享内存详解(上)
- sorted as raw strings, not alphanumerics 的个人理解?
- 用户信息验证基类
- 《开源合辑-(安全)之(Delphi/Kylix)》 (3)
- 小小的错误,但是很多人都会犯的错误