pino-pretty
Prettifier for Pino log lines
Last updated 8 years ago by jsumners .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install pino-pretty 
SYNC missed versions from official npm registry.

pino-pretty

Build Status Coverage Status

This module provides a basic log prettifier for the Pino logging library. It reads a standard Pino log line like:

{"level":30,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo","v":1}

And formats it to:

[1522431328992] INFO (42 on foo): hello world

Example

Using the example script from the Pino module, and specifying that logs should be colored and the time translated, we can see what the prettified logs will look like:

demo

Install

$ npm install -g pino-pretty

Usage

It's recommended to use pino-pretty with pino by piping output to the CLI tool:

pino app.js | pino-pretty

CLI Arguments

  • --colorize (-c): Adds terminal color escape sequences to the output.
  • --crlf (-f): Appends carriage return and line feed, instead of just a line feed, to the formatted log line.
  • --errorProps (-e): When formatting an error object, display this list of properties. The list should be a comma separated list of properties Default: ''.
  • --levelFirst (-l): Display the log level name before the logged date and time.
  • --errorLikeObjectKeys (-k): Define the log keys that are associated with error like objects. Default: err,error.
  • --messageKey (-m): Define the key that contains the main log message. Default: msg.
  • --translateTime (-t): Translate the epoch time value into a human readable date and time string. This flag also can set the format string to apply when translating the date to human readable format. For a list of available pattern letters see the dateformat documentation.
    • The default format is yyyy-mm-dd HH:MM:ss.l o in UTC.
    • Require a SYS: prefix to translate time to the local system's timezone. A shortcut SYS:standard to translate time to yyyy-mm-dd HH:MM:ss.l o in system timezone.
  • --search (-s): Specify a search pattern according to jmespath.
  • --ignore (-i): Ignore one or several keys: (-i time,hostname)

Programmatic Integration

We recommend against using pino-pretty in production, and highly recommend installing pino-pretty as a development dependency.

When installed, pino-pretty will be used by pino as the default prettifier.

Install pino-pretty alongside pino and set the prettyPrint option to true:

const pino = require('pino')
const logger = pino({
  prettyPrint: true
})

logger.info('hi')

The prettyPrint option can also be an object containing pretty-print options:

const pino = require('pino')
const logger = pino({
  prettyPrint: { colorize: true }
})

logger.info('hi')

See the Options section for all possible options.

Options

pino-pretty exports a factory function that can be used to format log strings. This factory function is used internally by pino, and accepts an options argument with keys corresponding to the options described in CLI Arguments:

{
  colorize: chalk.supportsColor, // --colorize
  crlf: false, // --crlf
  errorLikeObjectKeys: ['err', 'error'], // --errorLikeObjectKeys
  errorProps: '', // --errorProps
  levelFirst: false, // --levelFirst
  messageKey: 'msg', // --messageKey
  translateTime: false, // --translateTime
  search: 'foo == `bar`', // --search
  ignore: 'pid,hostname' // --ignore
}

The colorize default follows `chalk.supportsColor.

License

MIT License

Current Tags

  • 13.2.0                                ...           latest (2 months ago)
  • 3.0.0-rc.2                                ...           next (8 years ago)

97 Versions

  • 13.2.0                                ...           2 months ago
  • 13.1.3                                ...           a year ago
  • 13.1.2                                ...           a year ago
  • 13.1.1                                ...           a year ago
  • 13.1.0                                ...           a year ago
  • 11.3.0                                ...           2 years ago
  • 13.0.0                                ...           2 years ago
  • 12.1.0                                ...           2 years ago
  • 12.0.0                                ...           2 years ago
  • 11.2.2                                ...           2 years ago
  • 11.2.1                                ...           2 years ago
  • 11.2.0                                ...           2 years ago
  • 11.1.0                                ...           3 years ago
  • 11.0.0                                ...           3 years ago
  • 10.3.1                                ...           3 years ago
  • 10.3.0                                ...           3 years ago
  • 10.2.3                                ...           3 years ago
  • 10.2.2                                ...           3 years ago
  • 10.2.1                                ...           3 years ago
  • 10.2.0                                ...           3 years ago
  • 10.1.0                                ...           3 years ago
  • 10.0.1                                ...           3 years ago
  • 9.4.1                                ...           3 years ago
  • 10.0.0                                ...           4 years ago
  • 9.4.0                                ...           4 years ago
  • 9.3.0                                ...           4 years ago
  • 9.2.0                                ...           4 years ago
  • 9.1.1                                ...           4 years ago
  • 9.1.0                                ...           4 years ago
  • 9.0.1                                ...           4 years ago
  • 9.0.0                                ...           4 years ago
  • 8.1.0                                ...           4 years ago
  • 8.0.0                                ...           4 years ago
  • 7.6.1                                ...           5 years ago
  • 7.6.0                                ...           5 years ago
  • 7.5.4                                ...           5 years ago
  • 7.5.3                                ...           5 years ago
  • 7.5.2                                ...           5 years ago
  • 7.5.1                                ...           5 years ago
  • 7.5.0                                ...           5 years ago
  • 7.4.0                                ...           5 years ago
  • 7.3.0                                ...           5 years ago
  • 7.2.0                                ...           5 years ago
  • 7.1.0                                ...           5 years ago
  • 7.0.1                                ...           5 years ago
  • 7.0.0                                ...           5 years ago
  • 6.0.0                                ...           5 years ago
  • 5.1.3                                ...           5 years ago
  • 5.1.2                                ...           5 years ago
  • 5.1.1                                ...           5 years ago
  • 5.1.0                                ...           5 years ago
  • 5.0.2                                ...           5 years ago
  • 5.0.1                                ...           6 years ago
  • 5.0.0                                ...           6 years ago
  • 4.8.0                                ...           6 years ago
  • 4.7.1                                ...           6 years ago
  • 4.7.0                                ...           6 years ago
  • 4.6.0                                ...           6 years ago
  • 4.5.0                                ...           6 years ago
  • 4.4.0                                ...           6 years ago
  • 4.3.0                                ...           6 years ago
  • 4.2.1                                ...           6 years ago
  • 4.2.0                                ...           6 years ago
  • 4.1.0                                ...           6 years ago
  • 4.0.3                                ...           6 years ago
  • 4.0.2                                ...           6 years ago
  • 4.0.1                                ...           6 years ago
  • 4.0.0                                ...           7 years ago
  • 3.6.1                                ...           7 years ago
  • 3.6.0                                ...           7 years ago
  • 3.5.0                                ...           7 years ago
  • 3.4.0                                ...           7 years ago
  • 3.3.0                                ...           7 years ago
  • 3.2.2                                ...           7 years ago
  • 3.2.1                                ...           7 years ago
  • 3.2.0                                ...           7 years ago
  • 3.1.0                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.6.1                                ...           8 years ago
  • 3.0.0-rc.2                                ...           8 years ago
  • 3.0.0-rc.1                                ...           8 years ago
  • 2.6.0                                ...           8 years ago
  • 2.5.0                                ...           8 years ago
  • 2.4.0                                ...           8 years ago
  • 2.3.0                                ...           8 years ago
  • 2.2.4                                ...           8 years ago
  • 2.2.3                                ...           8 years ago
  • 2.2.2                                ...           8 years ago
  • 2.2.1                                ...           8 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 2.0.0-rc.1                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Downloads
Total 242
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 222
Dependencies (9)
Dev Dependencies (5)

© 2010 - cnpmjs.org x YWFE | Home | YWFE