I’ve discovered myself that logging can save a lot of time in developing an application. I’ve used initially the well known trace action, that permits to send messages to the Output Panel in Flash (or FlashDevelop) or Flex Builder IDE.
Then I’ve used some class like Out from BigSpaceShip Labs. I’ve added a call to the debug method of the Out class in all the methods of my classes, using it like this:
1 2 3 4
| private function constructUI():void {
Out.info(this, "constructUI");
/*...*/
} |
and having an output like this:
INFO: com.unicoshop.UnicoShop: setConnection
INFO: com.unicoshop.UnicoShop: initApplication
INFO: com.unicoshop.views.TabView: setApplicationGlobally
INFO: com.unicoshop.views.stats.StatisticheVenditeTempoReale: setConnection
INFO: com.unicoshop.views.manager.VenditaArticoli: setConnection
INFO: com.unicoshop.views.manager.ArticoliResiFornitore: setConnection
INFO: com.unicoshop.views.manager.ArticoliVenduti: setConnection
Out is powerful than the trace command, but like it doesn’t work outside of the IDE.
So I googled and I found this two great logging tools, both works in Flash and Flex projects, works under Windows, Macintosh and Linux, and both permits to log the output of Flash and Flex in a custom AIR Application (using LocalConnection to connect to the source swf or reading the flashlog.txt outputted by the debug version of the Flash Player):
- Thunderbolt
(from the website)
ThunderBolt is a logger extension for Flash ActionScript 2 and 3 as well as Flex 2 and 3 applications based on the Firebug add-on for Firefox.For logging without Firebug, especially for AIR applications, check out the new ThunderBolt AS3 Console. Unfortunately the Thunderbolt AS3 Console AIR application doesn’t work on Windows, due to a “limitation” of the win version of the AIR Runtime.
Update: the problem is fixed installing the updated AIR 1.1, I’ve just tested it!
Usage example:
1
| import org.osflash.thunderbolt.Logger; |
Logger.includeTime = true;
Logger.memorySnapshot();
var myNumber:int = 5;
var myString:String = “Lorem ipsum”;
Logger.debug(“My debug message”, myNumber, myString);
Logger.error(“My error message”, myNumber, myString);
Logger.info(“My info message”, myNumber, myString);
Logger.warn(“My warning message”, myNumber, myString);
This is a screenshot of my system running a Flex based AIR application, logged with anthropod:
