ptarmiganlabs / butler-cw

Cache warming for Qlik Sense. Proactively load Sense apps into memory in order to minimise load time and maximise user experience
https://ptarmiganlabs.com
MIT License
11 stars 8 forks source link

Make Winston logger handle errors properly #163

Open mountaindude opened 2 years ago

mountaindude commented 2 years ago

The logging module of Butler CW does not currently handle error logging as well as it should. Specifically, in some cases there is no stack trace or error message when errors occur.

This can be easily fixed by adding the following to the Winston.createLogger call:

winston.format.errors({ stack: true })

mountaindude commented 2 years ago

Example

logTransports.push(
    new winston.transports.Console({
        name: 'console',
        level: config.get('Butler.logLevel'),
        format: winston.format.combine(
            winston.format.errors({ stack: true }),
            winston.format.timestamp(),
            winston.format.colorize(),
            winston.format.simple(),
            winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`)
        ),
    })
);