Skip to content

Commit

Permalink
Do not redact the empty string
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
  • Loading branch information
freben committed Nov 16, 2021
1 parent eaeac8f commit 26b5da1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-rice-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/backend-common': patch
---

Do not redact the empty string, destroying all logs
9 changes: 6 additions & 3 deletions packages/backend-common/src/logging/rootLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 26b5da1

Please sign in to comment.