Skip to content

Commit 5fd3fcb

Browse files
committed
fix(logging): enhance HTTP logging to include tenant information
- Updated the LoggingInterceptor to extract and log tenant information during HTTP requests. - Improved log messages to include tenant slug for better traceability in multi-tenant environments. Signed-off-by: Innei <tukon479@gmail.com>
1 parent 6e309a7 commit 5fd3fcb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@
111111
"vite-plugin-html": "3.2.2",
112112
"vite-plugin-pwa": "1.1.0"
113113
}
114-
}
114+
}

be/apps/core/src/interceptors/logging.interceptor.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ const httpLogger = createLogger('HTTP')
1010
export class LoggingInterceptor implements Interceptor {
1111
async intercept(context: ExecutionContext, next: CallHandler): Promise<FrameworkResponse> {
1212
const start = performance.now()
13-
const { hono } = context.getContext()
13+
const { hono, tenant } = context.getContext()
1414
const { method, url } = hono.req
15+
const tenantSlug = tenant?.tenant.slug ?? 'n/a'
1516

1617
const uri = toUri(url)
17-
httpLogger.info(['<---', `${method} -> ${uri}`].join(' '))
18+
httpLogger.info(['<---', `${method} -> ${uri}`, `(tenant=${tenantSlug})`].join(' '))
1819
const result = await next.handle()
1920
const durationMs = Number((performance.now() - start).toFixed(2))
20-
httpLogger.info(['--->', `${method} -> ${uri}`, green(`+${durationMs}ms`)].join(' '))
21+
httpLogger.info(['--->', `${method} -> ${uri}`, `(tenant=${tenantSlug})`, green(`+${durationMs}ms`)].join(' '))
2122

2223
return result
2324
}

0 commit comments

Comments
 (0)