Socket
Socket
Sign inDemoInstall

pino-pretty

Package Overview
Dependencies
Maintainers
4
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-pretty - npm Package Compare versions

Comparing version 3.2.2 to 3.3.0

5

index.js

@@ -36,3 +36,4 @@ 'use strict'

useMetadata: false,
outputStream: process.stdout
outputStream: process.stdout,
customPrettifiers: {}
}

@@ -48,2 +49,3 @@

const errorProps = opts.errorProps.split(',')
const customPrettifiers = opts.customPrettifiers
const ignoreKeys = opts.ignore ? new Set(opts.ignore.split(',')) : undefined

@@ -141,2 +143,3 @@

skipKeys,
customPrettifiers,
errorLikeKeys: errorLikeObjectKeys,

@@ -143,0 +146,0 @@ eol: EOL,

4

lib/colors.js
'use strict'
/* eslint no-prototype-builtins: 0 */
const { LEVELS, LEVEL_NAMES } = require('./constants')

@@ -34,3 +32,3 @@

if (Number.isInteger(+level)) {
return LEVELS.hasOwnProperty(level)
return Object.prototype.hasOwnProperty.call(LEVELS, level)
? colorizer[level](LEVELS[level])

@@ -37,0 +35,0 @@ : colorizer.default(LEVELS.default)

@@ -252,2 +252,4 @@ 'use strict'

* prettified result. Default: `[]`.
* @param {Object<string, function>} [input.customPrettifiers] Dictionary of
* custom prettifiers. Default: `{}`.
* @param {string[]} [input.errorLikeKeys] A set of object keys that contain

@@ -266,2 +268,3 @@ * error objects. Default: `ERROR_LIKE_KEYS` constant.

skipKeys = [],
customPrettifiers = {},
errorLikeKeys = ERROR_LIKE_KEYS,

@@ -284,3 +287,9 @@ excludeLoggerKeys = true

const lines = stringifySafe(input[keyName], null, 2)
let lines
if (typeof customPrettifiers[keyName] === 'function') {
lines = customPrettifiers[keyName](keyValue, keyName, input)
} else {
lines = stringifySafe(keyValue, null, 2)
}
if (lines === undefined) continue

@@ -287,0 +296,0 @@ const joinedLines = joinLinesWithIndentation({ input: lines, ident, eol })

{
"name": "pino-pretty",
"version": "3.2.2",
"version": "3.3.0",
"description": "Prettifier for Pino log lines",

@@ -48,4 +48,4 @@ "main": "index.js",

"standard": "^14.0.0",
"tap": "^12.6.1"
"tap": "^14.9.1"
}
}

@@ -66,3 +66,3 @@ <a id="intro"></a>

- `--timestampKey` (`-m`): Define the key that contains the log timestamp.
Default: `time`.
Default: `time`.
- `--translateTime` (`-t`): Translate the epoch time value into a human readable

@@ -133,3 +133,4 @@ date and time string. This flag also can set the format string to apply when

search: 'foo == `bar`', // --search
ignore: 'pid,hostname' // --ignore
ignore: 'pid,hostname' // --ignore,
customPrettifiers: {}
}

