sai-mongodb
v1.3.0
Published
A MongoDB logging module for Node.js applications that automatically captures all logs
Downloads
6
Readme
sai-mongodb
A MongoDB logging module for Node.js applications, designed to simplify logging of information and errors to a MongoDB database. This module provides an easy way to log messages from your Node.js applications and retrieve them for monitoring or debugging purposes.
Features
Easy integration with Node.js applications. Configurable MongoDB connection. Supports logging of information and error messages. Provides a function to retrieve all logs from the database.
installation
install sai-mongod using npm
npm install sai-mongodb
usage
First, ensure you have MongoDB running and accessible from your application. Then, follow these steps to integrate sai-mongodb into your Node.js application.
initialization
In your main application file, initialize the sai-mongodb module with the MongoDB connection details:
const saiMongodb = require('sai-mongodb');
const storage = new saiMongodb(mongoUrl,dbname)
Retriveing Logs
To retrieve and display all logged messages, you might create a route in your Express application:
app.get('/logs', async (req, res) => {
const logs = await saiMongodb.getLogs();
res.json(logs);
});