Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: formatOpts typo #422

Merged
merged 2 commits into from
Jun 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pino.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function pino (opts, stream) {

// internal options
iopts.stringify = iopts.safe ? stringifySafe : JSON.stringify
iopts.formatOpts = {lowres: true}
iopts.formatOpts = {lowres: !iopts.safe}
iopts.messageKeyString = `,"${iopts.messageKey}":`
iopts.end = ',"v":' + LOG_VERSION + '}' + (iopts.crlf ? '\r\n' : '\n')
iopts.cache = !iopts.extreme ? null : {
Expand All @@ -320,7 +320,7 @@ function pino (opts, stream) {
instance.timestamp = iopts.timestamp
instance.slowtime = iopts.slowtime
instance.cache = iopts.cache
instance.formatiopts = iopts.formatiopts
instance.formatOpts = iopts.formatOpts
instance.onTerminated = iopts.onTerminated
instance.messageKey = iopts.messageKey
instance.messageKeyString = iopts.messageKeyString
Expand Down
22 changes: 22 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,25 @@ test('when safe is true it should ONLY use `fast-safe-stringify`', function (t)
})
t.end()
})

test('when safe is true, fast-safe-stringify must be used when interpolating', function (t) {
var instance = pino({safe: true}, sink(function (chunk, enc, cb) {
const { msg } = chunk
t.is(msg, 'test {"a":{"b":{"c":"[Circular]"}}}')
t.end()
}))
var o = { a: { b: {} } }
o.a.b.c = o.a.b
instance.info('test', o)
})

test('when safe is false, interpolation output circulars at the root', function (t) {
var instance = pino({safe: false}, sink(function (chunk, enc, cb) {
const { msg } = chunk
t.is(msg, 'test "[Circular]"')
t.end()
}))
var o = { a: { b: {} } }
o.a.b.c = o.a.b
instance.info('test', o)
})