Logger Service
Main logging facade with optional request context enrichment. Singleton service that can be enriched with request context via withContext().
withContext()
Features:
Architecture:
@Transient()export class UserService { constructor( @inject(LOGGER_TOKENS.LoggerService) private readonly logger: LoggerService ) {} async createUser(input: CreateUserInput) { this.logger.info('Creating user', { email: input.email }) }} Copy
@Transient()export class UserService { constructor( @inject(LOGGER_TOKENS.LoggerService) private readonly logger: LoggerService ) {} async createUser(input: CreateUserInput) { this.logger.info('Creating user', { email: input.email }) }}
// In RequestScopeServiceconst baseLogger = globalContainer.resolve<LoggerService>(LOGGER_TOKENS.LoggerService)const requestLogger = baseLogger.withContext(routerContext)requestContainer.register(LOGGER_TOKENS.LoggerService, { useValue: requestLogger }) Copy
// In RequestScopeServiceconst baseLogger = globalContainer.resolve<LoggerService>(LOGGER_TOKENS.LoggerService)const requestLogger = baseLogger.withContext(routerContext)requestContainer.register(LOGGER_TOKENS.LoggerService, { useValue: requestLogger })
Log debug message (development only)
Optional
Log error message Accepts Error object or custom context
Log info message
Log warning message
Logger Service
Main logging facade with optional request context enrichment. Singleton service that can be enriched with request context via
withContext().Features:
withContext()Architecture:
withContext()methodExample: Basic usage (no request context)
Example: With request context (in request container)