Logging a MongoDB ObjectID directly prints binary buffer
See original GitHub issuevar mongodb = require('mongodb');
var oid = new mongodb.ObjectID();
var winston = require('winston');
console.info(oid);
winston.info(oid);
Result:
553753a3e208f62631e6daa8
info: _bsontype=ObjectID, id=U7S£ö&1æÚ¨
This is possibly related to #500, although it was not fixed by it.
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Log Messages — MongoDB Manual
When working with MongoDB structured logging, the third-party jq command-line utility is a useful tool that allows for easy pretty-printing of log entries,...
Read more >nodejs mongodb object id to string - Stack Overflow
Try this: user._id.toString(). A MongoDB ObjectId is a 12-byte UUID can be used as a HEX string representation with 24 chars in length....
Read more >How To Find A MongoDB Document By Its BSON ObjectID ...
This article explains how to find a MongoDB document by the BSON ObjectID using Golang with easy to follow detail and example code....
Read more >Spring Data MongoDB - Reference Documentation
The core functionality of the MongoDB support can be used directly, ... The Spring Data MongoDB 4.x binaries require JDK level 17 and...
Read more >How To Perform CRUD Operations in MongoDB - DigitalOcean
MongoDB is a persistent document-oriented database used to store and process data in the form of documents. As with other database management ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1
using .toString() works but is extremely frustrating. any plans on fixing this?
currently doing stuff like
JSON.parse(JSON.stringify(post))
🙈Is there any solution for this other than patching external lib as @kaetemi said (using latest release of winston)? I log MongoDB-stored object that has some
ObjectID
properties like thisand for these
ObjectID
props I get crap like_bsontype=ObjectID, 0=88, 1=54, 2=212, 3=140, 4=168, 5=147, 6=113, 7=163, 8=107, 9=62, 10=237, 11=253
out 😦I was trying to use rewriters/filters for that but with no luck (cannot reliably detect/rewrite these props)