EDIT : Found the answer, and posted a complete answer for future readers.
I have grasped the basics of winston logging in Node.js, and wish to customize my logging a bit more. Here is what I have so far :
var winston = require('winston');
winston.remove(winston.transports.Console);
winston.add(winston.transports.Console, {'colorize': true});
winston.add(winston.transports.File,
{
'filename': 'testlog.log',
'timestamp': function() {return Date.now();},
}
);
// let's say I only want to log 'info' or 'error'
function loginfo(arg) {return winston.info(arg);}
function logerror(arg) {return winston.error(arg);}
The output file will look like this :
{"level":"info","message":"someinfo","timestamp":1470515515807}
{"level":"error","message":"someerror","timestamp":1470515515808}
I understand the fact that a JSON format standard logging is important, and therefore I want to keep the almost standard file transport as it is.
But since I'm actually reading every line of those logs, I would like to open a third transport to another file, with a completely customized formatting for my eyes only, such as :
1470515515807 info "someinfo"
1470515515808 error "someerror"
1470515519532 error HERE_GOES_SOME_COMPLEX_ERROR_MESSAGE_OR_OBJECT_
I_WANT_TO_SEE_AS_PRETTY_POSSIBLE_DESPITE_THE_FACT_IT_IS_VERY_COMPLEX
I have made some research and it seems there is no such functionnality directly available in winston. I have noticed the fancy bunyan CLI tool but what I want "seems" much more simple.
Questions :
1) Is there no built-in custom output formatting in logging libraries which would meet my requirements ? [Can't believe it]
2) If I have to hard-code it myself, could you give me some directions (best practice to process stdout the way I want without overloading the app itself), especially when it comes to complex objects returned by some errors ?