Skip to content

Commit

Permalink
#532 Updated cls service injection
Browse files Browse the repository at this point in the history
  • Loading branch information
leoseg committed Dec 15, 2024
1 parent 1a8e314 commit 83d4e5d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/logger/logger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ConsoleLogger, Inject } from '@nestjs/common';
import { ConsoleLogger } from '@nestjs/common';
import Rollbar from 'rollbar';
import { FIREBASE_ERRORS } from 'src/utils/errors';
import { isProduction, rollbarEnv, rollbarToken } from '../utils/constants';
import { ErrorLog } from './utils';
import { ClsService } from 'nestjs-cls';
import { ClsService, ClsServiceManager } from 'nestjs-cls';

interface LogMessage {
event: string;
Expand All @@ -13,12 +13,11 @@ interface LogMessage {

export class Logger extends ConsoleLogger {
private rollbar?: Rollbar;

@Inject
(ClsService) private readonly cls: ClsService;
private cls: ClsService;

constructor(context?: string, isTimestampEnabled?) {
super(context, isTimestampEnabled);
this.cls = ClsServiceManager.getClsService();
this.initialiseRollbar();
}

Expand All @@ -28,6 +27,7 @@ export class Logger extends ConsoleLogger {
const sessionId = this.cls.get('sessionId');
const decoratedMessage = `[Request ID: ${requestId}, Session ID: ${sessionId}] ${formattedMessage}`;
super.log(decoratedMessage);

}

error(message: string | ErrorLog, trace?: string): void {
Expand Down

0 comments on commit 83d4e5d

Please sign in to comment.