Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pinojs/pino
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Sep 28, 2022
2 parents f1aa631 + e6d355c commit de05d49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/tools.js
Expand Up @@ -53,7 +53,7 @@ function genLog (level, hook) {
}
this[writeSym](o, format(msg, formatParams, this[formatOptsSym]), level)
} else {
this[writeSym](null, format(o, n, this[formatOptsSym]), level)
this[writeSym](null, format(o === undefined ? n.shift() : o, n, this[formatOptsSym]), level)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -104,7 +104,7 @@
"tape": "^5.5.3",
"through2": "^4.0.0",
"ts-node": "^10.9.1",
"tsd": "^0.23.0",
"tsd": "^0.24.1",
"typescript": "^4.8.2",
"winston": "^3.7.2"
},
Expand Down
16 changes: 16 additions & 0 deletions test/basic.test.js
Expand Up @@ -109,6 +109,22 @@ function levelTest (name, level) {
same(Object.keys(obj), ['hello'])
})

test(`passing a undefined and a string at level ${name}`, async ({ equal, same }) => {
const stream = sink()
const instance = pino(stream)
instance.level = name
instance[name](undefined, 'a string')
const result = await once(stream, 'data')
equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
same(result, {
pid,
hostname,
level,
msg: 'a string'
})
})

test(`overriding object key by string at level ${name}`, async ({ equal, same }) => {
const stream = sink()
const instance = pino(stream)
Expand Down

0 comments on commit de05d49

Please sign in to comment.