From eb55031fbd2a37259a0c1328c5f48079f22e8fd3 Mon Sep 17 00:00:00 2001 From: Naseem Date: Mon, 13 Apr 2020 16:03:59 -0400 Subject: [PATCH] add formatters to pino's LoggerOptions (#43847) A new option that deprecates other ones, please see https://github.com/pinojs/pino/blob/master/docs/api.md\#formatters-object for more details. Signed-off-by: Naseem --- types/pino/index.d.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/types/pino/index.d.ts b/types/pino/index.d.ts index 9c4a22a79c..ee1a8a53f1 100644 --- a/types/pino/index.d.ts +++ b/types/pino/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for pino 5.17 +// Type definitions for pino 6.0 // Project: https://github.com/pinojs/pino.git, http://getpino.io // Definitions by: Peter Snider // BendingBender @@ -444,6 +444,35 @@ declare namespace P { * key-value object added as child logger to each log line. If set to null the base child logger is not added */ base?: { [key: string]: any } | null; + + /** + * An object containing functions for formatting the shape of the log lines. + * These functions should return a JSONifiable object and should never throw. + * These functions allow for full customization of the resulting log lines. + * For example, they can be used to change the level key name or to enrich the default metadata. + */ + formatters?: { + /** + * Changes the shape of the log level. + * The default shape is { level: number }. + * The function takes two arguments, the label of the level (e.g. 'info') and the numeric value (e.g. 30). + */ + level?: (level: string, number: number) => object; + /** + * Changes the shape of the bindings. + * The default shape is { pid, hostname }. + * The function takes a single argument, the bindings object. + * It will be called every time a child logger is created. + */ + bindings?: (bindings: Bindings) => object; + /** + * Changes the shape of the log object. + * This function will be called every time one of the log methods (such as .info) is called. + * All arguments passed to the log method, except the message, will be pass to this function. + * By default it does not change the shape of the log object. + */ + log?: (object: object) => object; + }; } interface PrettyOptions {