Wrap around logfmt exposing a interface compatible with console.log()
, console.warn()
and console.error()
.
npm install console-logfmt
The level is defined as:
log()
⇒'info'
warn()
⇒'warn'
error()
⇒'error'
Any string parameter will be concatenated to the msg=
key:
const ConsoleLogFmt = require('console-logfmt')
const { log, warn, error } = new ConsoleLogFmt()
log('message')
// output:
// level=info msg=message
log('message', 'of something')
// output:
// level=info msg="message of something"
Any object parameter wil be passed to the logfmt as it is:
warn('message of warning', { extra: 'data' })
// output
// level=warn msg="message of warning" extra=data
error({ other: 'message of error', extra: 'data' })
// output
// level=error other="message of error" extra=data
The default output for any log level is the process.stderr
, if you need something different, the console parameters still valid to be informed/replaced.
console-logfmt is released under the MIT License.