fix production logs filter
This commit is contained in:
parent
54775f537d
commit
1e441560f6
2 changed files with 16 additions and 9 deletions
|
|
@ -5,13 +5,14 @@ const CONTEXTS_TO_IGNORE = [
|
||||||
'InstanceLoader',
|
'InstanceLoader',
|
||||||
'RoutesResolver',
|
'RoutesResolver',
|
||||||
'RouterExplorer',
|
'RouterExplorer',
|
||||||
|
'LegacyRouteConverter',
|
||||||
'WebSocketsController',
|
'WebSocketsController',
|
||||||
];
|
];
|
||||||
|
|
||||||
export function createPinoConfig(): Params {
|
export function createPinoConfig(): Params {
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV?.toLowerCase() === 'production';
|
||||||
const isDebugMode = process.env.DEBUG_MODE === 'true';
|
const isDebugMode = process.env.DEBUG_MODE?.toLowerCase() === 'true';
|
||||||
const logHttp = process.env.LOG_HTTP === 'true';
|
const logHttp = process.env.LOG_HTTP?.toLowerCase() === 'true';
|
||||||
|
|
||||||
const level = isProduction && !isDebugMode ? 'info' : 'debug';
|
const level = isProduction && !isDebugMode ? 'info' : 'debug';
|
||||||
|
|
||||||
|
|
@ -32,14 +33,20 @@ export function createPinoConfig(): Params {
|
||||||
: undefined,
|
: undefined,
|
||||||
formatters: {
|
formatters: {
|
||||||
level: (label) => ({ level: label }),
|
level: (label) => ({ level: label }),
|
||||||
log: (object: Record<string, unknown>) => {
|
},
|
||||||
|
hooks: {
|
||||||
|
logMethod(inputArgs, method) {
|
||||||
if (isProduction && !isDebugMode) {
|
if (isProduction && !isDebugMode) {
|
||||||
const context = object['context'] as string | undefined;
|
for (const arg of inputArgs) {
|
||||||
if (context && CONTEXTS_TO_IGNORE.includes(context)) {
|
if (typeof arg === 'object' && arg !== null && 'context' in arg) {
|
||||||
return { filtered: true };
|
const context = (arg as Record<string, unknown>)['context'];
|
||||||
|
if (typeof context === 'string' && CONTEXTS_TO_IGNORE.includes(context)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return object;
|
return method.apply(this, inputArgs);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
serializers: {
|
serializers: {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit b6844b019c3778d51ff1bb236f30284a0bf8f403
|
Subproject commit 88e3d01f8135c2dbc628b9636ba91bb9ffd2f0eb
|
||||||
Loading…
Add table
Reference in a new issue