Skip to content

Instantly share code, notes, and snippets.

@georgebearden
Created October 10, 2018 14:26
Show Gist options
  • Save georgebearden/2c116d81da845b1bf4f99b9378443c13 to your computer and use it in GitHub Desktop.
Save georgebearden/2c116d81da845b1bf4f99b9378443c13 to your computer and use it in GitHub Desktop.
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