Skip to content

Commit

Permalink
Revert "fix: Run parent bindings formatter when creating child logger (
Browse files Browse the repository at this point in the history
…#1367)" (#1380)

This reverts commit 0d6eda8.
  • Loading branch information
mcollina authored Mar 22, 2022
1 parent 047ad75 commit 8f54c84
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 79 deletions.
7 changes: 1 addition & 6 deletions lib/proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,7 @@ function child (bindings, options) {
} else {
instance[formattersSym] = buildFormatters(
formatters.level,
formatters.bindings
? (bindings) => ({
...formatters.bindings(JSON.parse('{' + this[chindingsSym].substr(1) + '}')),
...bindings
})
: resetChildingsFormatter,
resetChildingsFormatter,
formatters.log
)
}
Expand Down
73 changes: 0 additions & 73 deletions test/formatters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,79 +201,6 @@ test('Formatters in child logger', async ({ match }) => {
})
})

test('Parent bindings in child logger', async ({ match }) => {
const stream = sink()

const logger = pino({
formatters: {
bindings (bindings) {
return {
...bindings,
process: {
pid: bindings.pid
},
from: 'parent'
}
}
}
}, stream)

const child = logger.child({
foo: 'bar'
})

const childOut = once(stream, 'data')
child.info('hello world')

match(await childOut, {
process: {
pid: process.pid
},
from: 'parent',
foo: 'bar'
})
})

test('Parent bindings in child logger with it\'s own bindings', async ({ match }) => {
const stream = sink()
const logger = pino({
formatters: {
bindings (bindings) {
return {
process: {
pid: bindings.pid
},
from: 'parent'
}
}
}
}, stream)

const childWithBindings = logger.child({
foo: 'bar'
}, {
formatters: {
bindings (bindings) {
return {
...bindings,
from: 'child'
}
}
}
})

const childWithBindingsOut = once(stream, 'data')
childWithBindings.info('hello world')

match(await childWithBindingsOut, {
process: {
pid: process.pid
},
foo: 'bar',
from: 'child'
})
})

test('Formatters without bindings in child logger', async ({ match }) => {
const stream = sink()
const logger = pino({
Expand Down

0 comments on commit 8f54c84

Please sign in to comment.