{"name":"pino-pretty","version":"3.2.2","keywords":["pino"],"author":{"name":"James Sumners","email":"james.sumners@gmail.com"},"license":"MIT","_id":"pino-pretty@3.2.2","maintainers":[{"name":"davidmarkclements","email":"huperekchuno@googlemail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"watson","email":"w@tson.dk"}],"homepage":"https://github.com/pinojs/pino-pretty#readme","bugs":{"url":"https://github.com/pinojs/pino-pretty/issues"},"bin":{"pino-pretty":"./bin.js"},"dist":{"shasum":"e252f964f99a0a3bd34f4a484bb4e202632eaaad","tarball":"http://registry-npm.ywwl.com/pino-pretty/download/pino-pretty-3.2.2.tgz","fileCount":18,"integrity":"sha512-2SP++Wbo4EsH5RpLhcsYHOR/8CMTIJWZpU0aPiVK0Wq8SrRMQ9oHQNffVK5ZyDFZMtSuTdFCVfLVNFmtFMDEeA==","signatures":[{"sig":"MEUCIGWhwrESYKiVeCK0aRcDI6jSWFydh3Uw0lUGUMx6F101AiEAx/i7utkdpzCzql8nEIDuMldEj61nWO4PTiwud8E8QtQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":247595,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdnJYECRA9TVsSAnZWagAAy8cQAI3xQbgPl/ONJXbknyyN\nWQtFyu+UK53By6eIL04WbQwRWYvS6oVcH+cjVsYRxamhAL2Q8OHq0w6MXlP9\nOgunosuldqBq4jGvwaP0U4DOmphJDvqobSGUZcxw77ZkWkLA1qylTXeHfoPo\nWWBM8g3nQtuKtyoYZz5k1OEL3gZY/H7V3cqsSr3e3jWp9d5iuA+QcKWV8fb+\nSGOdLMA3GO5u/gVK/icF5nx48r8Ai/Ki8zjqrb/a0aqMnvY1EnDcev4FQPPJ\nxFyUa4YI6JINE+/J6webm4nBJceGug+UG0X62JEB9AEu/Gt5JoG4aUDfvgmq\n0NoZgtYJv1pdcJrR98OBGiWqqcL/3h4S3FDmhKiu7mWI/mpPT3M0gGj0h4bF\ngXL/7SO/m1aT9W5V4oPZ2hS5erGOP9WtDNOJZFQmIWvoteKkzyrIVVY+Xr+a\nhr5nrnvV+8iL6uohP6y1ar1boPq5PbDxqMSbKuQFpbIQbpCMAyJCLu/y9S0e\nXKAeabYhYbNwvTz/xWSvWOFZKFUuYli1pMXbkpzcIo809LZu4Sn5OoF0jHAC\ngdZjHX82GwNUZ8ln9AwpNi+oNwUhx9Etuwf/cyFAwA/nYFnRdPvUqS+f95Uk\n+tbc1Jn+gyOXjIb2QwIFDrMLVfdnhtON5eFcHhy3P+0KmreRn3vX/oj9E1li\nkE9Q\r\n=0qSH\r\n-----END PGP SIGNATURE-----\r\n","size":185119,"noattachment":false,"key":"/pino-pretty/-/pino-pretty-3.2.2.tgz"},"main":"index.js","gitHead":"6abbb325b2e0238e48354d0f1205c2bc5a9eb0c8","scripts":{"lint":"standard | snazzy","test":"tap --no-cov 'test/**/*.test.js'","lint-ci":"standard","test-ci":"tap --cov 'test/**/*.test.js'"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"precommit":["lint","test"],"repository":{"url":"git+ssh://git@github.com/pinojs/pino-pretty.git","type":"git"},"_npmVersion":"6.11.3","description":"Prettifier for Pino log lines","directories":{},"_nodeVersion":"10.16.3","dependencies":{"args":"^5.0.1","pump":"^3.0.0","chalk":"^2.4.2","split2":"^3.1.1","jmespath":"^0.15.0","dateformat":"^3.0.3","@hapi/bourne":"^1.3.2","readable-stream":"^3.4.0","fast-safe-stringify":"^2.0.7"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^12.6.1","pino":"^5.13.4","snazzy":"^8.0.0","standard":"^14.0.0","pre-commit":"^1.2.2"},"_npmOperationalInternal":{"tmp":"tmp/pino-pretty_3.2.2_1570543107504_0.5259423276990731","host":"s3://npm-registry-packages"},"readme":"<a id=\"intro\"></a>\n# pino-pretty\n\n[![NPM Package Version](https://img.shields.io/npm/v/pino-pretty)](https://www.npmjs.com/package/pino-pretty)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/pinojs/pino-pretty/ci.yml?branch=master)](https://github.com/pinojs/pino-pretty/actions?query=workflow%3ACI)\n[![Coverage Status](https://img.shields.io/coveralls/github/pinojs/pino-pretty)](https://coveralls.io/github/pinojs/pino-pretty?branch=master)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n\nThis module provides a basic [ndjson](http://ndjson.org/) formatter to be used in __development__. If an\nincoming line looks like it could be a log line from an ndjson logger, in\nparticular the [Pino](https://getpino.io/) logging library, then it will apply\nextra formatting by considering things like the log level and timestamp.\n\nA standard Pino log line like:\n\n```\n{\"level\":30,\"time\":1522431328992,\"msg\":\"hello world\",\"pid\":42,\"hostname\":\"foo\",\"v\":1}\n```\n\nWill format to:\n\n```\n[17:35:28.992] INFO (42): hello world\n```\n\nIf you landed on this page due to the deprecation of the `prettyPrint` option\nof `pino`, read the [Programmatic Integration](#integration) section.\n\n<a id=\"example\"></a>\n## Example\n\nUsing the [example script][exscript] from the Pino module, we can see what the\nprettified logs will look like:\n\n![demo](demo.png)\n\n[exscript]: https://github.com/pinojs/pino/blob/25ba61f40ea5a1a753c85002812426d765da52a4/examples/basic.js\n\n<a id=\"install\"></a>\n## Install\n\n```sh\n$ npm install -g pino-pretty\n```\n\n<a id=\"usage\"></a>\n## Usage\n\nIt is recommended to use `pino-pretty` with `pino`\nby piping output to the CLI tool:\n\n```sh\nnode app.js | pino-pretty\n```\n\n<a id=\"cliargs\"></a>\n### CLI Arguments\n\n- `--colorize` (`-c`): Adds terminal color escape sequences to the output.\n- `--colorizeObjects` (`-C`): Allows suppressing colorization of objects when set to `false`. In combination with `--singleLine`, this ensures that the end of each line is parsable JSON.\n- `--crlf` (`-f`): Appends carriage return and line feed, instead of just a line\n  feed, to the formatted log line.\n- `--errorProps` (`-e`): When formatting an error object, display this list\n  of properties. The list should be a comma-separated list of properties Default: `''`.\n  Do not use this option if logging from pino@7. Support will be removed from future verions.\n- `--levelFirst` (`-l`): Display the log level name before the logged date and time.\n- `--errorLikeObjectKeys` (`-k`): Define the log keys that are associated with\n  error like objects. Default: `err,error`.\n- `--messageKey` (`-m`): Define the key that contains the main log message.\n  Default: `msg`.\n- `--levelKey` (`--levelKey`): Define the key that contains the level of the log. Nested keys are supported with each property delimited by a dot character (`.`).\n  Keys may be escaped to target property names that contains the delimiter itself:\n  (`--levelKey tags\\\\.level`).\n  Default: `level`.\n- `--levelLabel` (`-b`): Output the log level using the specified label.\n  Default: `levelLabel`.\n- `--minimumLevel` (`-L`): Hide messages below the specified log level. Accepts a number, `trace`, `debug`, `info`, `warn`, `error`, or `fatal`. If any more filtering is required, consider using [`jq`](https://stedolan.github.io/jq/).\n- `--customLevels` (`-x`): Override default levels with custom levels, e.g. `-x err:99,info:1`\n- `--customColors` (`-X`): Override default colors with custom colors, e.g. `-X err:red,info:blue`\n- `--useOnlyCustomProps` (`-U`): Only use custom levels and colors (if provided) (default: true); else fallback to default levels and colors, e.g. `-U false`\n- `--messageFormat` (`-o`): Format output of message, e.g. `{levelLabel} - {pid} - url:{req.url}` will output message: `INFO - 1123 - url:localhost:3000/test`\n  Default: `false`\n- `--timestampKey` (`-a`): Define the key that contains the log timestamp.\n  Default: `time`.\n- `--translateTime` (`-t`): Translate the epoch time value into a human-readable\n  date and time string. This flag also can set the format string to apply when\n  translating the date to a human-readable format. For a list of available pattern\n  letters, see the [`dateformat` documentation](https://www.npmjs.com/package/dateformat).\n  - The default format is `HH:MM:ss.l` in the local timezone.\n  - Require a `UTC:` prefix to translate time to UTC, e.g. `UTC:yyyy-mm-dd HH:MM:ss.l o`.\n  - Require a `SYS:` prefix to translate time to the local system's time zone. A\n    shortcut `SYS:standard` to translate time to `yyyy-mm-dd HH:MM:ss.l o` in\n    system time zone.\n- `--ignore` (`-i`): Ignore one or several keys, nested keys are supported with each property delimited by a dot character (`.`),\n  keys may be escaped to target property names that contains the delimiter itself:\n  (`-i time,hostname,req.headers,log\\\\.domain\\\\.corp/foo`).\n  The `--ignore` option would be ignored, if both `--ignore` and `--include` are passed.\n  Default: `hostname`.\n- `--include` (`-I`): The opposite of `--ignore`. Include one or several keys.\n- `--hideObject` (`-H`): Hide objects from output (but not error object)\n- `--singleLine` (`-S`): Print each log message on a single line (errors will still be multi-line)\n- `--config`: Specify a path to a config file containing the pino-pretty options.  pino-pretty will attempt to read from a `.pino-prettyrc` in your current directory (`process.cwd`) if not specified\n\n<a id=\"integration\"></a>\n## Programmatic Integration\n\nWe recommend against using `pino-pretty` in production and highly\nrecommend installing `pino-pretty` as a development dependency.\n\nInstall `pino-pretty` alongside `pino` and set the transport target to `'pino-pretty'`:\n\n```js\nconst pino = require('pino')\nconst logger = pino({\n  transport: {\n    target: 'pino-pretty'\n  },\n})\n\nlogger.info('hi')\n```\n\nThe transport option can also have an options object containing `pino-pretty` options:\n\n```js\nconst pino = require('pino')\nconst logger = pino({\n  transport: {\n    target: 'pino-pretty',\n    options: {\n      colorize: true\n    }\n  }\n})\n\nlogger.info('hi')\n```\n\nUse it as a stream:\n\n```js\nconst pino = require('pino')\nconst pretty = require('pino-pretty')\nconst logger = pino(pretty())\n\nlogger.info('hi')\n```\n\nOptions are also supported:\n\n```js\nconst pino = require('pino')\nconst pretty = require('pino-pretty')\nconst stream = pretty({\n  colorize: true\n})\nconst logger = pino(stream)\n\nlogger.info('hi')\n```\n\nSee the [Options](#options) section for all possible options.\n\n\n### Usage as a stream\n\nIf you are using `pino-pretty` as a stream and you need to provide options to `pino`,\npass the options as the first argument and `pino-pretty` as second argument:\n\n```js\nconst pino = require('pino')\nconst pretty = require('pino-pretty')\nconst stream = pretty({\n  colorize: true\n})\nconst logger = pino({ level: 'info' }, stream)\n\n// Nothing is printed\nlogger.debug('hi')\n```\n\n### Usage with Jest\n\nLogging with Jest is _problematic_, as the test framework requires no asynchronous operation to\ncontinue after the test has finished. The following is the only supported way to use this module\nwith Jest:\n\n```js\nimport pino from 'pino'\nimport pretty from 'pino-pretty'\n\ntest('test pino-pretty', () => {\n  const logger = pino(pretty({ sync: true }));\n  logger.info('Info');\n  logger.error('Error');\n});\n```\n\n### Handling non-serializable options\n\nUsing the new [pino v7+\ntransports](https://getpino.io/#/docs/transports?id=v7-transports) not all\noptions are serializable, for example if you want to use `messageFormat` as a\nfunction you will need to wrap `pino-pretty` in a custom module.\n\nExecuting `main.js` below will log a colorized `hello world` message using a\ncustom function `messageFormat`:\n\n```js\n// main.js\nconst pino = require('pino')\n\nconst logger = pino({\n  transport: {\n    target: './pino-pretty-transport',\n    options: {\n      colorize: true\n    }\n  },\n})\n\nlogger.info('world')\n```\n\n```js\n// pino-pretty-transport.js\nmodule.exports = opts => require('pino-pretty')({\n  ...opts,\n  messageFormat: (log, messageKey) => `hello ${log[messageKey]}`\n})\n```\n\n### Checking color support in TTY\n\nThis boolean returns whether the currently used TTY supports colorizing the logs.\n\n```js\nimport pretty from 'pino-pretty'\n\nif (pretty.isColorSupported) {\n  ...\n}\n\n```\n\n<a id=\"options\"></a>\n### Options\n\nThe options accepted have keys corresponding to the options described in [CLI Arguments](#cliargs):\n\n```js\n{\n  colorize: colorette.isColorSupported, // --colorize\n  colorizeObjects: true, //--colorizeObjects\n  crlf: false, // --crlf\n  errorLikeObjectKeys: ['err', 'error'], // --errorLikeObjectKeys (not required to match custom errorKey with pino >=8.21.0)\n  errorProps: '', // --errorProps\n  levelFirst: false, // --levelFirst\n  messageKey: 'msg', // --messageKey (not required with pino >=8.21.0)\n  levelKey: 'level', // --levelKey\n  messageFormat: false, // --messageFormat\n  timestampKey: 'time', // --timestampKey\n  translateTime: false, // --translateTime\n  ignore: 'pid,hostname', // --ignore\n  include: 'level,time', // --include\n  hideObject: false, // --hideObject\n  singleLine: false, // --singleLine\n  customColors: 'err:red,info:blue', // --customColors\n  customLevels: 'err:99,info:1', // --customLevels (not required with pino >=8.21.0)\n  levelLabel: 'levelLabel', // --levelLabel\n  minimumLevel: 'info', // --minimumLevel\n  useOnlyCustomProps: true, // --useOnlyCustomProps\n  // The file or file descriptor (1 is stdout) to write to\n  destination: 1,\n\n  // Alternatively, pass a `sonic-boom` instance (allowing more flexibility):\n  // destination: new SonicBoom({ dest: 'a/file', mkdir: true })\n\n  // You can also configure some SonicBoom options directly\n  sync: false, // by default we write asynchronously\n  append: true, // the file is opened with the 'a' flag\n  mkdir: true, // create the target destination\n\n\n  customPrettifiers: {}\n}\n```\n\nThe `colorize` default follows\n[`colorette.isColorSupported`](https://github.com/jorgebucaran/colorette#iscolorsupported).\n\nThe defaults for `sync`, `append`, `mkdir` inherit from\n[`SonicBoom(opts)`](https://github.com/pinojs/sonic-boom#API).\n\n`customPrettifiers` option provides the ability to add a custom prettify function\nfor specific log properties. `customPrettifiers` is an object, where keys are\nlog properties that will be prettified and value is the prettify function itself.\nFor example, if a log line contains a `query` property,\nyou can specify a prettifier for it:\n\n```js\n{\n  customPrettifiers: {\n    query: prettifyQuery\n  }\n}\n//...\nconst prettifyQuery = value => {\n  // do some prettify magic\n}\n```\n\nAll prettifiers use this function signature:\n\n```js\n['logObjKey']: (output, keyName, logObj, extras) => string\n```\n\n* `logObjKey` - name of the key of the property in the log object that should have this function applied to it\n* `output` - the value of the property in the log object\n* `keyName` - the name of the property (useful for `level` and `message` when `levelKey` or `messageKey` is used)\n* `logObj` - the full log object, for context\n* `extras` - an object containing **additional** data/functions created in the context of this pino-pretty logger or specific to the key (see `level` prettifying below)\n  * All `extras` objects contain `colors` which is a [Colorette](https://github.com/jorgebucaran/colorette?tab=readme-ov-file#supported-colors) object containing color functions. Colors are enabled based on `colorize` provided to pino-pretty or `colorette.isColorSupported` if `colorize` was not provided.\n\nAdditionally, `customPrettifiers` can be used to format the `time`, `hostname`,\n`pid`, `name`, `caller` and `level` outputs AS WELL AS any arbitrary key-value that exists on a given log object.\n\nAn example usage of `customPrettifiers` using all parameters from the function signature:\n\n```js\n{\n  customPrettifiers: {\n    // The argument for this function will be the same\n    // string that's at the start of the log-line by default:\n    time: timestamp => `🕰 ${timestamp}`,\n\n    // The argument for the level-prettifier may vary depending\n    // on if the levelKey option is used or not.\n    // By default this will be the same numerics as the Pino default:\n    level: logLevel => `LEVEL: ${logLevel}`,\n    // level provides additional data in `extras`:\n    // * label => derived level label string\n    // * labelColorized => derived level label string with colorette colors applied based on customColors and whether colors are supported\n    level: (logLevel, key, log, { label, labelColorized, colors }) => `LEVEL: ${logLevel} LABEL: ${levelLabel} COLORIZED LABEL: ${labelColorized}`,\n\n    // other prettifiers can be used for the other keys if needed, for example\n    hostname: hostname => `MY HOST: ${hostname}`,\n    pid: pid => pid,\n    name: (name, key, log, { colors }) => `${colors.blue(name)}`,\n    caller: (caller, key, log, { colors }) => `${colors.greenBright(caller)}`,\n    myCustomLogProp: (value, key, log, { colors }) => `My Prop -> ${colors.bold(value)} <--`\n  }\n}\n```\n\n`messageFormat` option allows you to customize the message output.\nA template `string` like this can define the format:\n\n```js\n{\n  messageFormat: '{levelLabel} - {pid} - url:{req.url}'\n}\n```\n\nIn addition to this, if / end statement blocks can also be specified.\nElse statements and nested conditions are not supported.\n\n```js\n{\n  messageFormat: '{levelLabel} - {if pid}{pid} - {end}url:{req.url}'\n}\n```\n\nThis option can also be defined as a `function` with this function signature:\n\n```js\n{\n  messageFormat: (log, messageKey, levelLabel, { colors }) => {\n    // do some log message customization\n    //\n    // `colors` is a Colorette object with colors enabled based on `colorize` option\n    return `This is a ${color.red('colorized')}, custom message: ${log[messageKey]}`;\n  }\n}\n```\n\n## Limitations\n\nBecause `pino-pretty` uses stdout redirection, in some cases the command may\nterminate with an error due to shell limitations.\n\nFor example, currently, mingw64 based shells (e.g. Bash as supplied by [git for\nWindows](https://gitforwindows.org)) are affected and terminate the process with\na `stdout is not a tty` error message.\n\nAny PRs are welcomed!\n\n<a id=\"license\"></a>\n## License\n\nMIT License\n","publish_time":1570543107630,"_cnpm_publish_time":1570543107630,"dist-tags":{"latest":"13.2.0","next":"3.0.0-rc.2"}}