-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Please tell us about your environment:
winstonversion?-
winston@2 -
winston@3
-
node -voutputs: v12.11.0- Operating System? Linux
- Language? ES6
What is the problem?
If the log message matches the splat regex, the behavior of the logging changes even if the splat formatter is not used. Any meta data passed to the logger is not passed through to the underlying transport when the regex matches.
Given a logger created with a transport configured not to use the splat formatter:
const log = winston.createLogger({
level: 'debug',
transports: [
new ConsoleTransport({
format: winston.format.combine(
winston.format.timestamp(),
winston.format.printf(info => {
// ... do something with `info`
}),
),
}),
],
});
The following works as expected, extraThing is available as a property of the info object in the transport.
log.info('this is a test', { extraThing: 7 });
The following unexpectedly does not include extraThing as a property of the info object in the transport.
log.info('this is %c a test', { extraThing: 7 });
Complete running example on runkit:
https://runkit.com/murrayju/winston-format-behavior
What do you expect to happen instead?
When not using the splat formatter, the splat regex should not be tested against the message, and the behavior should not vary by the content of the message.