@basaas/node-logger

1.1.5 • Public • Published

README

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.info('hello');
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'

Readme

Keywords

none

Package Sidebar

Install

npm i @basaas/node-logger

Weekly Downloads

4

Version

1.1.5

License

MIT

Unpacked Size

3.72 kB

Total Files

5

Last publish

Collaborators

  • basaas-dev