@xervo/logger
v2.0.0
Published
Winston wrapper with simplified interface
Downloads
2
Readme
Xervo logger
A Winston wrapper with a simplified interface and opinionated output.
Install
npm install @xervo/logger
Usage
The returned object is a winston logger instance, so all behavior is documented on that project. The addition of a namespace prefix mimics behavior of our other favorite logger: debug.
const Logger = require('@xervo/logger')('namespace')
Logger.info('message', { example: true })
// writes to process.stdout
// 2015-11-28T01:38:45.979Z INFO namespace message {"example":true}
Log level
The default log level is info
, but can be configured using the environment
variable LOG_LEVEL
.
LOG_LEVEL=debug npm start
Exceptions
All uncaught exceptions are automatically logged to stderr
and the process is
exited. There is no need to add an additional handler. If you would like to
enable the additional behavior of writing all exceptions to a file, you can!
Just set an environment variable EXCEPTION_LOG
to a writeable file.
EXCEPTION_LOG=/var/logs/myapp.exceptions.log npm start