1.1.3 • Published 5 years ago

wes-logger-nodejs v1.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

#wes-logger-nodejs

A logging package to log nodejs applications for Wabtec eservices

##Description

wes-logger-nodejs can be used for all applications that uses a nodejs middleware. It has been developed to provide datadog compatible logging syntax which is difficult to achieve using normal console logs.

wes-logger-nodejs leverages the power of winston to add more meaning to the logs and also provides a timestamp which can tracked in the datadog logs.

##Usage

const logger = require('wes-logger-nodejs');

logger.log('info', 'Hello world');

// Logging a variable for debugging purpose
const message = 'eServices';
logger.log('debug', `Hello ${message}`);

// Logging an object
const obj = {
    message: 'Hello World'
};
logger.log('debug', JSON.stringify(obj));

##Logging Levels

Since wes-logger-nodejs is a wrapper around winston, we can diversify the way we log messages by setting log levels based on severity.

const levels = { 
  error: 0,
  warn: 1,
  info: 2,
  http: 3,
  verbose: 4,
  debug: 5,
  silly: 6
};

// Examples

logger.log('info', 'Hello World');
logger.log('debug', 'This is a string returned from server');
logger.log('error', 'Something went wrong');
1.1.3

5 years ago

1.1.2

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago