mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -04:00
Add logger module and custom logger implementation
ConsoleLoggerService is based on the default Nest LoggerService, but adds the ability to give context about the function that is logging something. It also removes the `[Nest]` string and the PID at the beginning of each log line. NestConsoleLoggerService is a wrapper around ConsoleLoggerService and makes it possible to use our implementation as a default Nest LoggerService Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
d07d8fe278
commit
1a2959f6dc
3 changed files with 161 additions and 0 deletions
33
src/logger/nest-console-logger.service.ts
Normal file
33
src/logger/nest-console-logger.service.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { Injectable, LoggerService } from '@nestjs/common';
|
||||
import { ConsoleLoggerService } from './console-logger.service';
|
||||
|
||||
Injectable();
|
||||
|
||||
export class NestConsoleLoggerService implements LoggerService {
|
||||
private consoleLoggerService = new ConsoleLoggerService();
|
||||
|
||||
debug(message: any, context?: string): any {
|
||||
this.consoleLoggerService.setContext(context);
|
||||
this.consoleLoggerService.debug(message);
|
||||
}
|
||||
|
||||
error(message: any, trace?: string, context?: string): any {
|
||||
this.consoleLoggerService.setContext(context);
|
||||
this.consoleLoggerService.error(message);
|
||||
}
|
||||
|
||||
log(message: any, context?: string): any {
|
||||
this.consoleLoggerService.setContext(context);
|
||||
this.consoleLoggerService.log(message);
|
||||
}
|
||||
|
||||
verbose(message: any, context?: string): any {
|
||||
this.consoleLoggerService.setContext(context);
|
||||
this.consoleLoggerService.verbose(message);
|
||||
}
|
||||
|
||||
warn(message: any, context?: string): any {
|
||||
this.consoleLoggerService.setContext(context);
|
||||
this.consoleLoggerService.warn(message);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue