fuck temp 3

This commit is contained in:
Shinwoo PARK 2025-03-19 19:03:56 +09:00
parent 9f855b9939
commit 9758dfcb9d
2 changed files with 14 additions and 7 deletions

View File

@ -241,13 +241,20 @@ function overrideBuild<F extends Array<any>, R>(
if (req[REQUEST_LOG_ID] === undefined) { if (req[REQUEST_LOG_ID] === undefined) {
req[REQUEST_LOG_ID] = ScopedLogger.createScopeId(); req[REQUEST_LOG_ID] = ScopedLogger.createScopeId();
} else { } else {
// TODO: INHERIT SCOPE ID args[metadatas.scopedLoggerInjectableParam] = ScopedLogger.fromRoot(baseLogger, key, req[REQUEST_LOG_ID]);
} }
} }
} else if (type === 'middleware') { } else if (type === 'middleware') {
// args[0] == Request let req = args[0];
if (req[REQUEST_LOG_ID] === undefined) {
req[REQUEST_LOG_ID] = ScopedLogger.createScopeId();
} else {
args[metadatas.scopedLoggerInjectableParam] = ScopedLogger.fromRoot(baseLogger, key, req[REQUEST_LOG_ID]);
}
} else if (type === 'route') { } else if (type === 'route') {
// should use @Req // should use @Req
// WTF how should I get the request id from request object???????????????????????????????????????????????????????????????
// FUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCKFUCK
} }
} }
@ -589,7 +596,7 @@ export function LoggedGuard<F extends Array<any>, R>(options?: Partial<OverrideB
scopedLoggerInjectableParam, scopedLoggerInjectableParam,
loggedParams: [], loggedParams: [],
}, },
key, _target.constructor.name,
returnsData, returnsData,
newMetadata, newMetadata,
); );
@ -665,7 +672,7 @@ export function LoggedInterceptor<F extends Array<any>, R>(options?: Partial<Ove
scopedLoggerInjectableParam, scopedLoggerInjectableParam,
loggedParams: [], loggedParams: [],
}, },
key, _target.constructor.name,
returnsData, returnsData,
newMetadata, newMetadata,
); );
@ -741,7 +748,7 @@ export function LoggedMiddleware<F extends Array<any>, R>(options?: Partial<Over
scopedLoggerInjectableParam, scopedLoggerInjectableParam,
loggedParams: [], loggedParams: [],
}, },
key, _target.constructor.name,
returnsData, returnsData,
newMetadata, newMetadata,
); );

View File

@ -33,9 +33,9 @@ export class ScopedLogger extends Logger {
baseLogger, [...logger.scope, scope], logger.scopeId baseLogger, [...logger.scope, scope], logger.scopeId
) )
}; };
static fromRoot(logger: Logger, scope: string): ScopedLogger { static fromRoot(logger: Logger, scope: string, scopeId?: string): ScopedLogger {
return new ScopedLogger( return new ScopedLogger(
logger, [scope] logger, [scope], scopeId
) )
}; };
static createScopeId(): string { static createScopeId(): string {