Skip to content

Commit

Permalink
Fix #139.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Nov 29, 2016
1 parent 0b56336 commit f438c6d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pino.js
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') {
if (typeof a === 'string') {
l = countInterp(a, '%j')
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
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

0 comments on commit f438c6d

Please sign in to comment.