test('sync false logs everything when calling flushSync', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'syncfalse-flush-exit.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(actual.match(/hello/), null) isNot(actual.match(/world/), null) })
test('do not use SonicBoom is someone tampered with process.stdout.write', async ({ isNot }) => { var actual = '' const child = fork(join(__dirname, 'fixtures', 'stdout-hack-protection.js'), { silent: true }) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(actual.match(/^hack/), null) })
test('errors with props', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'error-props.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): kaboom/), null) isNot(strip(actual).match(/code: ENOENT/), null) isNot(strip(actual).match(/errno: 1/), null) isNot(strip(actual).match(/.*error-props\.js.*/), null) })
test('without timestamp', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'no-time.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).slice(2), '[]') })
test('applies redaction rules', async ({ is, isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'redact.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null) isNot(strip(actual).match(/\[Redacted\]/), null) is(strip(actual).match(/object/), null) })
test('final works without prior logging', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'final-no-log-before.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/WARN\s+: pino.final with prettyPrint does not support flushing/), null) isNot(strip(actual).match(/INFO\s+\(123456 on abcdefghijklmnopqr\): beforeExit/), null) })
test('can be enabled via exported pino function with pretty configuration', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'level-first.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/^INFO.*h/), null) })
test('applies updated chindings', async ({ is, isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'child-with-updated-chindings.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/foo: 123/), null) isNot(strip(actual).match(/foo: 456/), null) isNot(strip(actual).match(/bar: 789/), null) })
// https://github.com/pinojs/pino/issues/542 test('pino.destination log everything when calling process.exit(0)', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'destination-exit.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(actual.match(/hello/), null) isNot(actual.match(/world/), null) })
test('applies serializers', async ({ is, isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'serializers.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null) isNot(strip(actual).match(/foo: "bar"/), null) })
test('can be enabled via exported pino function', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'basic.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null) })
test('dateformat', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'dateformat.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null) })
test('works as expected with an object with the msg prop', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'obj-msg-prop.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): hello/), null) })
test('pino with no args log everything when calling process.exit(0)', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'default-exit.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(actual.match(/hello/), null) isNot(actual.match(/world/), null) })
test('can be enabled via exported pino function with prettifier', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'pretty-factory.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/^INFO.*h/), null) })