From 9758dfcb9d39399f404c458fbe3bc3e25e7304d4 Mon Sep 17 00:00:00 2001 From: Shinwoo PARK <shinwoo.park@psw.kr> Date: Wed, 19 Mar 2025 19:03:56 +0900 Subject: [PATCH] fuck temp 3 --- src/logged.ts | 17 ++++++++++++----- src/logger.ts | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/logged.ts b/src/logged.ts index 9774e07..f8f95e2 100644 --- a/src/logged.ts +++ b/src/logged.ts @@ -241,13 +241,20 @@ function overrideBuild<F extends Array<any>, R>( if (req[REQUEST_LOG_ID] === undefined) { req[REQUEST_LOG_ID] = ScopedLogger.createScopeId(); } else { - // TODO: INHERIT SCOPE ID + args[metadatas.scopedLoggerInjectableParam] = ScopedLogger.fromRoot(baseLogger, key, req[REQUEST_LOG_ID]); } } } 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') { // 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, loggedParams: [], }, - key, + _target.constructor.name, returnsData, newMetadata, ); @@ -665,7 +672,7 @@ export function LoggedInterceptor<F extends Array<any>, R>(options?: Partial<Ove scopedLoggerInjectableParam, loggedParams: [], }, - key, + _target.constructor.name, returnsData, newMetadata, ); @@ -741,7 +748,7 @@ export function LoggedMiddleware<F extends Array<any>, R>(options?: Partial<Over scopedLoggerInjectableParam, loggedParams: [], }, - key, + _target.constructor.name, returnsData, newMetadata, ); diff --git a/src/logger.ts b/src/logger.ts index 092c70a..9854f0c 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -33,9 +33,9 @@ export class ScopedLogger extends Logger { 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( - logger, [scope] + logger, [scope], scopeId ) }; static createScopeId(): string {