Created
October 10, 2018 14:26
-
-
Save georgebearden/2c116d81da845b1bf4f99b9378443c13 to your computer and use it in GitHub Desktop.
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
import { createLogger, format, transports } from 'winston' | |
const { combine, timestamp, label, printf } = format; | |
const myFormat = printf(info => { | |
return `${info.timestamp} [${info.label}] ${info.level} - ${info.message}`; | |
}); | |
module.exports = function(fileName) { | |
return createLogger({ | |
format: combine( | |
timestamp(), | |
label({label: fileName}), | |
myFormat | |
), | |
transports: [new transports.Console({ | |
level: process.env.STAGE === 'PROD' ? 'error' : 'debug' | |
})] | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment