vendredi 6 mars 2015

winston logger not serializing mongodb.ObjectID

I want to finally move away from console.log as a logging system and have been looking into both winston and bunyan. I have a slight preference for winston as for now I want human readable logs in longentries, and bunyan is a bit too chatty with all the extra fields.


winston is great except that it doesn't properly serialize mongo database ids.


If I do something like this:



var ObjectId = require('mongodb').ObjectID;
var winston = require('winston');
winston.info(new ObjectId());


This is what gets written to stdout:



info: _bsontype=ObjectID, id=Tø½þjÍrßgK



Sometimes I just want to dump an entire mongoose document to the log. I don't want to have to call .toString() on all my object ids?


Has anyone been able to work around this problematic scenario in winston?


Aucun commentaire:

Enregistrer un commentaire