Created
September 28, 2019 02:32
-
-
Save VitorDaynno/bcc760c28597cb76c64e8bfdca00351d to your computer and use it in GitHub Desktop.
Winston config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const winston = require('winston') | |
const { format, createLogger, transports } = winston; | |
const { printf, combine, colorize, timestamp } = format; | |
const { Console, File } = transports; | |
module.exports = () =>{ | |
const myFormat = printf(({ level, message, timestamp }) => { | |
return `${level}: [${timestamp}]${message}`; | |
}); | |
const logger = createLogger({ | |
format: combine(colorize(), | |
timestamp({format: 'DD-MM-YYYY HH:mm:ss'}), | |
myFormat), | |
transports: [ | |
new Console(), | |
new File({filename: 'error.log', level: 'error'}) | |
] | |
}); | |
return logger; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment