ibmmfpfanalytics.logger

JavaScript File:
ibmmfpfanalytics.js
Description:
ibmmfpfanalytics.logger

The IBM® MobileFirst® logger API facilitates logging to the IBM MobileFirst server at all levels. Additionally it receives logging configuration from the server.

Note: The data collected via the logger API can be sent to the IBM MobileFirst server and become available in the MobileFirst Analytics Console (Apps -> Client Log Search).


Method Summary
Method Attributes Method Name and Description
 
capture(flag)

Enable or disable the capture of the log messages.

 
debug(message)

Logs a message with additional contextual information at the debug level.

 
enable(flag)

Enable or disable the logger.

 
error(message)

Logs a message with additional contextual information at the error level.

 
fatal(message)

Logs a message with additional contextual information at the fatal level.

 
info(message)

Logs a message with additional contextual information at the info level.

 
log(message)

Logs a message with additional contextual information at the log level.

 
pkg(packageName)

Adds optional package for the logger.

 
state()
Returns the current state of logger.
 
trace(message)

Logs a message with additional contextual information at the trace level.

 

Takes or updates the logger configuration definitions made on the MobileFirst server.

 
warn(message)

Logs a message with additional contextual information at the warn level.

Method Detail
capture
<inner> capture(flag)

Enable or disable the capture of the log messages.
By disabling the capture the messages will not be stored in the browser localStorage and later delivered to the back-end.

Parameters:
{boolean} flag
Example:
logger.capture(false);

debug
<inner> debug(message)

Logs a message with additional contextual information at the debug level.

Log messages are automatically added to a persistent queue. The accumulated data is automatically sent to IBM® MobileFirst® server with the next explicit logger.send function call.

Parameters:
{string or object} message - The message(s) to log.
Example:
logger.debug('my record');
// or
logger.debug({data: [1,2,3]});
//or
logger.debug('my record', 'another message');

enable
<inner> enable(flag)

Enable or disable the logger.

Parameters:
{boolean} flag - If disabled, the logger messages will not be printed to the console and will not be sent to the back-end.
Example:
logger.enable(true);

error
<inner> error(message)

Logs a message with additional contextual information at the error level.

Log messages are automatically added to a persistent queue. The accumulated data is automatically sent to IBM® MobileFirst® server with the next explicit logger.send function call.

Parameters:
{string or object} message - The message(s) to log.
Example:
logger.error('my record');
// or
logger.error({data: [1,2,3]});
//or
logger.error('my record', 'another message');

fatal
<inner> fatal(message)

Logs a message with additional contextual information at the fatal level.

Log messages are automatically added to a persistent queue. The accumulated data is automatically sent to IBM® MobileFirst® server with the next explicit logger.send function call.

Parameters:
{string or object} message - The message(s) to log.
Example:
logger.fatal('my record');
// or
logger.fatal({data: [1,2,3]});
//or
logger.fatal('my record', 'another message');

info
<inner> info(message)

Logs a message with additional contextual information at the info level.

Log messages are automatically added to a persistent queue. The accumulated data is automatically sent to IBM® MobileFirst® server with the next explicit logger.send function call.

Parameters:
{string or object} message - The message(s) to log.
Example:
logger.info('my record');
// or
logger.info({data: [1,2,3]});
//or
logger.info('my record', 'another message');

log
<inner> log(message)

Logs a message with additional contextual information at the log level.

Log messages are automatically added to a persistent queue. The accumulated data is automatically sent to IBM® MobileFirst® server with the next explicit logger.send function call.

Parameters:
{string or object} message - The message(s) to log.
Example:
logger.log('my record');
// or
logger.log({data: [1,2,3]});
//or
logger.log('my record', 'another message');

pkg
<inner> pkg(packageName)

Adds optional package for the logger.

You can chain pkg() to the log calls as shown in the example below.
Parameters:
{string} packageName - the package name
Example:
logger.pkg('com.mycompany.mymodule').info('my message');

state
<inner> state()
Returns the current state of logger.
Returns:
the current state of the ibmmfpfanalytics.logger
Example:
ibmmfpfanalytics.logger.state();

trace
<inner> trace(message)

Logs a message with additional contextual information at the trace level.

Log messages are automatically added to a persistent queue. The accumulated data is automatically sent to IBM® MobileFirst® server with the next explicit logger.send function call.

Parameters:
{string or object} message - The message(s) to log.
Example:
logger.trace('my record');
// or
logger.trace({data: [1,2,3]});
//or
logger.trace('my record', 'another message');

updateConfigFromServer
<inner> {Promise} updateConfigFromServer()

Takes or updates the logger configuration definitions made on the MobileFirst server.

Returns:
{Promise} Resolved with the configuration returned from server, rejected with an error message.
Example:
logger.updateConfigFromServer()
.then(function (response) {
	console.log(response);
})	 
.catch(function (error) {
	console.log(error);
 });

warn
<inner> warn(message)

Logs a message with additional contextual information at the warn level.

Log messages are automatically added to a persistent queue. The accumulated data is automatically sent to IBM® MobileFirst® server with the next explicit logger.send function call.

Parameters:
{string or object} message - The message(s) to log.
Example:
logger.warn('my record');
// or
logger.warn({data: [1,2,3]});
//or
logger.warn('my record', 'another message');

© Copyright IBM Corp. 2011, 2016.