Do not redact the empty string

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-11-16 11:42:10 +01:00
parent eaeac8fdac
commit 26b5da1c1a
2 changed files with 11 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-common': patch
---
Do not redact the empty string, destroying all logs
@@ -21,7 +21,7 @@ import { coloredFormat } from './formats';
import { escapeRegExp } from '../util/escapeRegExp';
let rootLogger: winston.Logger;
let redactionRegExp: RegExp;
let redactionRegExp: RegExp | undefined;
/** @public */
export function getRootLogger(): winston.Logger {
@@ -34,11 +34,14 @@ export function setRootLogger(newLogger: winston.Logger) {
}
export function setRootLoggerRedactionList(redactionList: string[]) {
if (redactionList.length) {
const filtered = redactionList.filter(Boolean);
if (filtered.length) {
redactionRegExp = new RegExp(
`(${redactionList.map(escapeRegExp).join('|')})`,
`(${filtered.map(escapeRegExp).join('|')})`,
'g',
);
} else {
redactionRegExp = undefined;
}
}