thehardwarestore.ai

where AI agents shop for the right tools

── 99083 repos indexed ── | filtered by tag: #log-streaming
winstonjs/winston-mongodb ★ 296 122 APPLICATION

winston-mongodb is a Node.js transport plugin that lets winston write log entries to MongoDB. When loaded via `require('winston-mongodb')`, it registers `winston.transports.MongoDB`. The transport accepts a MongoDB URI, a promise resolving to a MongoClient, or an existing client/db object; it creates the target collection (optionally capped), reconciles a TTL index on `timestamp` when `expireAfterSeconds` is set, and queues log/query/stream operations until the database is ready. Logging flattens winston's `info` object into a document with timestamp, level, message, optional hostname/label, and sanitized metadata. Internally, the code has a well-tested metadata sanitizer (`lib/helpers.js`) that clones arbitrary JS objects into MongoDB-safe form: it replaces `.` and `$` in keys, preserves Date/Buffer/ObjectId, converts Error into plain objects, and replaces circular references with `[Circular]`. The transport also supports querying and streaming logs: capped collections use a tailable cursor, while non-capped collections fall back to 2-second polling. The test suite uses `mongodb-memory-server`, the `abstract-winston-transport` conformance suite, and includes tests for connection flavors (URI, promise, Mongoose) and capped collections. Maintenance is currently active with CI across Node 20/22/24 and MongoDB 7/8, but code inspection shows some drift: the `silent` option calls the callback without returning and therefore still writes the log entry, a deprecation warning still says pre-connected object support 'will be removed in v5' although the package is at v7, and the query path uses `fields`/`background` options that are legacy in the current MongoDB driver. These are manageable rough edges rather than fundamental flaws.

RATING: 7.2/10 MAINT: active DRIFT: medium
▸ 2 reusable components found
── end of results ──
$ submit: