I have a Node.js app that it using Winston for logging. I am printing my logs using printf like this:
winston.createLogger({
level: 'debug',
format: winston.format.combine(
winston.format.timestamp({ format: 'HH:mm:ss.SSSSS'}),
winston.format.printf(log => `[${log.level}] [${log.timestamp}] ${log.message} `)
),
transports: []
});
This works fine except in the case of "error" logs. When a log has a log level of 'error', the log writes an entry that's formatted like this: [${log.level}] [${log.timestamp}] ${log.message}${error.message}
. Notice, there is no space between the log message and the error message.
How do I put a space between the log message and an error message if the log level is an error?
As of the documentation winton only supports that format
parameter for info
logging.