Skip to content

Commit

Permalink
docs: Update the options.level documentation of the child logger (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann authored Sep 10, 2021
1 parent a0010f3 commit c57c258
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ the current log level of the parent at the time they are spawned.
The log level of a child is mutable. It can be set independently
of the parent either by setting the [`level`](#level) accessor after creating
the child logger or using the reserved [`bindings.level`](#bindingslevel-string) key.
the child logger or using the [`options.level`](#optionslevel-string) key.
#### `bindings` (Object)
Expand All @@ -695,18 +695,6 @@ child.info('child!')
The `bindings` object may contain any key except for reserved configuration keys `level` and `serializers`.
##### `bindings.level` (String)
If a `level` property is present in the `bindings` object passed to `logger.child`
it will override the child logger level.
```js
const logger = pino()
logger.debug('nope') // will not log, since default level is info
const child = logger.child({foo: 'bar', level: 'debug'})
child.debug('debug!') // will log as the `level` property set the level to debug
```
##### `bindings.serializers` (Object) - DEPRECATED
Use `options.serializers` instead.
Expand All @@ -715,6 +703,19 @@ Use `options.serializers` instead.
Options for child logger. These options will override the parent logger options.
##### `options.level` (String)
The `level` property overrides the log level of the child logger.
By default the parent log level is inherited.
After the creation of the child logger, it is also accessible using the [`logger.level`](#logger-level) key.
```js
const logger = pino()
logger.debug('nope') // will not log, since default level is info
const child = logger.child({foo: 'bar'}, {level: 'debug')
child.debug('debug!') // will log as the `level` property set the level to debug
```
##### `options.redact` (Array | Object)
Setting `options.redact` to an array or object will override the parent `redact` options. To remove `redact` options inherited from the parent logger set this value as an empty array (`[]`).
Expand Down

0 comments on commit c57c258

Please sign in to comment.