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 #139 #141

Merged
merged 1 commit into from
Dec 1, 2016
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 @@ -406,8 +406,8 @@ function genLog (z) {
}
p = n.length = arguments.length - l
if (p > 1) {
l = countInterp(a, '%j')
if (l && typeof a === 'string') {
l = typeof a === 'string' ? countInterp(a, '%j') : 0
if (l) {
n.length = l + countInterp(a, '%d') + countInterp(a, '%s') + 1
o = `${util.format.apply(null, n)}`
} else {
Expand Down
36 changes: 36 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,42 @@ test('correctly escape msg strings', function (t) {
instance.fatal('this contains "')
})

// https://github.com/pinojs/pino/issues/139
test('object and format string', function (t) {
var instance = pino(sink(function (chunk, enc, cb) {
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
msg: 'foo bar',
v: 1
})
t.end()
cb()
}))

instance.info({}, 'foo %s', 'bar')
})

test('object and format string property', function (t) {
var instance = pino(sink(function (chunk, enc, cb) {
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
msg: 'foo bar',
answer: 42,
v: 1
})
t.end()
cb()
}))

instance.info({ answer: 42 }, 'foo %s', 'bar')
})

test('correctly strip undefined when returned from toJSON', function (t) {
t.plan(1)

Expand Down