A simple wrapper around winston logger


1.1.53 years ago5 years agoMinified + gzip package size for @basaas/node-logger in KB



This is a utility library, which uses internally winston logger (s. https://www.npmjs.com/package/winston)

How do I get set up?

const Logger = require('@basaas/node-logger');

const myLogger = Logger.getLogger('my-logger', {
    level: 'info'   // defaults to 'warn' in production and otherwise 'info'

myLogger.warn({foo: 42});
myLogger.error(new Error('oh noes!'));

Logging multiple arguments

If you pass more than one argument to the logger function, then the arguments will be concatenated to a single string whilst the last arguments will be interpreted as metadata.

myLogger.info('hello', {foo: 42});

will be logged as:

{"foo":42,"level":"info","message":"[blubb] hello"}

Environment Variables

  • NODE_ENV - logs in json format if production, otherwise uses the default from 'winston'
  • DEBUG - if true then sets the default log level to 'debug'

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.