1.0.2 • Published 1 year ago

sai-sequelize v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

sai-sequelize

sai-sequelize is a Node.js module built on top of Sequelize, designed to automatically capture and store log messages from your application into a MySQL database. It intercepts console logs and errors, making it easier to persist logs for later retrieval and analysis.

Features

  • Easy integration with any Express.js application.
  • Automatically captures and stores console logs and errors in a MySQL database.
  • Provides a simple API to retrieve stored logs for monitoring and debugging.

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Node.js installed on your machine.
  • A MySQL database is accessible.

Installation

Install sai-sequelize using npm:

npm install sai-sequelize

Usage

Here's how to integrate sai-sequelize into your Node.js application:

  1. Initialize sai-sequelize with your database configuration:
const saiSequelize = require('sai-sequelize');

saiSequelize.initialization({
  host: "your_database_host",
  username: "your_database_username",
  password: "your_database_password",
  database: "your_database_name",
  dialect: "mysql" // or another supported dialect
}).catch(err => {
  console.error('Failed to initialize sai-sequelize:', err);
});

Retrieve stored logs

You can retrieve stored logs using the getLogs method. For example, to display logs on an Express route

app.get('/logs', async (req, res) => {
  const logs = await saiSequelize.getLogs();
  res.json(logs);
});

Optionally, intercept standard console logs and errors:

saiSequelize.interceptConsoleLogs();
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago