Created
July 14, 2020 10:19
-
-
Save velotiotech/14686ff164b30c5f92fe52fdca5346eb to your computer and use it in GitHub Desktop.
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
import { createLogger, format, transports } from 'winston'; | |
// Import Functions | |
const { File, Console } = transports; | |
// Init Logger | |
const logger = createLogger({ | |
level: 'info', | |
}); | |
const errorStackFormat = format((info) => { | |
if (info.stack) { | |
// tslint:disable-next-line:no-console | |
console.log(info.stack); | |
return false; | |
} | |
return info; | |
}); | |
const consoleTransport = new Console({ | |
format: format.combine( | |
format.colorize(), | |
format.simple(), | |
errorStackFormat(), | |
), | |
}); | |
logger.add(consoleTransport); | |
} | |
export default logger; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment