-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.ts
41 lines (32 loc) · 1 KB
/
logger.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Consola, ConsolaOptions } from 'consola';
import { ILogger, LogLevel } from '../interfaces/ILogger';
import { getConoslaLogLevel } from './logLevel';
export class Logger extends Consola implements ILogger {
constructor(options: ConsolaOptions) {
super(options);
}
public isTraceEnabled(): boolean {
return this.isLevelEnabled(LogLevel.TRACE);
}
public isDebugEnabled(): boolean {
return this.isLevelEnabled(LogLevel.DEBUG);
}
public isInfoEnabled(): boolean {
return this.isLevelEnabled(LogLevel.INFO);
}
public isWarnEnabled(): boolean {
return this.isLevelEnabled(LogLevel.WARN);
}
public isLogEnabled(): boolean {
return this.isLevelEnabled(LogLevel.LOG);
}
public isErrorEnabled(): boolean {
return this.isLevelEnabled(LogLevel.ERROR);
}
public isSilent(): boolean {
return this.level === getConoslaLogLevel(LogLevel.SILENT);
}
private isLevelEnabled(level: LogLevel): boolean {
return this.level >= getConoslaLogLevel(level);
}
}