- Notifications
You must be signed in to change notification settings - Fork97
Open
Description
The code sampleconst { level, message, ...meta } = info; describedhere does not always returns message consistently and may vary depending if format object was provided towinston.createLogger() or not. It appears thatinfo parameter could also have aninfo[Symbol.for('message')] in addition toinfo.message field and those values are not the same:
- In case when no formatting is provided to
winston.createLogger()constructor, the correct message indeed returned byinfo.message. - When formatting is provided to
winston.createLogger()constructor, the correct message will be ininfo[MESSAGE]field, whileinfo.messagecontains non-formatted version of the message.
Given a fact that we don't have a way to see if formatting was provided forwinston.createLogger() constructor or not, we cannot provide a deterministic approach to fetch correct message (e.g. we cannot count oninfo[MESSAGE] nor oninfo.message fields to determine where is a "right" message is).
The code which can be used to test the issue is:
constlogger=winston.createLogger({level:LOG_LEVEL,format:winston.format.combine(winston.format.timestamp({format:'YYYY-MM-DD HH:mm:ss,SSS'}),winston.format.printf(info=>`${info.timestamp} |${info.level.toUpperCase()}| my-service ->${info.message}`)),transports:[// Add custom transport here to intercept the info for debugging purposes//new SomeTransportLogging(),newwinston.transports.Console()]});
Metadata
Metadata
Assignees
Labels
No labels