-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger.js
50 lines (42 loc) · 1.13 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
const winston = require("winston");
loggerInstance = null;
class Logger {
static getInstance() {
if (loggerInstance === null) {
loggerInstance = new Logger();
}
return loggerInstance;
}
constructor() {
this._logger = new winston.Logger({
transports: [
new (winston.transports.File)({
name: 'info-file',
filename: 'logs/info.log',
level: 'info'
}),
new (winston.transports.Console)({
level: 'info'
}),
new (winston.transports.File)({
name: 'error-file',
filename: 'logs/error.log',
level: 'error'
})
]
});
}
info(string) {
this._logger.log('info', string);
}
debug(string) {
this._logger.log('debug', string);
}
error(string) {
this._logger.log('error', string);
}
}
module.exports = Logger.getInstance();
// debugging
// var l = Logger.getInstance();
// l.info("Testing logger.");