mrmBot-Matrix/utils/logger.js

19 lines
691 B
JavaScript
Raw Normal View History

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}`)
});
exports.log = (type = "info", content) => logger.log(type, content);
exports.error = (...args) => this.log("error", ...args);
exports.warn = (...args) => this.log("warn", ...args);
exports.debug = (...args) => this.log("debug", ...args);