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