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

Fixing browser side child log issue (#960) child level can now be set at cr… #1986

Merged
merged 2 commits into from
Jun 11, 2024
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
2 changes: 1 addition & 1 deletion browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function pino (opts) {
// must happen before the level is assigned
appendChildLogger(this, newLogger)
// required to actually initialize the logger functions for any given child
newLogger.level = this.level
newLogger.level = childOptions.level || this.level // allow level to be set by childOptions

return newLogger
}
Expand Down
12 changes: 12 additions & 0 deletions test/browser-child.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ test('child has parent level', ({ end, same, is }) => {
end()
})

test('child can set level at creation time', ({ end, same, is }) => {
const instance = pino({
level: 'error',
browser: {}
})

const child = instance.child({}, { level: 'info' }) // first bindings, then options

same(child.level, 'info')
end()
})

test('changing child level does not affect parent', ({ end, same, is }) => {
const instance = pino({
level: 'error',
Expand Down