Registry / testing / errsole-mongodb

errsole-mongodb

JSON →
library3.0.0jsnpmunverified

MongoDB storage plugin for Errsole, a Node.js logger with a built-in web dashboard. Version 3.0.0 is the current stable release. This plugin enables storing and querying application logs in MongoDB, making it ideal for apps already using MongoDB. Compared to other storage backends (e.g., file-based or SQLite), it offers seamless integration with existing MongoDB infrastructure, scalability, and the ability to leverage MongoDB's aggregation framework for advanced log analysis.

npm install errsole-mongodb
INSTALL
IMPORT
SIG · ERRSOLE-MONGODB
E
errsole-mongodb
testingjavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ErrsoleMongoDB
import { ErrsoleMongoDB } from 'errsole-mongodb';
const ErrsoleMongoDB = require('errsole-mongodb'); // Wrong for ESM projects; CJS require also works but ESM is recommended for TypeScript
The primary export is a named export, not default. TypeScript types bundled. For CommonJS, use require('errsole-mongodb').ErrsoleMongoDB.
Errsole (core)
import Errsole from 'errsole';
const Errsole = require('errsole'); // Works in CommonJS but not tree-shakeable; ESM import is preferred
Errsole core must be imported separately. errsole-mongodb only provides the storage backend for Errsole.

Shows how to initialize Errsole with the MongoDB storage plugin, create a logger, and log info and error messages.

import Errsole from 'errsole'; import { ErrsoleMongoDB } from 'errsole-mongodb'; // Initialize Errsole with MongoDB storage const logger = Errsole.init({ storage: new ErrsoleMongoDB({ uri: process.env.MONGO_URI ?? 'mongodb://localhost:27017/errsole', dbName: 'errsole_logs', collectionName: 'logs' }), appName: 'my-app', enableDashboard: true }); // Log messages logger.info('Application started'); try { throw new Error('Sample error'); } catch (err) { logger.error(err.message, { error: err }); }
Debug
Known issues
breakingVersion 3.x drops support for Mongoose 5.x. Minimum Mongoose version is 6.0.0.
fix
Update Mongoose dependency to 6.0.0 or higher.
affects: >=3.0.0
deprecatedThe `connectionOptions` constructor parameter is deprecated. Use `mongooseOptions` instead.
fix
Rename 'connectionOptions' to 'mongooseOptions' in the configuration object.
affects: >=3.0.0
gotchaIf MongoDB connection fails, Errsole will silently fall back to an in-memory store. Ensure MongoDB is reachable on startup.
fix
Use the 'storageError' event on the logger to detect connection issues: logger.on('storageError', (err) => console.error(err)).
affects: >=2.0.0
Errors
Common errors & fixes
MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
Missing or undefined MONGO_URI environment variable.
fix
Set MONGO_URI environment variable or pass a fallback URI string when initializing ErrsoleMongoDB.
Error: Cannot find module 'errsole-mongodb'
Package not installed.
fix
Run: npm install errsole-mongodb
TypeError: ErrsoleMongoDB is not a constructor
Using default import instead of named import.
fix
Change to: import { ErrsoleMongoDB } from 'errsole-mongodb';
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
errsolerequirederrsole is the core logger framework that provides the web dashboard and logging interface. The MongoDB plugin is only functional when used with errsole.
mongooserequiredUsed internally for MongoDB schema modeling and connection management.
Agent activity
4 hits · last 30 days
node
4
Resources
errsole-mongodb — npm install errsole-mongodb · libregistry