pino-pretty
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -8,2 +8,3 @@ 'use strict' | ||
const jmespath = require('jmespath') | ||
const stringifySafe = require('fast-safe-stringify') | ||
@@ -228,3 +229,3 @@ const CONSTANTS = require('./lib/constants') | ||
if (errorLikeObjectKeys.indexOf(keys[i]) !== -1 && value[keys[i]] !== undefined) { | ||
const lines = JSON.stringify(value[keys[i]], null, 2) | ||
const lines = stringifySafe(value[keys[i]], null, 2) | ||
if (lines === undefined) continue | ||
@@ -259,3 +260,3 @@ const arrayOfLines = ( | ||
if (value[keys[i]] !== undefined) { | ||
const lines = JSON.stringify(value[keys[i]], null, 2) | ||
const lines = stringifySafe(value[keys[i]], null, 2) | ||
if (lines !== undefined) { | ||
@@ -262,0 +263,0 @@ result += IDENT + keys[i] + ': ' + joinLinesWithIndentation(lines) + EOL |
{ | ||
"name": "pino-pretty", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Prettifier for Pino log lines", | ||
@@ -37,2 +37,3 @@ "main": "index.js", | ||
"fast-json-parse": "^1.0.3", | ||
"fast-safe-stringify": "^2.0.6", | ||
"jmespath": "^0.15.0", | ||
@@ -39,0 +40,0 @@ "pump": "^3.0.0", |
@@ -488,2 +488,31 @@ 'use strict' | ||
t.test('prettifies msg object with circular references', (t) => { | ||
t.plan(7) | ||
const expectedLines = [ | ||
' msg: {', | ||
' "b": {', | ||
' "c": "d"', | ||
' },', | ||
' "a": "[Circular]"', | ||
' }' | ||
] | ||
const pretty = prettyFactory() | ||
const log = pino({}, new Writable({ | ||
write (chunk, enc, cb) { | ||
const formatted = pretty(chunk.toString()) | ||
const lines = formatted.split('\n') | ||
t.is(lines.length, expectedLines.length + 2) | ||
lines.shift(); lines.pop() | ||
for (var i = 0; i < lines.length; i += 1) { | ||
t.is(lines[i], expectedLines[i]) | ||
} | ||
cb() | ||
} | ||
})) | ||
const msg = { b: { c: 'd' } } | ||
msg.a = msg | ||
log.info({ msg }) | ||
}) | ||
t.test('prettifies object with some undefined values', (t) => { | ||
@@ -490,0 +519,0 @@ t.plan(1) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220569
1057
9
+ Addedfast-safe-stringify@^2.0.6
+ Addedfast-safe-stringify@2.1.1(transitive)