Skip to content

Customizing Logging

arthur-debert edited this page Oct 15, 2010 · 1 revision

BulkLoader comes with a flexible and customizable logging facility.

Logging Levels

You can choose at which level you'd like BulkLoader to trace messages.

Specifing Logging Levels

The constructor's 3rd parameter is an int, the logging level. Examples:

// verbose: logs everything that happens
var loader : BulkLoader = new BulkLoader("main", 5, BulkLoader.LOG_VERBOSE)
// errors only:
var loader : BulkLoader = new BulkLoader("main", 5, BulkLoader.LOG_ERRORS)

Or you can set the logLevel property at any time:

BulkLoader.logLevel = BulkLoader.LOG_INFO;

What each level filters

BulkLoader's default logging is LOG_ERRORS. It's a reasonable level, since it will only trace messages in case something goes wrong:

  • LOG_SILENT : nothing will be traced.
  • LOG_ERRORS: the default level. Will log:
    • If an item fails to load.
    • If retrieving content fails.
  • LOG_INFO: besides everything that LOG_ERRORS traces:
    • When an item is starting to load.
    • When an item is finished loading.
    • When a loading operation received a response.
    • When all items are loaded.
  • LOG_VERBOSE: Pretty much everything, usefull for debugging. Besides everything that LOG_INFO traces:
    • When an item has been added.
    • When an item has been removed.
    • When an item has been stoped.
    • When an item has been resumed.
    • All download stats when all items are loaded.

Using your own logging function

If you'd rather do something else with the messages BulkLoader logs, you can specify you own logging function. Just set the BulkLoader.logFunction property to another function:

<bulkLoader>.logFunction = myLogger;

function myLogger(msg : String) : void{
  // do sothing with that message here
}

The logging function will receive one parameter, a string of the message to log.