Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
/ console-logfmt Public archive

console.log/warn/error interface for logfmt

License

Notifications You must be signed in to change notification settings

gumieri/console-logfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

console.log/warn/error interface for logfmt

Resources

License

Stars

Watchers

Forks

Packages

No packages published