Last active
June 27, 2024 13:02
-
-
Save andersonbosa/90b305d464fd535f0c193e892ebb08c6 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 winston from 'winston' | |
const createWinstonLogger = () => winston.createLogger({ | |
levels: winston.config.syslog.levels, | |
transports: [ | |
new winston.transports.Console({ | |
level: 'info', | |
format: winston.format.combine( | |
winston.format.colorize({ all: true }), | |
winston.format.timestamp({ format: 'YYYY-MM-DD hh:mm:ss.SSS A', }), | |
winston.format.align(), | |
winston.format.printf((info) => `[${info.timestamp}] ${info.level.toUpperCase()}: ${info.message}`) | |
) | |
}), | |
new winston.transports.File({ | |
filename: 'winston.log', | |
level: 'debug', | |
format: winston.format.combine( | |
winston.format.timestamp(), | |
winston.format.json(), | |
) | |
}) | |
] | |
}) | |
export const LOGGER = createWinstonLogger() // this is not a singleton |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment