winston version?_node -v outputs:_v10.13.0logger.info('First', 'Second') is printing only First in the console and in File.
With 3.0, this is printing both arguments, First & Second. (Second in the new line)
Expecting output as
First Second
What formatters and other config are you using? In particular, handling of splats/metadata has changed from 3.0 to 3.2.
@DABH Can I get to see the change details w.r.t 3.2 ?
Below is the custom formatter function ___f__ and usage.
const ___f__ = winston.format.printf(info => {
let log = '[Process : ' + process.pid + ' AT : ' + info.timestamp + '] ' + info.level + ' : ' + (undefined !== info.message ? info.message : '');
if(info.meta){
log += '\n' + util.inspect(info.meta);
}
return log;
});
........
........
winston.createLogger({
level: 'debug',
transports : {transports}
exitOnError : false,
format: winston.format.combine(
winston.format.timestamp(),
winston.format.splat(),
___f__
),
timestamp : {dateFormatterFunction}
});
You could log like logger.info(['First', 'Second']) if you need that kind of call. Generally winston isn't really designed for that call style; for the leveled log methods, the first param is a string message, and all other params are treated as splats/metas.
That being said, I think https://github.com/winstonjs/logform/pull/85 with the metadataArray might help achieve what you want. I can leave this issue open till that gets merged.
I think this is such a breaking change...
The partial solution is:
const wrapper = ( original ) => {
return (...args) => {
for (let index = 0; index < args.length; index++) {
if(args[index] instanceof Error){
args[index] = args[index].stack
}
}
original(args.join(" "))
}
};
logger.error = wrapper(logger.error);
logger.warn = wrapper(logger.warn);
logger.info = wrapper(logger.info);
logger.verbose = wrapper(logger.verbose);
logger.debug = wrapper(logger.debug);
logger.silly = wrapper(logger.silly);
You could log like
logger.info(['First', 'Second'])if you need that kind of call. Generallywinstonisn't really designed for that call style; for the leveled log methods, the first param is a string message, and all other params are treated as splats/metas.That being said, I think winstonjs/logform#85 with the
metadataArraymight help achieve what you want. I can leave this issue open till that gets merged.
But util.format('First', 'Second') will output First Second, the same as console.log and winston@2. Why winston@3 with format splat break this behavior?
I think this is such a breaking change...
The partial solution is:
const wrapper = ( original ) => { return (...args) => { for (let index = 0; index < args.length; index++) { if(args[index] instanceof Error){ args[index] = args[index].stack } } original(args.join(" ")) } }; logger.error = wrapper(logger.error); logger.warn = wrapper(logger.warn); logger.info = wrapper(logger.info); logger.verbose = wrapper(logger.verbose); logger.debug = wrapper(logger.debug); logger.silly = wrapper(logger.silly);
agree, it's the break change.
the meta key in the info object is gone under the new version.
the new key named as the numeric, such as { '0': 'string', '1': 'object'}
Definitely a breaking change. Also the wrapper works in a very limited way.
Most helpful comment
I think this is such a breaking change...
The partial solution is: