Skip to content

hildjj/log

 
 

Repository files navigation

@cto.af/log

A thin wrapper around Pino to insulate multiple projects from the dependency, and to normalize a common pattern in those projects.

In particular:

  • Singleton log object.
  • Write pretty output to stdout, JSON to a file, both, or neither.

Installation

npm install @cto.af/log

API

Full API documentation is available. Options are the Pino options plus:

  • logLevel: Suitable for -v and -q CLI arguments:
    • -3: fatal
    • -2: error
    • -1: warn
    • 0: info
    • 1: debug
    • 2: trace.
  • logFile: Write to this file, creating the directory if needed.
  • mute: Disable stdout logging if true.
  • prettyIgnore: Ignore these comma-separated fields in the stdout. Default: 'pid,hostname,name,host,port'

Example:

const log = getLog();
log.info('foo');
log.warn({clientId: 17}, 'Client %d did things', 17);

Build Status codecov

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 52.1%
  • TypeScript 47.9%