winstonjs/logform

splat() spreads individual characters of unreferenced string into result

Opened this issue · 1 comments

If there is an additional string parameter that is not insert via %s into the message template, its characters are inserted individually as properties into the result:

const {createLogger, format, transports} = require('winston');
const logger = createLogger({
  level: 'info',
  format: format.combine(format.splat(), format.json()),
  transports: [new transports.Console()],
});

logger.error('one %s', 'two', 'three');
// {"0":"t","1":"h","2":"r","3":"e","4":"e","level":"error","message":"one two"}

While this is in compliance with the documentation at https://github.com/winstonjs/logform#splat it is still not expected. The behavior should be aligned to what console.log() does where additional parameters are just printed as they are.
Issue #51 suggests that they should be collected into a meta-property which would also be fine as they could then be used in a custom printf transformation.

Versions:
winston@3.2.1
logform@2.1.2

Y-qwq commented

+1