Using the Flex Trace Panel
사용법:
1. 위의 파일을 압축 푼 후에 bin 디렉토리안에 있는 실행 파일을 실행 시킨다.
2. src 디렉토리안에 있는 폴더를 자신의 프로젝트 안의 src에 복사한다.
3. 로그를 사용하고 싶은 파일에 다음과 같은 코드를 삽입한다.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
import de.richinternet.utils.Dumper;
private function sayHello():Void {
Dumper.dump("Hello World!");
}
]]>
</mx:Script>
<mx:Button label="Say Hello!" click="sayHello()"/>
</mx:Application>
Using the Flex Trace Panel
To use the Flex Trace Panel, unzip the downloaded ZIP file to a directory of your choice. The directory contains an src and a bin folder, with the Flex Trace Panel executable in the bin Folder. You may want to copy this file to another location on your machine.
The src folder contains a directory structure for the Dumper class. Copy the contents of the src folder to your Flex server, so that the Dumper class is available to your Flex application. In general, place the Dumper class in the class path of your Flex application. To make the Dumper class available to all of your Flex applications (recommended for a testing or development system) simply copy the directory structure to the user_classes directory of your Flex server. With a default, out-of-the-box Flex 1.5 installation, this is at:
C:\Program Files\Macromedia\Flex\jrun4\servers\default\flex\WEB-INF\flex\user_classes
If you only want to use the Dumper class in a single application, copy the de.richinternet.utils.* package to the root of your Flex application.
After you install the source files, it's time to start the show.
Create a new Flex application and add the following code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
import de.richinternet.utils.Dumper;
private function sayHello():Void {
Dumper.dump("Hello World!");
}
]]>
</mx:Script>
<mx:Button label="Say Hello!" click="sayHello()"/>
</mx:Application>
Start the Flex Trace Panel and run your Flex application. When you click the button, the following message will appear in the output window.
Figure 1. Sample output from the Flex Trace Panel
The [INFO] text printed left to the message indicates the log level of the message, while (String) tells you the type of data sent. This is extremely helpful when passing complex data such as Arrays or nested Objects to the Trace Panel.
As mentioned before, you can set up your applications to send any data type to the Flex Trace Panel. For example, if you want to output the content of the DataProvider attached to the DataGrid myGrid you simply write:
Dumper.dump(myGrid.dataProvider);
The Dumper class provides several methods to send data with different log levels to the Trace Panel. This is convenient if you for example want to indicate whether a certain message is an error message or just simple information. The log levels are:
INFOWARNERROR
Here's a listing of all available methods of the Dumper class:
Dumper.dump(message:Object):Void
takes the passed Object (any type) and routes it to the Flex Trace Panel with log levelINFODumper.info(message:Object):Void
takes the passed Object (any type) and routes it to the Flex Trace Panel with log levelINFODumper.warn(message:Object):Void
takes the passed Object (any type) and routes it to the Flex Trace Panel with log levelWARNDumper.error(message:Object):Void
takes the passed Object (any type) and routes it to the Flex Trace Panel with log levelERROR
To distinguish between messages with different log levels, you can use the Flex Trace Panel to filter messages on their log level. By using the Level menu of the Trace Panel, you can filter all received messages. Internally, the Flex Trace Panel uses a message buffer to filter messages dynamically.
Figure 2. Filtering messages in the Flex Trace Panel
To save the content of the output text field to a text file, click the save icon or select Save from the File menu. To clear the text field, select File > Clear or click the trash can icon.
This article explained how you can use the Flex Trace Panel while you develop Flex applications. As with any other software, the Flex Trace Panel will keep evolving. Especially, I'd like to update it so that it runs with Flex 2 and the new Flex 2 Logging API. Stay tuned on developments with the Flex Trace Panel category on my blog.


flextracepanel-1.5b2(2).zip
