errsole
repository·master·Indexed 20 days ago
https://github.com/errsole/errsole.jsA comprehensive logging solution for Node.js (v2.18.2) that collects, stores, and visualizes logs via a built-in Web Dashboard. It supports multiple storage backends including SQLite, MySQL, PostgreSQL, and MongoDB, and provides integrations for Slack and Email notifications. The module includes specialized logging functions (log, alert, error, warn, debug) and a .meta() method for attaching contextual metadata to logs.
What's inside errsole
- Errsole is an open-source logging module for Node.js applications designed to collect, store, and visualize logs. It provides a built-in Web Dashboard (Log Viewer) for filtering and searching logs, supports multiple storage backends (SQLite, MySQL, PostgreSQL, MongoDB), and includes features for critical error notifications and advanced metadata logging.
Errsole Performance Benchmarks vs Elasticsearch and CloudWatch
masterErrsole is designed for high-performance logging and can be used with various storage backends including SQLite, MySQL, PostgreSQL, and MongoDB.
Elasticsearch Comparison
In benchmarks comparing Errsole against Elasticsearch-based logging (using Winston or Pino), Errsole demonstrated a significant performance advantage, handling approximately 70,000 - 90,000 more requests per minute.
Amazon CloudWatch Comparison
Errsole significantly outperforms direct Amazon CloudWatch configurations and Pino + CloudWatch setups. In tests, Errsole handled 280,000 - 300,000 more requests per minute than direct CloudWatch and 40,000 - 70,000 more requests per minute than Pino + CloudWatch. Notably, Winston + CloudWatch configurations failed in the tested scenarios.
Average Requests Per Minute (Benchmark Results)
Configuration Avg Requests/Min Errsole + SQLite ~364,269 Errsole + PostgreSQL ~364,144 Errsole + MySQL ~350,758 Errsole + MongoDB ~339,128 Pino + Elasticsearch ~265,227 Winston + Elasticsearch ~271,761 Pino + CloudWatch ~295,133 CloudWatch (Direct) ~54,868 Integrate the Errsole Web Dashboard using Proxy Middleware
masterIf you want to host the Errsole Web Dashboard as a route within your existing application instead of running it as a separate service, you can use the Errsole Proxy Middleware. This middleware maps a specific route in your main application to the Errsole dashboard interface.Install Errsole with MongoDB storage
masterTo use MongoDB as your storage backend for Errsole, install both the core
errsolepackage and theerrsole-mongodbadapter using npm.npm install errsole errsole-mongodbInstall Winston and Errsole dependencies
masterTo set up the Winston integration, you need to install
winston,winston-errsole,errsole, and a storage provider (e.g.,errsole-sqlite).# Install Winston and the transport npm install winston winston-errsole # Install Errsole and a storage engine npm install errsole errsole-sqliteIntegrate the Errsole Web Dashboard via Proxy Middleware
masterTo host the Errsole Web Dashboard as a route within your existing application, use the Errsole Proxy Middleware. This allows you to access the dashboard using your application's domain (e.g.,
https://api.example.com/errsole).Critical Requirements:
- Mandatory Path: You must specify a path where the dashboard will be accessible.
- Middleware Order: The Errsole Proxy Middleware must be the first middleware in your application. All other middlewares (like body parsers or routers) must be placed after it.
- Custom Paths: If you have initialized Errsole with a custom path, you must append that custom path to the middleware path registration.
Configure NGINX to proxy the Errsole Web Dashboard
masterIf your application is behind an NGINX reverse proxy, add the following configuration to map a specific URL path to the Errsole Web Dashboard (defaulting to port 8001):
location = /your-app-name/logs { return 301 /your-app-name/logs/; } location /your-app-name/logs/ { proxy_pass http://localhost:8001/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }Note: Replace
/your-app-name/logswith your desired path. After updating, reload NGINX usingsudo nginx -s reload.Configure NGINX for the Errsole Web Dashboard
masterIf your application is behind an NGINX reverse proxy, add a location block to your NGINX configuration to proxy requests to the Errsole dashboard (default port
8001).Replace
/your-app-name/logswith your preferred URL path.location = /your-app-name/logs { return 301 /your-app-name/logs/; } location /your-app-name/logs/ { proxy_pass http://localhost:8001/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }After updating, reload NGINX using
sudo nginx -s reload.Configure the Errsole logger with MongoDB
masterInitialize Errsole by creating a dedicated
logger.jsfile. This ensures the logger is a singleton that can be easily imported throughout your application. TheErrsoleMongoDBconstructor accepts a connection URL, an optional database name, and an optional object for MongoDB client options (such ascollectionPrefix).// CommonJS const errsole = require('errsole'); const ErrsoleMongoDB = require('errsole-mongodb'); errsole.initialize({ storage: new ErrsoleMongoDB( 'mongodb-connection-url', 'optional-database-name', { collectionPrefix: 'your-app-name' } ), appName: 'your-app-name' }); module.exports = errsole;Initialize Errsole with ErrsolePostgres
masterInitialize Errsole by passing a new instance of
ErrsolePostgresto thestorageoption withinerrsole.initialize(). You must provide connection details such ashost,user,password,database, andtablePrefix.errsole-postgresuses thepgpackage, so it supports all standard PostgreSQL connection options provided by thenode-postgresclient.import errsole from 'errsole'; import ErrsolePostgres from 'errsole-postgres'; errsole.initialize({ storage: new ErrsolePostgres({ host: 'postgres-host', user: 'database-user', password: 'database-password', database: 'database-name', tablePrefix: 'app-name', }), appName: 'app-name' }); export default errsole;Configure the Errsole MySQL logger
masterInitialize Errsole by providing a
new ErrsoleMySQL()instance to thestorageoption. You must provide connection details such ashost,user,password,database, andtablePrefix.errsole-mysqluses themysql2package, so it supports all standard MySQL connection options for advanced configuration.const errsole = require('errsole'); const ErrsoleMySQL = require('errsole-mysql'); errsole.initialize({ storage: new ErrsoleMySQL({ host: 'mysql-host', user: 'database-user', password: 'database-password', database: 'database-name', tablePrefix: 'app-name' }), appName: 'app-name' }); module.exports = errsole;Install Errsole with MySQL storage
masterTo use MySQL as a storage backend for Errsole, install both the core
errsolepackage and theerrsole-mysqladapter using npm.npm install errsole errsole-mysql