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
We intercept messages from the console. Some messages come with a '%c' character. When we pass an object to the logger method, only the message and level fields reach the format, the rest of the fields are undefined.
What we have in the file now: 2021-06-07 00:00:00.00+03:00 | 00000 | info | | %c next state color: #4CAF50; font-weight: bold [object Object] |
We expect that the fields will be in our format and message won't be formatted.
What we expect in the file: 2021-06-07 00:00:00.000 +00:00 | 00000 | info | Renderer | %c next state color: #4CAF50; font-weight: bold [object Object] | (1) index.ts
Other information
Example of execution log method: this.logger.log({ message, line, sourceId, scope }, undefined);
Logger has been created via: WinstonModule.createLogger({ transports: [this.FileTransport] })
Example of format:
Line, sourceId and scope fields are undefined when message contains '%c'. format.printf( ({ level, message = '', timestamp, line, sourceId, scope = '', exception = '' }) => `${String(timestamp)} | ${String(process.pid)} | ${String(level)} | ${String(scope)} | ${message} | ` + `${sourceId ? `(${String(line)}) ${String(sourceId)}` : ''}\n${String(exception)}`, );
Example of the message: %c action color: #03A9F4; font-weight: bold [object Object]
The text was updated successfully, but these errors were encountered:
Please tell us about your environment:
winston
version?winston@2
winston@3
node -v
outputs: v14.17.0What is the problem?
We intercept messages from the console. Some messages come with a '%c' character. When we pass an object to the logger method, only the message and level fields reach the format, the rest of the fields are undefined.
What we have in the file now:
2021-06-07 00:00:00.00+03:00 | 00000 | info | | %c next state color: #4CAF50; font-weight: bold [object Object] |
We are loosing meta here:
winston/lib/winston/logger.js
Line 251 in 2625f60
What do you expect to happen instead?
We expect that the fields will be in our format and message won't be formatted.
What we expect in the file:
2021-06-07 00:00:00.000 +00:00 | 00000 | info | Renderer | %c next state color: #4CAF50; font-weight: bold [object Object] | (1) index.ts
Other information
Example of execution log method:
this.logger.log({ message, line, sourceId, scope }, undefined);
Logger has been created via:
WinstonModule.createLogger({ transports: [this.FileTransport] })
Example of format:
Line, sourceId and scope fields are undefined when message contains '%c'.
format.printf( ({ level, message = '', timestamp, line, sourceId, scope = '', exception = '' }) => `${String(timestamp)} | ${String(process.pid)} | ${String(level)} | ${String(scope)} | ${message} | ` + `${sourceId ? `(${String(line)}) ${String(sourceId)}` : ''}\n${String(exception)}`, );
Example of the message:
%c action color: #03A9F4; font-weight: bold [object Object]
The text was updated successfully, but these errors were encountered: