package bontos.firebugTracer
{
import flash.external.ExternalInterface;
/**
* FirebugConsole class provides some functionality of Firebug console.
*/
public class Fbug
{
/**
* Constructor. You cannot create an instance of FirebugConsole,
* because all its methods are static.
*/
public function Fbug ( )
{
throw new Error( 'You cannot create an instance of FirebugConsole' );
}
/**
* Writes a message to the console and opens a nested block to indent
* all future messages sent to the console.
* Call FirebugConsole.groupEnd()
to close the block.
*
* @param title Title of opened group
*/
public static function group ( title : String ) : void
{
Fbug.call( 'function(title){try{console.group(title);}catch(e){}}', title );
}
/**
* Closes the most recently opened block
* created by a call to FirebugConsole.group(title)
.
*/
public static function groupEnd ( ) : void
{
Fbug.call( 'function(){try{console.groupEnd();}catch(e){}}' );
}
/**
* Writes a log message to the Firebug console.
*
* @param message Message
*/
public static function log ( message : * ) : void
{
Fbug.call( 'function(message){try{console.log(message);}catch(e){}}', message );
}
/**
* Writes a debug message to the Firebug console.
*
* @param message Message
*/
public static function debug ( message : * ) : void
{
Fbug.call( 'function(message){try{console.debug(message);}catch(e){}}', message );
}
/**
* Writes a info message to the Firebug console.
*
* @param message Message
*/
public static function info ( message : * ) : void
{
Fbug.call( 'function(message){try{console.info(message);}catch(e){}}', message );
}
/**
* Writes a warn message to the Firebug console.
*
* @param message Message
*/
public static function warn ( message : * ) : void
{
Fbug.call( 'function(message){try{console.warn(message);}catch(e){}}', message );
}
/**
* Writes a error message to the Firebug console.
*
* @param message Message
*/
public static function error ( message : * ) : void
{
Fbug.call( 'function(message){try{console.error(message);}catch(e){}}', message );
}
/**
* @private
*/
private static function call ( functionAsString : String, param : * = null ) : void
{
if( !ExternalInterface.available )
return;
if( param != null )
ExternalInterface.call( functionAsString, param );
else
ExternalInterface.call( functionAsString );
}
}
}