You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code sample const { level, message, ...meta } = info; described here does not always returns message consistently and may vary depending if format object was provided to winston.createLogger() or not. It appears that info parameter could also have an info[Symbol.for('message')] in addition to info.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 by info.message.
When formatting is provided to winston.createLogger() constructor, the correct message will be in info[MESSAGE] field, while info.message contains non-formatted version of the message.
Given a fact that we don't have a way to see if formatting was provided for winston.createLogger() constructor or not, we cannot provide a deterministic approach to fetch correct message (e.g. we cannot count on info[MESSAGE] nor on info.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()]});
The text was updated successfully, but these errors were encountered:
The code sample
const { level, message, ...meta } = info;
described here 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:winston.createLogger()
constructor, the correct message indeed returned byinfo.message
.winston.createLogger()
constructor, the correct message will be ininfo[MESSAGE]
field, whileinfo.message
contains non-formatted version of the message.Given a fact that we don't have a way to see if formatting was provided for
winston.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:
The text was updated successfully, but these errors were encountered: