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 <naseem@transit.app>
This commit is contained in:
Naseem
2020-04-13 13:03:59 -07:00
committed by GitHub
parent 64989f4ed4
commit eb55031fbd
+30 -1
View File
@@ -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 <https://github.com/psnider>
// BendingBender <https://github.com/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 {