-
Notifications
You must be signed in to change notification settings - Fork 1
/
Logger.js
58 lines (44 loc) · 1.29 KB
/
Logger.js
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
54
55
56
57
58
const kLogger = Symbol('logger')
const kConfig = Symbol('config')
class Logger {
constructor($logger, $config) {
this[kLogger] = $logger
}
emergency($message, $context = []) {
this.writeLog('emerg', $message, $context);
}
alert($message, $context = []) {
this.writeLog('alert', $message, $context);
}
critical($message, $context = []) {
this.writeLog('crit', $message, $context);
}
error($message, $context = []) {
this.writeLog('error', $message, $context);
}
warning($message, $context = []) {
this.writeLog('warning', $message, $context);
}
notice($message, $context = []) {
this.writeLog('notice', $message, $context);
}
info($message, $context = []) {
this.writeLog('info', $message, $context);
}
debug($message, $context = []) {
this.writeLog('debug', $message, $context);
}
log($level, $message, $context = []) {
this.writeLog('log', $message, $context);
}
write($level, $message, $context = []) {
this.writeLog('write', $message, $context);
}
writeLog($level, $message, $context) {
this[kLogger].log($level, $message, $context);
}
getLogger() {
return this[kLogger];
}
}
module.exports = Logger