Wiki
Clone wikidsair / LogManager
HOWTO: LogManager: Easy app logging
Introduction
DSAir comes with a simple logger that we can use to keep track of log messages. In debug mode, all logs are traced as well. Logs can be viewed using the built-in display, and easily copied to the clipboard.
Details
Check out the TestLogging.as file for the full details.
As with all examples, you need to init the framework before doing anything:
#!actionscript DSAir.init( this ); // "this" is your Document class
##Logs, warnings, and errors##
The LogManager has 3 functions for logging:
#!actionscript LogManager.instance.log( this, "This is a log message" ); LogManager.instance.warn( this, "This is a warning" ); LogManager.instance.error( this, "This is an error" );
Logs are colour coded depending on their level. The first parameter is the object calling the log function. This is saved to let you know where your log came from.
There's also convenience functions in the DSAir
class:
#!actionscript DSAir.log( this, "This is a log message from the DSAir class" ); DSAir.warn( this, "This is a warning message from the DSAir class" ); DSAir.error( this, "This is an error message from the DSAir class", false );
The DSAir
functions are functionally similar except for one difference: the DSAir.error()
function has an extra parameter that if set to true
will also show an error alert to the user.
##Viewing the logs##
You can view the log display by pressing Ctrl+Shift+L, or through code by using the LogManager.instance.visible
property. When the log display is open, you can use Pg-up and Pg-down to move the log up and down. Pressing Ctrl+C will copy the log to the clipboard.
Updated