2019-09-13 20:02:41 +00:00
|
|
|
const moment = require("moment");
|
|
|
|
const winston = require("winston");
|
|
|
|
const logger = winston.createLogger({
|
|
|
|
transports: [
|
|
|
|
new winston.transports.Console(),
|
|
|
|
new winston.transports.File({ filename: "logs/error.log", level: "error" }),
|
|
|
|
new winston.transports.File({ filename: "logs/main.log" }),
|
|
|
|
],
|
|
|
|
format: winston.format.printf(log => `[${moment().format("YYYY-MM-DD HH:mm:ss")}]: [${log.level.toUpperCase()}] - ${log.message}`)
|
|
|
|
});
|
|
|
|
|
2019-11-11 20:54:19 +00:00
|
|
|
exports.log = (type, content) => content ? logger.log(type, content) : logger.log("info", type);
|
2019-09-13 20:02:41 +00:00
|
|
|
|
|
|
|
exports.error = (...args) => this.log("error", ...args);
|
|
|
|
|
|
|
|
exports.warn = (...args) => this.log("warn", ...args);
|
|
|
|
|
|
|
|
exports.debug = (...args) => this.log("debug", ...args);
|