·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[flex]as3commons log使用方法

时间:2016-09-02 22:25酷播
[flex]as3commons log使用方法

http://www.as3commons.org/  [flex]as3commons log使用方法

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"  
  3.                xmlns:s="library://ns.adobe.com/flex/spark"  
  4.                xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"  
  5.                creationComplete="application1_creationCompleteHandler(event)"  
  6.                xmlns:debugger="com.demonsters.debugger.*"> 
  7.      
  8.     <fx:Script> 
  9.         <![CDATA[ 
  10.             import com.demonsters.debugger.MonsterDebugger; 
  11.              
  12.             import mx.events.FlexEvent; 
  13.              
  14.             import org.as3commons.logging.api.*; 
  15.             import org.as3commons.logging.api.ILogger; 
  16.             import org.as3commons.logging.api.LOGGER_FACTORY; 
  17.             import org.as3commons.logging.setup.*; 
  18.             import org.as3commons.logging.setup.target.*; 
  19.             import org.as3commons.logging.util.captureUncaughtErrors; 
  20.             protected function click(event:MouseEvent):void 
  21.             { 
  22.                 // TODO Auto-generated method stub 
  23.                 var log:ILogger = getLogger(Test_log); 
  24.                 log.debug("日志测试..."); 
  25.                 var o:Object={a:1,b:2,c:'d的',d:{a:1,b:2}}; 
  26.                 log.info(o); 
  27.                 MonsterDebugger.trace(this, "世界你好!"); 
  28.                 monsterDebugger.trace(this,"asdfa撒旦发射"); 
  29.             } 
  30.              
  31.             protected function application1_creationCompleteHandler(event:FlexEvent):void 
  32.             { 
  33.                 setup(); 
  34.             } 
  35.              
  36.             protected function button1_clickHandler(event:MouseEvent):void 
  37.             { 
  38.                 // TODO Auto-generated method stub 
  39.                 LOGGER_FACTORY.setup = null; 
  40.             } 
  41.             protected function button2_clickHandler(event:MouseEvent):void 
  42.             { 
  43.                 setup(); 
  44.             } 
  45.             private function setup():void{ 
  46.                 var format:String = "{date}{time} {logLevel} - {shortName}{atPerson}: - {message}\n"; 
  47.                 var col:IFormattingLogTarget = new TraceTarget(); 
  48.                 col.format=format; 
  49.                 //              captureUncaughtErrors(loaderInfo); 
  50.                 //LOGGER_FACTORY.setup = new SimpleTargetSetup( mergeTargets( new TextFieldTarget(format,field),col,new AlconTarget(format)) ); 
  51.                 LOGGER_FACTORY.setup = new SimpleTargetSetup( mergeTargets( col) ); 
  52.                 //MonsterDebugger.initialize(this); 
  53.             } 
  54.         ]]> 
  55.     </fx:Script> 
  56.      
  57.     <fx:Declarations> 
  58.         <!-- Place non-visual elements (e.g., services, value objects) here --> 
  59.     </fx:Declarations> 
  60.     <s:layout> 
  61.         <s:HorizontalLayout/> 
  62.     </s:layout> 
  63.     <s:Button label="log" click="click(event)"/> 
  64.     <s:Button label="offlog" click="button1_clickHandler(event)"/> 
  65.     <s:Button label="onlog" click="button2_clickHandler(event)"/> 
  66.     <debugger:MonsterDebuggerFlex id="monsterDebugger" visible="true" width="100" height="100"/> 
  67. </s:Application> 

[flex]as3commons log使用方法

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器