startLogListener( successCB, errorCB, logListener, [containingObject] ) method

Registers a log listener.

Syntax

<static> startLogListener( successCB, errorCB, logListener, [containingObject] )

Parameters

Name Type Argument Description
successCB anonymous.startOrStopLogListenerSuccessCallback   A callback function that will be invoked if the log listener is successfully registered.
errorCB anonymous.startOrStopLogListenerErrorCallback   A callback function that will be invoked if there is an error registering the log listener.
logListener anonymous.logListener   The callback to register.This will be invoked when new entries are added to the log.
containingObject Object (optional) Object containing the 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

// This example shows how to use this function with a globally-scoped logListener.
// A global function called by the log listener.
var doSomething = function()
{
   alert("this gets displayed when there is a new log entry.");
}

// The log listener callback function that will be passed to AppLog.startLogListener.
// This function will be invoked whenever there is a new log entry.
var logListener = function( date, statusCode, message )
{
   doSomething();
}

function onStartLogListenerSuccessCallback() {
   // Do something here after listener has been added
}

function onStartLogListenerFailureCallback(error) {
   // React to error here
}

// Add the log listener.
AppLog.startLogListener( onStartLogListenerSuccessCallback,
                         onStartLogListenerFailureCallback,
                         logListener );
// This example shows how to use this function with a logListener contained in an object.
// 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 displayed when there is a new log entry.");
}

// This is the listener callback that will be passed to AppLog.startLogListener.
// Since a variable is referenced from the containing object, the containing object
// will need to be passed to AppLog.startLogListener.
logListenerManager.listener = function( date, statusCode, message )
{
   this.doSomething();
}

function onStartLogListenerSuccessCallback() {
   // Do something here after listener has been added
}

function onStartLogListenerFailureCallback(error) {
   // React to error here
}

// Pass both the listener callback and the containing object.
AppLog.startLogListener( onStartLogListenerSuccessCallback,
                         onStartLogListenerFailureCallback,
                         logListenerManager.listener,
                         logListenerManager );

Source

Plugins/AppLog/applog.js, line 249.