-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Please tell us about your environment:
-
winstonversion? 3.1.0-
winston@2 -
winston@3
-
-
node -voutputs: v8.11.3 -
Operating System? Linux
-
Language? all
What is the problem?
logger.error called with Error instance doesn't use message and stack fields, instead logs test error.
Code example:
const winston = require('winston');
const alignedWithColorsAndTime = winston.format.combine(
// winston.format.colorize({ all: true }),
// winston.format.timestamp(),
// winston.format.align(),
winston.format.printf((info) => {
const { level, message, ...args } = info;
if (level.indexOf('error') !== -1) {
console.log(typeof message, JSON.stringify(message));
}
return `[${level}]: ${message} ${Object.keys(args).length ? JSON.stringify(args, null, 2) : ''}`;
})
);
const transports = [new winston.transports.Console({
level: 'debug',
format: alignedWithColorsAndTime
})];
const logger = winston.createLogger({
level: 'debug',
transports
});
try {
logger.info('aaaaa');
logger.debug('bbbb');
logger.error('eeee');
throw new Error('Scary error');
} catch (error) {
logger.error(error);
}
What do you expect to happen instead?
At least actual error message logged. Ideally - with stack.
jeremy-j-ackso, siddjain, iki, gfranco93, alexis-aquanty and 4 more
Metadata
Metadata
Assignees
Labels
No labels