addLogListener( LogListener, [containingObject] ) method

Register the log listener.

Syntax

<static> addLogListener( LogListener, [containingObject] )

Parameters

Name Type Argument Description
LogListener anonymous.LogListener   Callback for changes to the log.
containingObject Object (optional) Object containing definition for LogListener.If a log listener callback function references variables in its containing object, then the containing object should be passed to this function.

Example

// A global function called by the log listener.
var doSomething = function()
{
   alert("this gets displays when there is a log event.");
}
// The log listener callback function that will be passed to hwc.addLogListener.
// This function will be invoked whenever there is a log event.
var logListener = function( event, errorCode, errorMessage )
{
   doSomething();
}
// Add the log listener.
hwc.addLogListener( logListener );
// logListenerManager is an object that will contain the listener callback as well
// as a function that will be invoked from the listener callback function.
var logListenerManager = {};
// This is a function that is called from the listener callback.
logListenerManager.doSomething = function()
{
   alert("this gets displays when there is a log event.");
}
// This is the listener callback that will be passed to hwc.addLogListener.
// Since a variable is referenced from the containing object, the containing object
// will need to be passed to hwc.addLogListener.
logListenerManager.listener = function( event, errorCode, errorMessage )
{
   this.doSomething();
}
// Pass both the listener callback and the containing object.
hwc.addLogListener( logListenerManager.listener, logListenerManager );

Source

hwc-api.js, line 757.