namshi/lib-logger

Name: lib-logger

Owner: Namshi

Description: null

Created: 2018-04-03 11:13:31.0

Updated: 2018-05-09 11:19:26.0

Pushed: 2018-05-10 04:48:16.0

Homepage: null

Size: 15

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Lib-logger

Library that simplifies the way we log. It eases migration from native console.log to other log libraries. Current release wrapped winston logger but more loggers can be supported later.

Features
Usage

Install it through: npm i lib-logger

const log = require('lib-logger');

log.debug("This is a debug message!");
log.info("This is an info message");

Migration From console.log to lib-logger

To ease migrating from console.log to lib-logger, the library supports receiving a number of arguments (should be limited) that are not wrapped in a json object. The library will parse and format it as follows:

example: log.error('Shipment Number', 1234, “could not be created”, new Error('Error while bla bla'), { name: 'Test Name', locale: 'en', country: 'ae'}); Output:

message: 'Shipment Number, 1234, could not be created, Error: Error while bla bla' it's
context object: {
    stack: "Error while bla bla @FileName ..... stacktrace',
    statusCode: 500, // default value if no code provided in the error object
    name: 'Test Name',
    locale: 'en',
    country: 'ae',
}

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.