-
Notifications
You must be signed in to change notification settings - Fork 0
/
default-logger.ts
53 lines (42 loc) · 1.21 KB
/
default-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
42
43
44
45
46
47
48
49
50
51
52
53
import { Logger } from './logger';
import * as winston from 'winston';
import { injectable } from 'inversify';
@injectable()
export class DefaultLogger implements Logger {
private logger: any;
constructor() {
this.logger = (winston as any).createLogger({
level: 'debug',
format: (winston as any).format.combine(
(winston as any).format.splat(),
(winston as any).format.simple(),
),
transports: [
new winston.transports.Console({
format: (winston as any).format.combine(
(winston as any).format.splat(),
(winston as any).format.simple(),
),
}),
],
});
}
log(level: string, message: string, ...args: any[]): void {
this.logger.log(level, message, ...args);
}
debug(message: string, ...args: any[]): void {
this.log('debug', message, ...args);
}
info(message: string, ...args: any[]): void {
this.log('info', message, ...args);
}
warn(message: string, ...args: any[]): void {
this.log('warn', message, ...args);
}
error(message: string, ...args: any[]): void {
this.log('error', message, ...args);
}
profile(message: string): void {
this.logger.profile(message);
}
}