Debugging
The debugging library allows logging onto different outputs like Firebug, De MonsterDebugger, Alcon or a built in LogPanel.
As the debugging functionality is implemented in an external library we have to first include the modularDebug.swf file. The functionality is ready as soon as the swf file is loaded so it makes sense to load the swf as early as possible. Thats why we include it as an asset in the PreloaderPage which assets are loaded before the main Page assets. An example boot.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?> <ModularApplication> <Page> <Assets> <Library path="swf/ProjectLibrary.swf" /> </Assets> <Modules> <Module class="modules.Text" /> </Modules> </Page> <PreloaderPage> <Assets> <!-- include the debug library that allows us to debug/log on different logging outputs. --> <Library path="swf/modularDebug.swf" /> </Assets> </PreloaderPage> </ModularApplication>
To configure the outputs - where the logging messages should be traced - we create a Logger node in the boot.xmland specify which output we want to use like this:
<?xml version="1.0" encoding="UTF-8"?> <ModularApplication> <Page> <Assets> <Library path="swf/ProjectLibrary.swf" /> </Assets> <Modules> <Module class="modules.Text" /> </Modules> </Page> <PreloaderPage> <Assets> <Library path="swf/modularDebug.swf" /> </Assets> </PreloaderPage> <!-- the Logger node to setup outputs. --> <Logger> <PanelOutput /> <MonsterOutput /> <AlconOutput /> <FirebugOutput /> </Logger> </ModularApplication>
Furthermore we have the ability to filter the log messages on levels and scopes:
Levels
modular supports three levels for logging messages: info, warn and error that are used by the way you use the logging framework:
Logger.info( "message" ); Logger.warn( "message" ); Logger.error( "message" );
Scopes
Additional to the levels you can specify a scope for ever log message. For example if you want log all messages from the backend to the "backend" scope you can use the Logging framework like this:
Logger.info( "backend info message", "backend" ); Logger.warn( "backend warn message", "backend" ); Logger.error( "backend error message", "backend" );
Its a good practise to defined a public static constant variable for the scope. In the example above it could be: Backend.LOG:String = "backend".
If you dont specify a scope it will use the scope "default". All modular log messages have the scope "modular".
Filter messages
Now you can filter on scopes and levels for every output as the following example shows:
<Logger> <!-- traces only error messages ( level1 ) from the modular scope to the log panel --> <PanelOutput level="1" scope="modular" /> <!-- traces all levels from the modular and the backend scope to the monster debugger --> <MonsterOutput scope="backend,modular" /> <!-- traces all levels and all scopes to the alcon debugger --> <AlconOutput /> <!-- traces warn ( level2 ) and error (level1) levels and all scopes to the firebug panel --> <FirebugOutput level="2" /> </Logger>
Comments