My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Documentation  
Full documentation for old version (1.2.2 and below)
Updated Nov 6, 2009 by oyvind.n...@gmail.com

Documentation

The constructor has this signature:

function AILogger ($password:String = "", $width:uint = 0, $height:uint = 0)

  • $pasword: Optional password to ensure authorized access to the logger. When supplied, the first time you invoke the logger, a password prompt will show up.

Type in the password you gave the constructor. Focus is already set to the input field, just begin typing. The text you enter will remain red as long as it's wrong and it turns green when you've typed the complete correct password. Hit enter and the logger shows up.

  • $width / $height: Optional dimentions for the logger. Handy if you want to be able to use the application while observing the log at the same time.

The log function has the following signature:

function log($msg:Object, $severity:int = AILoggerEvent.CODE_INFO, $appendLast:Boolean = false):void

  • $msg: What you want to appear in the logger. It can be basically anything. It does not need to be a string. If this parameter is something not natively handled by the logger, it will try to make the best of it with the insignia "(recovered)" preceeding it.
  • Tip: If the $msg parameter is recognized as a HEX color value (say 0xff0000) the log line will be colored with that color, and both the raw toString and HEX code will be displayed.
  • $severity: AILogger supports four levels of severity designated in the log window by their color. The severity levels are defined in the supporting AILoggerEvent class as numbers from 0 through 4. These are the different variations:
  • CODE_INFO: Default, black/hvite text.
  • CODE_WARNING: Orange text.
  • CODE_ERROR: Red text. Logging Errors or ErrorEvents automatically yelds this severity.
  • CODE_SUCCESS: In case you wanna shout it, this turns the text green.
  • CODE_EVENT: Blue text, logging events defaults to this code
  • NEW CODE_TRACE: Gray text to signify lower importance
  • $appendLast: This Boolean lets you append the message to the last line logged.

The log function also makes sure that you don't waste screen space when repeating the same message in a row. If the same message is logged repeatedly (i.e. in a for-loop) the number of times it has been repeated will be displayed in parenthesis after the message. I.e. "Hello Planet (16)" means you logged "Hello Planet" 16 times.

Options

There are a few options you can use to control and customize the logger.

  • inverseColorScheme - (true/false): Sets the logger theme to a white-on-black appearance that comes in handy on top of very bright content. Or if you just want to play it Matrix-style :-)
  • disablePassword - (true/false): Lets you disable the password prompt even thought you have supplied a password. Note: Passing nothing or an empty string to the constructor also effectively disables the password prompt.
  • detailedLogging: Gives you in general more information when logging complex data types like arrays, events, errors and unrecognized types. This last one will display as a full XML description of the object being logged, which can easily fill up the entire window, so you might want to use this for specific debugging.
  • coloring: Turns log line severity coloring on or off.
  • disableSenderLabel: Disables the part in log lines after ~ which is the origin of the log message
  • enableContextMenu - (true/false): Enables or disables the ability to open the logger from the Flash Player context menu.
  • isVisible: Returns whether the logger is open or not.

Public Methods

In addition to writing log lines, there's a handful of other utility methods you can use.

  • describe($obj:Object, $objectName:String = ""): Lets you pass in any object and the result is a list of properties belonging to that object. Use the $objectName argument to insert a custom name above to help distinguish the information in the log window.
  • header($text:String): Lets you insert a headline with empty lines before and after to signify an important phase in the program.
  • cr($numLines:uint = 1): Inserts the desired number of empty lines.
  • toggle(): You guessed it.. Toggles the logger on or off. Password prompt enabled if so configured.
  • getLogText(): Returns the full contents of the logger.

AILoggerEvent

This is the supporting event class you can use for loose coupling. It has pretty much the same signature as the log() method. The log method can be used as an event handler for these events. It also contains the constants for the severity codes.

Event types:

  • LOG: Regular logging, just like calling the log() method directly
  • DESCRIBE: Lists all available properties of the object being the msg parameter.

Event signature:

function AILoggerEvent($type:String, $message:Object, $appendLast:Boolean = false, $severity:uint = 0, $origin:Object = null, $bubbles:Boolean = false, $cancelable:Boolean = false)

  • Tip: Use the origin parameter to identify where a log message came from. Typically you just enter "this" when dispatching the AILoggerEvent, and the class name appears in the log.

Suggestions?

Please leave a comment!


Sign in to add a comment
Powered by Google Project Hosting