console-logfmt
v3.0.2
Published
console.log/warn/error interface for logfmt
Downloads
3
Readme
console-logfmt
Wrap around logfmt exposing a interface compatible with console.log()
, console.warn()
and console.error()
.
Instalation
npm install console-logfmt
Usage
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
Important to notice
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.
License
console-logfmt is released under the MIT License.