Created
July 6, 2019 08:12
-
-
Save AhmedCommando/31a423f18e751bd27d3081b3105279d7 to your computer and use it in GitHub Desktop.
winston logger for development mode
This file contains 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 { createLogger, transports } = require('winston'); | |
const defaultLevel = process.env.LOG_LEVEL || 'info'; | |
const options = { | |
exitOnError: false, | |
level: defaultLevel | |
}; | |
const logger = new createLogger(options); | |
if (process.env.NODE_ENV === 'development') { | |
logger.add(new transports.Console({ | |
colorize: true, | |
showLevel: true, | |
timestamp: true, | |
level: 'debug' | |
})); | |
} | |
export default logger; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment