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.
npm install @cto.af/log
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);