+

Search Tips | Advanced Search

Skip navigation links

Index Overview

PREV CLASS NEXT CLASS FRAMES (opens in new window)



Class WL.Logger

WL.Logger



Method Summary
Method Attributes Method Name and Description
 

config(options)

Configures the logger globally.

 

create(options)

Creates an instance of a logger with its own context (also called status or state).

 

ctx(options)

Updates the state (also called context or status) of the logger.

 

debug(message)

Prints arguments to the console.

 

error(message)

Prints arguments to the console.

 

fatal(message)

Prints arguments to the console.

 

info(message)

Prints arguments to the console.

 

log(message)

Prints arguments to the console.

 

metadata(options)

Attach additional metadata to the next logger instance call.

 

off()

 

on(options)

 

send()

Send any logs collected up to this point to the IBM Worklight server.

 

setNativeOptions(options)

 

status()

Shows the status (current configuration) of the logger.

 

trace(message)

Prints arguments to the console.

 

updateConfigFromServer()

Retrieves and applies any matching configuration profile from the IBM Worklight Server.

 

warn(message)

Prints arguments to the console.

Method Detail

config

{this} config(options)

Configures the logger globally. This means every logger instance created using WL.Logger.create, all uses of the global WL.Logger functions and any native API calls to the MobileFirst logger API are affected.


create

{LogInstance} create(options)

Creates an instance of a logger with its own context (also called status or state).


ctx

{this} ctx(options)

Updates the state (also called context or status) of the logger.


debug

debug(message)

Prints arguments to the console. Has a priority of


error

error(message)

Prints arguments to the console. Has a priority of


fatal

fatal(message)

Prints arguments to the console. Has a priority of


info

info(message)

Prints arguments to the console. Has a priority of


log

log(message)

Prints arguments to the console. Has a priority of


metadata

metadata(options)

Attach additional metadata to the next logger instance call.

    Parameters:
    {Object} options Optional - an object to attach to the next logger instance call

    Example:

    WL.Logger.metadata( { userRealName : 'Robert Paulson' } );

WL.Logger.metadata( { hi : 'world' } ).info('hello');


off

{this} off()

    Returns:
    {this} Returns the current instance.

    Deprecated:
    since version 6.2. WL.Logger.off is now a NOP. WL.Logger is always enabled. Use WL.Logger.config with {'level': 'FATAL'} to reduce verbosity.


on

{this} on(options)

    Parameters:
    options

    Returns:
    {this} Returns the current instance.

    Deprecated:
    since version 6.2. WL.Logger.on is now a no-op. WL.Logger is always enabled. Use WL.Logger.config with {'level': 'FATAL'} to reduce verbosity.


send

{Promise} send()

Send any logs collected up to this point to the IBM Worklight server.

    Returns:
    {Promise} Resolved with success status, rejected with an error message.


setNativeOptions

setNativeOptions(options)

    Parameters:
    {Object} options Optional - an object that optionally contains any of the following key/value pairs:

    • maxFileSize: integer (minimum allowed is 10000 (in bytes))
    • level: String (any of the following values: 'trace', debug', 'log', 'info', 'warn', 'error', 'fatal')
    • capture: boolean

    Deprecated:
    since version 6.2. Use WL.Logger.config instead. Sets options in native application layer (iOS and Android only)

    Example:

    WL.Logger.setNativeOptions( { maxFileSize : 100000, // allow persistent storage of up to 100k of log data level : 'debug', // at debug (and above) level capture : true, // capture data passed to log API calls into persistent storage filters : { jsonstore : 'debug' } // establish whitelist filters at native } );


status

{Promise} status()

Shows the status (current configuration) of the logger.

    Returns:
    {Promise} Resolved with current status, rejected with an error message.

    Example:

    WL.Logger.status() .then(function (state) { //{ enabled : true, stringify: true, filters : {}, // level : 'info', pkg : '', tag: {level: false, pkg: true} } }) .fail(function (errMsg) { //errMsg = error message });


trace

trace(message)

Prints arguments to the console. Has a priority of

    600 and a level of TRACE.
    						
    						 
    					
    					
    					
    					
    					
    					
    							
    

      Parameters:
      message - One or more messages of any data type.

      Example:

      WL.Logger.trace('Hello world'); //Hello world


updateConfigFromServer

updateConfigFromServer()

Retrieves and applies any matching configuration profile from the IBM Worklight Server. A matching configuration profile acts as an override of the local configuration. Configuration profiles are defined by the IBM Worklight administrator in the Worklight admin console. Restores to original settings when the server indicates that no matching configuration profile exists. This API call is only applicable in Android and IOS environments. It is a safe, but no-op, call in other environments.

    Returns:
    promise


warn

warn(message)

Prints arguments to the console. Has a priority of

    200 and a level of WARN.
    						
    						 
    					
    					
    					
    					
    					
    					
    							
    

      Parameters:
      message - One or more messages of any data type.

      Example:

      WL.Logger.warn('Hello world'); //Hello world


© Copyright IBM Corp. 2011, 2016.