3.0.2 • Published 6 years ago
console-logfmt v3.0.2
console-logfmt
Wrap around logfmt exposing a interface compatible with console.log(), console.warn() and console.error().
Instalation
npm install console-logfmtUsage
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=dataerror({ other: 'message of error', extra: 'data' })
// output
// level=error other="message of error" extra=dataImportant 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.