flatiron/winston — Issue #76: Formatting difference between console and file...
Author: crazyfrog
Created: 2011-12-14 11:27:28+00:00
State: open

Hi

How my custom logger is defined:

var customLevels = {
levels: {
trace: 0,
debug: 1,
info: 2,
warn: 3,
error: 4,
fatal: 5
},
colors: {
trace: "blue",
debug: "grey",
info: "white",
warn: "magenta",
error: "red",
fatal: "red"
}
};
winston.addColors(customLevels.colors);

var logger = new (winston.Logger)({
levels: customLevels.levels,
exitOnError: false,
transports: [
new winston.transports.Console({
level: "debug",
silent: false,
colorize: true,
timestamp: true }),

new winston.transports.File({
level: "debug",
silent: false,
colorize: true,
timestamp: true,
filename: "../logs/generic.log",
maxsize: 5000,
maxFiles: 5 })
],
exceptionHandlers: [
new winston.transports.File({
level: "debug",
silent: false,
colorize: true,
timestamp: true,
filename: "../logs/error.log",
maxSize: 5000,
maxFiles: 3})
]
});

Logging the following:
logger.debug("Received [" + util.inspect(msg, true, null) + "].");

shows (in console)
14 Dec 11:04:45 - debug: Received [{ _queryId: 1, _workerId: 1, cmd: 'online' }].

shows (in generic.log)
{"level":"debug","message":"Received [{ _queryId: 1, _workerId: 1, cmd: 'online' }].","timestamp":"14 Dec 11:04:45"}

I don't understand the different format of the entry. I was expecting to see the same entry in both console and file.
Is that meant to be like that?