chore: update in the scaffolder instead
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
"p-queue": "^6.6.2",
|
||||
"prom-client": "^15.0.0",
|
||||
"tar": "^6.1.12",
|
||||
"triple-beam": "^1.4.1",
|
||||
"uuid": "^9.0.0",
|
||||
"winston": "^3.2.1",
|
||||
"winston-transport": "^4.7.0",
|
||||
@@ -108,7 +109,6 @@
|
||||
"@backstage/cli": "workspace:^",
|
||||
"@backstage/plugin-scaffolder-node-test-utils": "workspace:^",
|
||||
"@types/fs-extra": "^11.0.0",
|
||||
"@types/json-stringify-safe": "^5.0.3",
|
||||
"@types/nunjucks": "^3.1.4",
|
||||
"@types/supertest": "^2.0.8",
|
||||
"@types/zen-observable": "^0.8.0",
|
||||
|
||||
@@ -21,7 +21,7 @@ import { JsonObject } from '@backstage/types';
|
||||
import { Format, TransformableInfo } from 'logform';
|
||||
import Transport, { TransportStreamOptions } from 'winston-transport';
|
||||
import { Logger, format, createLogger, transports } from 'winston';
|
||||
import stringify from 'json-stringify-safe';
|
||||
import { MESSAGE } from 'triple-beam';
|
||||
|
||||
/**
|
||||
* Escapes a given string to be used inside a RegExp.
|
||||
@@ -108,26 +108,17 @@ export class WinstonLogger implements RootLoggerService {
|
||||
|
||||
let redactionPattern: RegExp | undefined = undefined;
|
||||
|
||||
const replace = (obj: TransformableInfo) => {
|
||||
if (!redactionPattern) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
const stringifiedFields = stringify(obj);
|
||||
const redacted = JSON.parse(
|
||||
stringifiedFields.replace(redactionPattern, '[REDACTED]'),
|
||||
);
|
||||
|
||||
for (const key in redacted) {
|
||||
if (obj && Object.hasOwn(obj, key)) {
|
||||
obj[key] = redacted[key];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
return {
|
||||
format: format(replace)(),
|
||||
format: format((obj: TransformableInfo) => {
|
||||
if (!redactionPattern || !obj) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
obj[MESSAGE] = obj[MESSAGE]?.replace?.(redactionPattern, '[REDACTED]');
|
||||
obj.message = obj.message?.replace?.(redactionPattern, '[REDACTED]');
|
||||
|
||||
return obj;
|
||||
})(),
|
||||
add(newRedactions) {
|
||||
let added = 0;
|
||||
for (const redactionToTrim of newRedactions) {
|
||||
|
||||
Reference in New Issue
Block a user