2020-04-09 23:08:28 +02:00
|
|
|
const winston = require('winston');
|
|
|
|
const moment = require('moment');
|
2020-04-08 16:27:34 +02:00
|
|
|
|
2020-04-09 16:30:52 +02:00
|
|
|
class Logger {
|
2020-04-08 16:27:34 +02:00
|
|
|
|
2020-04-09 16:30:52 +02:00
|
|
|
constructor(manager) {
|
|
|
|
|
|
|
|
this.manager = manager;
|
2020-04-09 23:08:28 +02:00
|
|
|
this.logger = winston.createLogger({
|
|
|
|
transports: [
|
|
|
|
new winston.transports.Console(),
|
2020-04-11 10:10:52 +02:00
|
|
|
new winston.transports.File({ filename: `logs/${this.date}.log` }),
|
|
|
|
new winston.transports.File({ filename: `logs/${this.date}-error.log`, level: 'error' })
|
2020-04-09 23:08:28 +02:00
|
|
|
]
|
|
|
|
});
|
2020-04-09 16:30:52 +02:00
|
|
|
|
|
|
|
}
|
2020-04-08 16:27:34 +02:00
|
|
|
|
2020-04-09 23:08:28 +02:00
|
|
|
get date() {
|
2020-04-11 10:10:52 +02:00
|
|
|
return moment().format("MM-DD-YYYY-hh:mm:ss");
|
2020-04-09 23:08:28 +02:00
|
|
|
}
|
|
|
|
|
2020-04-08 16:27:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Logger;
|