mirror of
https://github.com/immich-app/immich.git
synced 2025-12-24 01:11:32 +03:00
28 lines
837 B
TypeScript
28 lines
837 B
TypeScript
|
|
import { Injectable } from '@nestjs/common';
|
||
|
|
import { ClsService } from 'nestjs-cls';
|
||
|
|
import { LogLevel } from 'src/entities/system-config.entity';
|
||
|
|
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||
|
|
import { ImmichLogger } from 'src/utils/logger';
|
||
|
|
|
||
|
|
@Injectable()
|
||
|
|
export class LoggerRepository extends ImmichLogger implements ILoggerRepository {
|
||
|
|
constructor(private cls: ClsService) {
|
||
|
|
super(LoggerRepository.name);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected formatContext(context: string): string {
|
||
|
|
let formattedContext = super.formatContext(context);
|
||
|
|
|
||
|
|
const correlationId = this.cls?.getId();
|
||
|
|
if (correlationId && this.isLevelEnabled(LogLevel.VERBOSE)) {
|
||
|
|
formattedContext += `[${correlationId}] `;
|
||
|
|
}
|
||
|
|
|
||
|
|
return formattedContext;
|
||
|
|
}
|
||
|
|
|
||
|
|
setLogLevel(level: LogLevel): void {
|
||
|
|
ImmichLogger.setLogLevel(level);
|
||
|
|
}
|
||
|
|
}
|