$ npm install pino-pretty
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
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:
$ npm install -g pino-pretty
--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 in UTC. The default pattern is 'yyyy-mm-dd HH:MM:ss.l o'.
If you want to translate to the local system's timezone, then you must prefix the format
string with SYS:, e.g. 'SYS:yyyy-mm-dd HH:MM:ss'. See dateformat documentation
for more available pattern letters.--search (-s): Specifiy a search pattern according to
jmespath.pino-pretty exports a factory function that can be used to format log strings.
It accepts an options argument with keys corresponding to the options described
in CLI Arguments:
{
colorize: false, // --colorize
crlf: false, // --crlf
errorLikeObjectKeys: ['err', 'error'], // --errorLikeObjectKeys
errorProps: '', // --errorProps
levelFirst: false, // --levelFirst
messageKey: 'msg', // --messageKey
translateTime: false, // --translateTime
search: 'foo == `bar`' // --search
}
See the Pino's prettifier documentation for information on how
to use this directly with pino.
MIT License
© 2010 - cnpmjs.org x YWFE | Home | YWFE