Skip to content

Logging

Rodrigo Fernandez edited this page Jul 21, 2014 · 10 revisions

A simple logging utility is available on both client and server side through LAZO.logger.

It supports four logging levels: info, warn, error and debug.

// There are 4 log levels: info, warn, error and debug.
logger.info('Lorem ipsum dolor sit amet');
logger.warn('Lorem ipsum dolor sit amet');
logger.error('Lorem ipsum dolor sit amet');
logger.debug('Lorem ipsum dolor sit amet');

Log levels can be changed during runtime.

logger.setLevel('warn');

It accepts more than one argument and printf-style formatting.

logger.debug('Lorem %s dolor %s amet', 'ipsum', 'sit'); // Lorem ipsum dolor sit amet
logger.debug('integer: %d', 3.14159); // integer: 3
logger.debug('integer: %i', 3.14159); // integer: 3
logger.debug('float: %f', 3.14159); // float: 3.14159
logger.debug('json: %j', {foo:123, bar:456}); // json: {"foo":123,"bar":456}