pino-pretty
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -238,9 +238,9 @@ 'use strict' | ||
if (/^\s*"stack"/.test(line)) { | ||
const matches = /^(\s*"stack":)\s*"(.*)",?$/.exec(line) | ||
const matches = /^(\s*"stack":)\s*(".*"),?$/.exec(line) | ||
if (matches && matches.length === 3) { | ||
const indentSize = /^\s*/.exec(line)[0].length + 4 | ||
const indentation = Array(indentSize + 1).join(' ') | ||
const indentation = ' '.repeat(indentSize) | ||
result += matches[1] + '\n' + indentation + matches[2].replace(/\\n/g, '\n' + indentation) | ||
result += matches[1] + '\n' + indentation + JSON.parse(matches[2]).replace(/\n/g, '\n' + indentation) | ||
} | ||
@@ -247,0 +247,0 @@ } else { |
{ | ||
"name": "pino-pretty", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Prettifier for Pino log lines", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -100,2 +100,32 @@ 'use strict' | ||
t.test('prettifies Error in property within errorLikeObjectKeys when stack has escaped characters', (t) => { | ||
t.plan(8) | ||
const pretty = prettyFactory({ | ||
errorLikeObjectKeys: ['err'] | ||
}) | ||
const err = Error('hello world') | ||
err.stack = 'Error: hello world\n at anonymous (C:\\project\\node_modules\\example\\index.js)' | ||
const expected = err.stack.split('\n') | ||
expected.unshift(err.message) | ||
const log = pino({ serializers: { err: serializers.err } }, new Writable({ | ||
write (chunk, enc, cb) { | ||
const formatted = pretty(chunk.toString()) | ||
const lines = formatted.split('\n') | ||
t.is(lines.length, expected.length + 6) | ||
t.is(lines[0], `[${epoch}] INFO (${pid} on ${hostname}): `) | ||
t.match(lines[1], /\s{4}err: {$/) | ||
t.match(lines[2], /\s{6}"type": "Error",$/) | ||
t.match(lines[3], /\s{6}"message": "hello world",$/) | ||
t.match(lines[4], /\s{6}"stack":$/) | ||
t.match(lines[5], /\s{10}Error: hello world$/) | ||
t.match(lines[6], /\s{10}at anonymous \(C:\\project\\node_modules\\example\\index.js\)$/) | ||
cb() | ||
} | ||
})) | ||
log.info({ err }) | ||
}) | ||
t.test('prettifies Error in property within errorLikeObjectKeys when stack is not the last property', (t) => { | ||
@@ -102,0 +132,0 @@ t.plan(9) |
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
218558
991