2020-08-18 04:58:36 +00:00
|
|
|
const { createLogger, format, transports, addColors } = require("winston");
|
|
|
|
const { combine, timestamp, printf, colorize } = format;
|
|
|
|
|
|
|
|
const fmt = printf(({ level, message, timestamp }) => {
|
2020-10-06 07:50:28 +00:00
|
|
|
return timestamp + ' ' + level + ' ' + message;
|
2020-08-18 04:58:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const customLevels = {
|
|
|
|
levels: {
|
|
|
|
debug: 0,
|
|
|
|
cmd: 1,
|
|
|
|
info: 2,
|
|
|
|
ready: 3,
|
|
|
|
warn: 4,
|
|
|
|
error: 5
|
|
|
|
},
|
|
|
|
|
|
|
|
colours: {
|
2020-10-06 07:50:28 +00:00
|
|
|
debug: "black magentaBG",
|
|
|
|
cmd: "black whiteBG",
|
|
|
|
info: "black cyanBG",
|
|
|
|
ready: "black greenBG",
|
|
|
|
warn: "black yellowBG",
|
|
|
|
error: "black redBG"
|
2020-08-18 04:58:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const logger = createLogger({
|
|
|
|
levels: customLevels.levels,
|
|
|
|
level: "error",
|
|
|
|
format: combine(
|
|
|
|
timestamp({
|
|
|
|
format: "YYYY-MM-DD hh:mm:ss"
|
|
|
|
}),
|
|
|
|
fmt
|
|
|
|
),
|
|
|
|
|
|
|
|
transports: [
|
|
|
|
new transports.Console({
|
|
|
|
level: "error",
|
|
|
|
format: combine(
|
|
|
|
timestamp({
|
|
|
|
format: "YYYY-MM-DD hh:mm:ss"
|
|
|
|
}),
|
|
|
|
colorize(),
|
|
|
|
fmt
|
|
|
|
)
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
addColors(customLevels.colours);
|
|
|
|
|
|
|
|
module.exports = logger;
|