@@ -141,2 +142,19 @@ ```

`customPrettifiers` option provides the ability to add a custom prettify function
for specific log properties. `customPrettifiers` is an object, where keys are
log properties which will be prettified and value is the prettify function itself.
For example, if a log line contains a `query` propert
you can specify a prettifier for it:
```js
{
customPrettifiers: {
query: prettifyQuery
}
}
//...
const prettifyQuery = value => {
// do some prettify magic
}
```
<a id="license"><a>

@@ -143,0 +161,0 @@ ## License

'use strict'
/* eslint no-prototype-builtins: 0 */
const { Writable } = require('readable-stream')

@@ -15,3 +13,3 @@ const os = require('os')

opts = { colorize: false }
} else if (!opts.hasOwnProperty('colorize')) {
} else if (!Object.prototype.hasOwnProperty.call(opts, 'colorize')) {
opts.colorize = false

@@ -541,2 +539,26 @@ }

t.test('prettifies custom key', (t) => {
t.plan(1)
const pretty = prettyFactory({
customPrettifiers: {
foo: val => `${val}_baz\nmultiline`,
cow: val => val.toUpperCase()
}
})
const arst = pretty('{"msg":"hello world", "foo": "bar", "cow": "moo", "level":30, "v":1}')
t.is(arst, 'INFO : hello world\n foo: bar_baz\n multiline\n cow: MOO\n')
})
t.test('does not prettify custom key that does not exists', (t) => {
t.plan(1)
const pretty = prettyFactory({
customPrettifiers: {
foo: val => `${val}_baz`,
cow: val => val.toUpperCase()
}
})
const arst = pretty('{"msg":"hello world", "foo": "bar", "level":30, "v":1}')
t.is(arst, 'INFO : hello world\n foo: bar_baz\n')
})
t.test('prettifies object with some undefined values', (t) => {

@@ -543,0 +565,0 @@ t.plan(1)

@@ -14,3 +14,4 @@ 'use strict'

t.plan(1)
const child = spawn(process.argv0, [bin])
const env = { TERM: 'dumb' }
const child = spawn(process.argv0, [bin], { env })
child.on('error', t.threw)

@@ -26,3 +27,4 @@ child.stdout.on('data', (data) => {

t.plan(1)
const child = spawn(process.argv0, [bin, '-l'])
const env = { TERM: 'dumb' }
const child = spawn(process.argv0, [bin, '-l'], { env })
child.on('error', t.threw)

@@ -38,3 +40,4 @@ child.stdout.on('data', (data) => {

t.plan(1)
const child = spawn(process.argv0, [bin, '-t'])
const env = { TERM: 'dumb' }
const child = spawn(process.argv0, [bin, '-t'], { env })
child.on('error', t.threw)

@@ -50,3 +53,4 @@ child.stdout.on('data', (data) => {

t.plan(1)
const child = spawn(process.argv0, [bin, '-s', 'msg == `hello world`'])
const env = { TERM: 'dumb' }
const child = spawn(process.argv0, [bin, '-s', 'msg == `hello world`'], { env })
child.on('error', t.threw)

@@ -62,3 +66,4 @@ child.stdout.on('data', (data) => {

t.plan(1)
const child = spawn(process.argv0, [bin, '-s', 'msg == `hello world`'])
const env = { TERM: 'dumb' }
const child = spawn(process.argv0, [bin, '-s', 'msg == `hello world`'], { env })
child.on('error', t.threw)

@@ -75,3 +80,4 @@ child.stdout.on('data', (data) => {

t.plan(1)
const child = spawn(process.argv0, [bin, '-i', 'pid,hostname'])
const env = { TERM: 'dumb' }
const child = spawn(process.argv0, [bin, '-i', 'pid,hostname'], { env })
child.on('error', t.threw)

@@ -87,3 +93,4 @@ child.stdout.on('data', (data) => {

t.plan(1)
const child = spawn(process.argv0, [bin])
const env = { TERM: 'dumb' }
const child = spawn(process.argv0, [bin], { env })
child.on('error', t.threw)

@@ -90,0 +97,0 @@

'use strict'
const test = require('tap').test
const prettyFactory = require('../')
const _prettyFactory = require('../')
function prettyFactory (opts) {
if (!opts) {
opts = { colorize: false }
} else if (!Object.prototype.hasOwnProperty.call(opts, 'colorize')) {
opts.colorize = false
}
return _prettyFactory(opts)
}
const logLine = '{"level":30,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo","v":1}\n'

@@ -7,0 +16,0 @@

@@ -8,4 +8,13 @@ 'use strict'

const serializers = pino.stdSerializers
const prettyFactory = require('../')
const _prettyFactory = require('../')
function prettyFactory (opts) {
if (!opts) {
opts = { colorize: false }
} else if (!Object.prototype.hasOwnProperty.call(opts, 'colorize')) {
opts.colorize = false
}
return _prettyFactory(opts)
}
// All dates are computed from 'Fri, 30 Mar 2018 17:35:28 GMT'

@@ -12,0 +21,0 @@ const epoch = 1522431328992

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc