mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Add redact to pino options
This commit is contained in:
Vendored
+20
@@ -173,6 +173,20 @@ declare namespace P {
|
||||
* Warning: this option may not be supported by downstream transports.
|
||||
*/
|
||||
useOnlyCustomLevels?: boolean;
|
||||
|
||||
/**
|
||||
* As an array, the redact option specifies paths that should have their values redacted from any log output.
|
||||
*
|
||||
* Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation.
|
||||
*
|
||||
* If an object is supplied, three options can be specified:
|
||||
*
|
||||
* paths (String[]): Required. An array of paths
|
||||
* censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]'
|
||||
* remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false
|
||||
*/
|
||||
redact?: string[] | redactOptions;
|
||||
|
||||
/**
|
||||
* When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`.
|
||||
*/
|
||||
@@ -420,4 +434,10 @@ declare namespace P {
|
||||
(msg: string, ...args: any[]): void;
|
||||
(obj: object, msg?: string, ...args: any[]): void;
|
||||
}
|
||||
|
||||
interface redactOptions {
|
||||
paths: string[];
|
||||
censor?: string;
|
||||
remove?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,3 +102,24 @@ const handler = pino.final(logExtreme, (err: Error, finalLogger: pino.BaseLogger
|
||||
});
|
||||
|
||||
handler(new Error('error'));
|
||||
|
||||
const redacted = pino({
|
||||
redact: ['path']
|
||||
});
|
||||
|
||||
redacted.info({
|
||||
msg: 'logged with redacted properties',
|
||||
path: 'Not shown'
|
||||
});
|
||||
|
||||
const anotherRedacted = pino({
|
||||
redact: {
|
||||
paths: ['anotherPath'],
|
||||
censor: 'Not the log you\re looking for'
|
||||
}
|
||||
});
|
||||
|
||||
anotherRedacted.info({
|
||||
msg: 'another logged with redacted properties',
|
||||
anotherPath: 'Not shown'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user