mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: apply feedback
This commit is contained in:
parent
e8cbe253d3
commit
3756235a76
@ -17,8 +17,6 @@ import { INQUIRER } from '@nestjs/core';
|
|||||||
|
|
||||||
@Injectable({ scope: Scope.TRANSIENT })
|
@Injectable({ scope: Scope.TRANSIENT })
|
||||||
export class LoggerService extends ConsoleLogger {
|
export class LoggerService extends ConsoleLogger {
|
||||||
private logLevels: LogLevel[] = [];
|
|
||||||
|
|
||||||
constructor(@Inject(INQUIRER) private parentClass: object) {
|
constructor(@Inject(INQUIRER) private parentClass: object) {
|
||||||
super(parentClass.constructor.name, {
|
super(parentClass.constructor.name, {
|
||||||
logLevels: process.env.NODE_ENV?.includes('dev')
|
logLevels: process.env.NODE_ENV?.includes('dev')
|
||||||
@ -28,54 +26,31 @@ export class LoggerService extends ConsoleLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log(message: string, ...args: any[]) {
|
log(message: string, ...args: any[]) {
|
||||||
if (!this.isLevelEnabled('log')) {
|
this.logArguments('log', message, args);
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.log(message);
|
|
||||||
this.logArguments('log', args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error(message: string, ...args: any[]) {
|
error(message: string, ...args: any[]) {
|
||||||
if (!this.isLevelEnabled('error')) {
|
this.logArguments('error', message, args);
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.error(message);
|
|
||||||
this.logArguments('error', args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
warn(message: string, ...args: any[]) {
|
warn(message: string, ...args: any[]) {
|
||||||
if (!this.isLevelEnabled('warn')) {
|
this.logArguments('warn', message, args);
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.warn(message);
|
|
||||||
this.logArguments('warn', args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(message: string, ...args: any[]) {
|
debug(message: string, ...args: any[]) {
|
||||||
if (!this.isLevelEnabled('debug')) {
|
this.logArguments('debug', message, args);
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.debug(message);
|
|
||||||
this.logArguments('debug', args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose(message: string, ...args: any[]) {
|
verbose(message: string, ...args: any[]) {
|
||||||
if (!this.isLevelEnabled('verbose')) {
|
this.logArguments('verbose', message, args);
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.verbose(message);
|
|
||||||
this.logArguments('verbose', args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal(message: string, ...args: any[]) {
|
fatal(message: string, ...args: any[]) {
|
||||||
if (!this.isLevelEnabled('fatal')) {
|
this.logArguments('fatal', message, args);
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.fatal(message);
|
|
||||||
this.logArguments('fatal', args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private logArguments(type: LogLevel, args: any[]) {
|
private logArguments(type: LogLevel, message: string, args: any[]) {
|
||||||
|
super[type](message);
|
||||||
args.forEach((arg) => {
|
args.forEach((arg) => {
|
||||||
super[type](arg);
|
super[type](arg);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user