fixed issue with logger and hideObject
This commit is contained in:
parent
19ecd95346
commit
6d5d746f68
3 changed files with 15 additions and 35 deletions
|
|
@ -177,9 +177,9 @@ export class Logger {
|
|||
|
||||
let data = { ...this.context, ...metadata };
|
||||
|
||||
// Filter out objects if hideObject is enabled
|
||||
// Hide all metadata if hideObject is enabled
|
||||
if (globalConfig.hideObject) {
|
||||
data = this.filterObjects(data);
|
||||
data = {}; // Clear all metadata
|
||||
}
|
||||
|
||||
if (typeof message === 'string') {
|
||||
|
|
@ -193,27 +193,6 @@ export class Logger {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out objects from metadata when hideObject is enabled
|
||||
*/
|
||||
private filterObjects(data: Record<string, any>): Record<string, any> {
|
||||
const filtered: Record<string, any> = {};
|
||||
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
||||
// Keep error objects for debugging
|
||||
if (key === 'err' || key === 'error' || value instanceof Error) {
|
||||
filtered[key] = value;
|
||||
} else {
|
||||
filtered[key] = '[object hidden]';
|
||||
}
|
||||
} else {
|
||||
filtered[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
// Simple log level methods
|
||||
trace(message: string | object, metadata?: LogMetadata): void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue