From 5c277d2f60a15728ca9c54f7887064942e89fb75 Mon Sep 17 00:00:00 2001 From: Alec Mev Date: Tue, 19 Mar 2024 11:10:47 +0000 Subject: [PATCH] Document setBindings --- docs/api.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index 9c69f86e2..1fc438423 100644 --- a/docs/api.md +++ b/docs/api.md @@ -13,7 +13,8 @@ * [logger.fatal()](#fatal) * [logger.silent()](#silent) * [logger.child()](#child) - * [logger.bindings()](#bindings) + * [logger.bindings()](#logger-bindings) + * [logger.setBindings()](#logger-set-bindings) * [logger.flush()](#flush) * [logger.level](#logger-level) * [logger.isLevelEnabled()](#islevelenabled) @@ -888,6 +889,7 @@ 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 [`options.level`](#optionslevel-string) key. + #### `bindings` (Object) An object of key-value pairs to include in every log line output @@ -978,7 +980,7 @@ child.info({test: 'will be overwritten'}) * See [`serializers` option](#opt-serializers) * See [pino.stdSerializers](#pino-stdSerializers) - + ### `logger.bindings()` Returns an object containing all the current bindings, cloned from the ones passed in via `logger.child()`. @@ -991,6 +993,16 @@ console.log(anotherChild.bindings()) // { foo: 'bar', MIX: { IN: 'always' } } ``` + +### `logger.setBindings(bindings)` + +Adds to the bindings of this logger instance. + +**Note:** Does not overwrite bindings. Can potentially result in duplicate keys in +log lines. + +* See [`bindings` parameter in `logger.child`](#logger-child-bindings) + ### `logger.flush([cb])`