SimpleLogger

SimpleLogger

The simplest logging application (AIR) for Flash, Flex, and AIR development inspecting into a deeply nested object such as Array, ArrayCollection1, Object, and XML. You can easily look inside these objects on the console.

SimpleLogger schematic

Figure 1. SimpleLogger schematic.

Version info

Goodies using SimpleLogger

The same kind of software is out there. The differences between SimpleLogger and these following are:

Target class for SimpleLogger to inspect

Object, Array, ArrayCollection1, XML, TextField, String, and so on.

System requiremens for the application

Download

You need the following two: AIR application (Console) and ActionScript library (Client).

  1. AIR application (Console)

    Install automatically from the button below. If you could not install it automatically, try manual install from here (you may probably need to install Adobe AIR Runtime).

    CAUTION: You need the latest Flash Player to play the movie correctly. » Download the Flash Player
  2. ActionScript library (Client) that inclues:

    • SimpleLogger.as - Standard client class
    • SimmpleLoggerMx.as - Client class for a project including Flex's mx-package (ArrayCollection etc.)

How to use SimpleLogger

  1. Run SimpleLogger app.
  2. Pass the object you would like to inspect to SimpleLogger.trace(), or SimpleLoggerMx.trace() method (the method is defined in the AS file, so import com.borealkiss.SimpleLogger, or com.borealkiss.SimpleLoggerMx). For example, when you would like to inspect into a following nested array, write a code in your swf file like this:
    import com.borealkiss.SimpleLogger;
    
    var ary:Array = ["This","is","a","nested","array", 
                    {platform:"Flex", flash_player:"9"},
                    ["This","is","a",{R:"Rich",I:"Internet",A:"Application"}]];
                    
    SimpleLogger.trace(ary);
    
    Then SimpleLogger console will show the result like this:
    [0] => "This"
    [1] => "is"
    [2] => "a"
    [3] => "nested"
    [4] => "array"
    [5] => [flash_player] => "9"
    [5] => [platform] => "Flex"
    [6] => [0] => "This"
    [6] => [1] => "is"
    [6] => [2] => "a"
    [6] => [3] => [A] => "Application"
    [6] => [3] => [I] => "Internet"
    [6] => [3] => [R] => "Rich"
    
    Note that SimpleLogger.trace() method is static so that you don't need instantiate it by new. Next consider the following case with Object;
    import com.borealkiss.SimpleLogger;
    
    var obj:Object = {  first:"This",
                        second:"is",
                        third:{one:"a",two:"nested",three:"Object"}};
    
    SimpleLogger.trace(obj);
    
    When you run the preceding code in your swf file, the SimpleLogger console will get the following result:
    [third] => [two] => "nested"
    [third] => [three] => "Object"
    [third] => [one] => "a"
    [second] => "is"
    [first] => "This"
    
    It is possible to examine an XML object. The SimpleLogger console shows each node name in a tree-like style (see the top image). Note that attributes of an XML object are not analyzed for the moment;
    import com.borealkiss.SimpleLogger;
    
    //Example of XML object
    var xml:XML = <users>...</users>;  
    SimpleLogger.trace(xml);
    
    ArrayCollection class object is defined in Flex's mx package, so use SimpleLoggerMx.trace(). The standard SimmpleLogger.trace() will NOT work in this case;
    import com.borealkiss.SimpleLoggerMx;
    
    var ac:ArrayCollection = new ArrayCollection([  {name:"Martin Foo",age:25},
                                                    {name:"Joe Bar",age:15},
                                                    {name:"John Baz",age:23}]);
                    
    SimpleLoggerMx.trace(ac);
    
    The result will be shown up in the SimpleLogger console:
    [0] => [age] => "25"
    [0] => [name] => "Martin Foo"
    [1] => [age] => "15"
    [1] => [name] => "Joe Bar"
    [2] => [age] => "23"
    [2] => [name] => "John Baz"
    

Note

1 ArrayCollection must be analyzed by SimpleLoggerMx class that suits a project including Flex's mx-package. For more detail, see the example above.

Contact

info [AT] boreal-kiss [DOT] com


Powered by blog Boreal Kiss 2008.