Skip to content

Instantly share code, notes, and snippets.

@shaunoconnor
Created November 28, 2010 22:50
Show Gist options
  • Save shaunoconnor/719369 to your computer and use it in GitHub Desktop.
Save shaunoconnor/719369 to your computer and use it in GitHub Desktop.
package com.shaunoconnor.utils.log
{
/**
* ThunderBolt Logger
* http://code.google.com/p/flash-thunderbolt/
*/
import org.osflash.thunderbolt.Logger;
import flash.utils.getQualifiedClassName;
/**
* @author shaun
*/
public class SimpleLogger
{
/**
* Switch between trace / log
*/
public static var inBrowser : Boolean = false;
/**
* Turn loggin on / off
*/
public static var loggingOn : Boolean = true;
/**
* Static method for tracing / logging to Firebug console
*
* <br /><br />
* <b>EXAMPLE:</b>
* <br /><br />
*
* <code>
*
* import com.shaunoconnor.utils.log.SimpleLogger;<br /><br />
*
* // call debug<br /><br />
* SimpleLogger.debug( this, 'onRegister()' );<br /><br />
*
* // output<br /><br />
* // DEBUG : com.shaunoconnor.project.view.mediators::AViewMediator onRegister()<br /><br />
*
* </code>
*
*
* @param classref The Class that debug() is called from
* @param rest additional properties to be logged
*/
public static function debug( classref : Object, ... rest ) : void
{
if ( !loggingOn ) return;
var logrest : String = "";
for ( var i : uint = 0 ; i < rest.length ; i++ )
{
logrest += ", " + rest[ i ];
}
if ( inBrowser )
Logger.debug( getQualifiedClassName( classref ), logrest );
else
trace( 'DEBUG :', getQualifiedClassName( classref ), logrest );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment