Skip to content

Logging

wwitman edited this page Feb 4, 2016 · 2 revisions

Logger class reference

The Logger class lets you print information, warning, and other messages to the console output.

You can also replace Zetta logging with a custom logger such as bunyan or winston. See (TBD).

Methods

Logger.info(message, data)

Prints a standard blue log message to the console output.

Arguments

  • message - (string) A message to print to the console output.
  • data - (object) Relevant data associated with the log message.
server.info('Hello world', { 'hello': 'world' });

Logger.warn(message, data)

Prints a standard yellow log message to the console output.

Arguments

  • message - (string) A message to print to the console output.
  • data - (object) Relevant data associated with the log message.
server.warn('Hello world', { 'hello': 'world' });

Logger.error(message, data)

Prints a standard red log message to the console output.

Arguments

  • message - (string) A message to print to the console output.
  • data - (object) Relevant data associated with the log message.
server.error('Hello world', { 'hello': 'world' });

Logger.log(message, data)

Same as info(). Prints a standard blue log message to the console output.

Arguments

  • message - (string) A message to print to the console output.
  • data - (object) Relevant data associated with the log message.
server.log('Hello world', { 'hello': 'world' });

Using Logger

You can use Logger in devices, scouts, and apps. Below are examples on how to access logging from these different types of files.

Logging in device files

MyDevice.prototype.init = function(config) {
  this.info('some info message', { hello: 'world'});
};

Logging in app files

module.exports = function(server) {
  server.info('some info message', { hello: 'world'});
};

Logging in scout files

MyScout.prototype.init = function(next) {
  this.server.info('some info message', { hello: 'world'});
};
Clone this wiki locally