Adobe Flex Flash developer blog

Adventures of a Flex developer

Logging panel

Thursday 18 February 2010 by jonnysparkplugs

If you haven’t been using logging in your flex application, you have been missing out on a very useful debug tool.  By logging I do not mean the trace command which will output the trace window in Flex builder.  I mean the Flex3 Logging API.

The logging API is based on the java API which was introduced in JDK 1.4.  For more info on using logging see the API, also the Wrox book “Professional Adobe Flex 3” has a very useful chapter on logging.
I have created the logging panel which displays the log messages created in a handy TitleWindow, the title window simply displays the log messages.  This is done by overriding the mx_internal function internalLog and redirecting the output.

 package indecentmonkey.logging  
 {  
      import mx.controls.TextArea;  
      import mx.core.mx_internal;  
      import mx.logging.targets.LineFormattedTarget;  
      use namespace mx_internal;  
      public class LogPanelTarget extends LineFormattedTarget {  
           private var _loggingTA:TextArea;  
           public function LogPanelTarget(console:TextArea) {  
       super();  
       this._loggingTA = console;  
           }  
           override mx_internal function internalLog(message:String):void {  
       this._loggingTA.text += message + "\n";  
           }  
   }  
 }  












You will not need a debug flash player to see the output.  Enjoy...

Filed under having  

0 comments:

Post a Comment