import changes

This commit is contained in:
Emily 2020-10-17 12:17:05 +11:00
parent 0588d24882
commit 7e140d1ce8

View file

@ -1,52 +1,51 @@
const { createLogger, format, transports, addColors } = require("winston");
const { combine, timestamp, printf, colorize } = format;
const { createLogger, format, transports, addColors } = require('winston');
const fmt = printf(({ level, message, timestamp }) => {
return '[' + timestamp + '] ' + level + ' ' + message;
const fmt = format.printf(({ level, message, timestamp }) => {
return '[' + timestamp + '] ' + level + ' ' + message;
});
const customLevels = {
levels: {
debug: 0,
cmd: 1,
info: 2,
ready: 3,
warn: 4,
error: 5
},
levels: {
debug: 0,
cmd: 1,
info: 2,
ready: 3,
warn: 4,
error: 5
},
colours: {
debug: "black magentaBG",
cmd: "black whiteBG",
info: "black cyanBG",
ready: "black greenBG",
warn: "black yellowBG",
error: "black redBG"
}
colours: {
debug: 'black magentaBG',
cmd: 'black whiteBG',
info: 'black cyanBG',
ready: 'black greenBG',
warn: 'black yellowBG',
error: 'black redBG'
}
};
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"
levels: customLevels.levels,
level: 'error',
format: format.combine(
format.timestamp({
format: 'YYYY-MM-DD hh:mm:ss'
}),
colorize(),
fmt
)
})
]
),
transports: [
new transports.Console({
level: 'error',
format: format.combine(
format.timestamp({
format: 'YYYY-MM-DD hh:mm:ss'
}),
format.colorize(),
fmt
)
})
]
});
addColors(customLevels.colours);