@basaas/node-logger
v1.1.5
Published
A simple wrapper around winston logger
Downloads
56
Readme
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'