### Complete Errsole SQLite Logger Configuration Example Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md This example provides a full, runnable setup for Errsole with SQLite, showing how to configure the logger to store logs in a temporary file. It leverages Node.js's `os` and `path` modules to construct a platform-independent temporary file path. ```javascript import errsole from 'errsole'; import ErrsoleSQLite from 'errsole-sqlite'; import os from 'os'; import path from 'path'; const logFile = path.join(os.tmpdir(), 'helloworld.log.sqlite'); errsole.initialize({ storage: new ErrsoleSQLite(logFile), appName: 'helloworld' }); export default errsole; ``` -------------------------------- ### Initialize Errsole with Core Configuration Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Demonstrates how to initialize the Errsole library, configuring essential parameters such as storage, log collection settings, dashboard enablement, and application metadata. This setup is crucial for Errsole's basic operation. ```javascript errsole.initialize({ storage: new ErrsoleMySQL(options), exitOnException: true, collectLogs: ['error', 'info'], enableConsoleOutput: true, enableDashboard: true, port: 8001, path: '/', appName: 'your-app-name', environmentName: 'your-environment-name', serverName: 'your-server-name' }); ``` -------------------------------- ### Install Errsole and MySQL Storage Modules Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md This command installs the core Errsole library and its MySQL storage module using npm, preparing your Node.js project for MySQL-backed logging. ```bash npm install errsole errsole-mysql ``` -------------------------------- ### Initialize Errsole with Core and Server Name Options Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md Example of initializing Errsole with essential configuration options such as storage, exception handling, log collection, dashboard settings, and specifically setting a custom server name. This setup is fundamental for basic Errsole operation and identification. ```javascript errsole.initialize({ storage: new ErrsoleSQLite(logFile), exitOnException: true, collectLogs: ['error', 'info'], enableConsoleOutput: true, enableDashboard: true, port: 8001, path: '/', appName: 'your-app-name', environmentName: 'your-environment-name', serverName: 'your-server-name' }); ``` -------------------------------- ### Install Errsole and PostgreSQL storage modules Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md Run this command to install the Errsole core library and the `errsole-postgres` storage module into your Node.js project using npm. These modules are essential for setting up Errsole with PostgreSQL. ```bash npm install errsole errsole-postgres ``` -------------------------------- ### Integrate Errsole Logger into an Express Application Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Demonstrates how to import and use the configured Errsole logger within an Express.js application. The example shows basic server setup and logging a message upon application startup, illustrating how to incorporate Errsole into your existing codebase. ```javascript import express from 'express'; import errsole from './logger.js'; const app = express(); app.get('/', (req, res) => { res.send('Hello World!'); }); const port = 3000; app.listen(port, () => { errsole.log(`Hello World app is listening on port ${port}`); }); ``` -------------------------------- ### Install Errsole and MongoDB Storage Modules Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This command installs the core Errsole library and its MongoDB storage module, `errsole-mongodb`, into your Node.js project using npm. ```bash npm install errsole errsole-mongodb ``` -------------------------------- ### Install Errsole and Errsole-SQLite Modules Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md This command installs the core `errsole` library and the `errsole-sqlite` storage module from npm. These packages are essential for enabling application logging with SQLite as the data store in your Node.js project. ```bash npm install errsole errsole-sqlite ``` -------------------------------- ### Errsole Initialization Configuration Options Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md Comprehensive documentation for the `errsole.initialize` method's configuration options, including core settings, email integration, and Slack integration parameters. ```APIDOC errsole.initialize(options: object) Options: serverName: string - Optional. Default: the hostname of the machine. Specify the name of the server. integrations.email: object - Optional. SMTP configuration object for sending email notifications. - Properties: host: string (Required) - SMTP host or IP address. port: number (Required) - SMTP port number. username: string (Required) - SMTP username. password: string (Required) - SMTP password. sender: string (Required) - Email address from which notifications are sent. recipients: string[] (Required) - List of email addresses to receive notifications. integrations.slack: object - Optional. Slack configuration object. - Properties: url: string (Required) - Slack Webhook URL for sending notifications. ``` -------------------------------- ### Integrate Errsole logger into an Express.js application Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md This example shows how to import the configured Errsole logger into an Express.js application and use it to log a message when the server successfully starts listening on a specified port. This demonstrates basic logging functionality within your application code. ```javascript import express from 'express'; import errsole from './logger.js'; const app = express(); app.get('/', (req, res) => { res.send('Hello World!'); }); const port = 3000; app.listen(port, () => { errsole.log(`Hello World app is listening on port ${port}`); }); ``` -------------------------------- ### Errsole Initialization Options (errsole.initialize) Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Comprehensive documentation for all configuration options available when initializing the Errsole library. This includes core settings, storage, logging behavior, dashboard settings, and integration options for email and Slack notifications. ```APIDOC errsole.initialize(options: object) - Initializes the Errsole library with specified configurations. Options Object Properties: - storage: ErrsoleMySQL | ErrsoleMongoDB | ErrsolePostgreSQL | ErrsoleSQLite (Required) - Description: Specifies the database storage adapter to use. - Type: Object (e.g., new ErrsoleMySQL(options)) - exitOnException: boolean (Optional) Default: true - Description: If true, Errsole will exit the process on uncaught exceptions. - Type: boolean - collectLogs: string[] (Optional) Default: ['error'] - Description: An array of log levels to collect (e.g., 'error', 'info', 'warn', 'debug', 'alert'). - Type: string[] - enableConsoleOutput: boolean (Optional) Default: true - Description: If true, Errsole will output collected logs to the console. - Type: boolean - enableDashboard: boolean (Optional) Default: true - Description: If true, enables the Errsole Web Dashboard. - Type: boolean - port: number (Optional) Default: 8001 - Description: The port for the Errsole Web Dashboard. - Type: number - path: string (Optional) Default: '/' - Description: The base path for the Errsole Web Dashboard. - Type: string - appName: string (Optional) Default: 'your-app-name' - Description: A unique name for your application. - Type: string - environmentName: string (Optional) Default: 'development' - Description: The name of the current environment (e.g., 'production', 'staging'). - Type: string - serverName: string (Optional) Default: hostname of the machine - Description: The name of the server instance. - Type: string - integrations: object (Optional) - Description: Configuration for external integrations. - Type: Object - integrations.email: object (Optional) - Description: SMTP configuration for sending email notifications. - Type: Object - integrations.email.host: string (Required) - Description: SMTP host or IP address. - Type: string - integrations.email.port: number (Required) - Description: SMTP port number. - Type: number - integrations.email.username: string (Required) - Description: SMTP username. - Type: string - integrations.email.password: string (Required) - Description: SMTP password. - Type: string - integrations.email.sender: string (Required) - Description: Email address from which notifications are sent. - Type: string - integrations.email.recipients: string[] (Required) - Description: List of email addresses to receive notifications. - Type: string[] - integrations.slack: object (Optional) - Description: Slack configuration object. - Type: Object - integrations.slack.url: string (Required) - Description: Slack Webhook URL for sending notifications. - Type: string ``` -------------------------------- ### Configure errsole.js Initialization with Server Settings Source: https://github.com/errsole/errsole.js/blob/master/docs/advanced-configuration.md This JavaScript example demonstrates how to initialize the errsole.js library, setting up storage, logging behavior, dashboard options, and server-specific parameters like `appName`, `environmentName`, and `serverName`. ```javascript errsole.initialize({ storage: new ErrsoleSQLite(logsFile), exitOnException: true, collectLogs: ['error', 'info'], enableConsoleOutput: true, enableDashboard: true, port: 8001, path: '/', appName: 'your-app-name', environmentName: 'your-environment-name', serverName: 'your-server-name' }); ``` -------------------------------- ### Integrate Errsole Logger into an Express Application Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This example illustrates how to import and utilize the Errsole logger within a typical Express.js application. It shows a basic server setup and demonstrates logging a message upon application startup. ```javascript import express from 'express'; import errsole from './logger.js'; const app = express(); app.get('/', (req, res) => { res.send('Hello World!'); }); const port = 3000; app.listen(port, () => { errsole.log(`Hello World app is listening on port ${port}`); }); ``` -------------------------------- ### Install Errsole and Errsole SQLite storage Source: https://github.com/errsole/errsole.js/blob/master/docs/winston-errsole.md Installs the main Errsole library and the `errsole-sqlite` storage module using npm. These are necessary for Errsole to receive and persist logs. ```bash npm install errsole errsole-sqlite ``` -------------------------------- ### Initialize Errsole with Core Configuration Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md This snippet demonstrates the basic initialization of the Errsole.js library, setting up storage, log collection, dashboard enablement, and application metadata. It configures essential parameters like `appName`, `environmentName`, and `serverName` for application identification and logging. ```javascript errsole.initialize({ storage: new ErrsolePostgres(options), exitOnException: true, collectLogs: ['error', 'info'], enableConsoleOutput: true, enableDashboard: true, port: 8001, path: '/', appName: 'your-app-name', environmentName: 'your-environment-name', serverName: 'your-server-name' }); ``` -------------------------------- ### Errsole Initialization Configuration Options Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md Comprehensive documentation for all available configuration options when initializing the Errsole.js library. This includes core application settings, server identification, and detailed parameters for integrating email and Slack for critical error notifications. ```APIDOC errsole.initialize(options: Object) options: storage: ErrsolePostgres | ErrsoleMongo | ... - Required. The storage adapter to use (e.g., ErrsolePostgres). exitOnException: boolean - Optional. Default: false. If true, the application exits on uncaught exceptions. collectLogs: string[] - Optional. Array of log levels to collect (e.g., ['error', 'info']). enableConsoleOutput: boolean - Optional. Default: true. If true, logs are also output to the console. enableDashboard: boolean - Optional. Default: true. If true, enables the Errsole Web Dashboard. port: number - Optional. Default: 8001. Port for the Errsole Web Dashboard. path: string - Optional. Default: '/'. Base path for the Errsole Web Dashboard. appName: string - Required. The name of your application. environmentName: string - Optional. Default: 'development'. The name of the environment (e.g., 'production', 'staging'). serverName: string - Optional. Default: the hostname of the machine. Specify the name of the server. integrations: Object - Optional. Configuration for third-party integrations. integrations.email: Object - Optional. SMTP configuration object for sending email notifications. host: string - Required. SMTP host or IP address. port: number - Required. SMTP port number. username: string - Required. SMTP username. password: string - Required. SMTP password. sender: string - Required. Email address from which notifications are sent. recipients: string[] - Required. List of email addresses to receive notifications. integrations.slack: Object - Optional. Slack configuration object. url: string - Required. Slack Webhook URL for sending notifications. ``` -------------------------------- ### Configure Errsole Logger with MongoDB Storage Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This snippet demonstrates how to initialize the Errsole logger, configuring it to use `errsole-mongodb` for persistent storage. It includes examples for a generic setup, CommonJS, and ESM/TypeScript module systems, specifying MongoDB connection details and optional client options. ```javascript errsole.initialize({ storage: new ErrsoleMongoDB( '', '', {} ) }); ``` ```javascript 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; ``` ```javascript // ESM and TypeScript import errsole from 'errsole'; import ErrsoleMongoDB from 'errsole-mongodb'; errsole.initialize({ storage: new ErrsoleMongoDB( 'mongodb-connection-url', 'optional-database-name', { collectionPrefix: 'your-app-name' } ), appName: 'your-app-name' }); export default errsole; ``` -------------------------------- ### Errsole Initialization Configuration Options Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md Comprehensive documentation for various configuration options available when initializing Errsole, including server identification, email integration for notifications, and Slack integration. These options allow tailoring Errsole's behavior and notification channels. ```APIDOC serverName: type: string description: Optional. Default: the hostname of the machine. Specify the name of the server. integrations.email: type: Object description: Optional. SMTP configuration object for sending email notifications. integrations.email.host: type: string description: Required. SMTP host or IP address. integrations.email.port: type: number description: Required. SMTP port number. integrations.email.username: type: string description: Required. SMTP username. integrations.email.password: type: string description: Required. SMTP password. integrations.email.sender: type: string description: Required. Email address from which notifications are sent. integrations.email.recipients: type: string[] description: Required. List of email addresses to receive notifications. integrations.slack: type: Object description: Optional. Slack configuration object. integrations.slack.url: type: string description: Required. Slack Webhook URL for sending notifications. ``` -------------------------------- ### Configure errsole.js Initialization with Slack Integration Source: https://github.com/errsole/errsole.js/blob/master/docs/advanced-configuration.md This JavaScript example illustrates how to set up Slack integration during errsole.js initialization. It requires a Slack Webhook URL for sending critical error notifications. ```javascript errsole.initialize({ storage: new ErrsoleSQLite(logsFile), appName: 'your-app-name', integrations: { slack: { url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' } } }); ``` -------------------------------- ### Install Winston and winston-errsole transport Source: https://github.com/errsole/errsole.js/blob/master/docs/winston-errsole.md Installs the core Winston logging library and the `winston-errsole` transport module using npm. These packages are required to set up Winston logging with Errsole integration. ```bash npm install winston winston-errsole ``` -------------------------------- ### Errsole.js Configuration Options Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md This section details the available configuration options for the Errsole.js library, allowing users to customize its behavior, including storage backend, log collection, dashboard settings, and application identification. ```APIDOC Configuration Option: storage Type: ErrsoleSQLite | ErrsoleMySQL | ErrsolePostgres | ErrsoleMongoDB Description: Required. Specify the storage backend along with connection details. Configuration Option: exitOnException Type: boolean Description: Optional. Default: true. By default, Errsole exits the process after capturing an uncaught exception. To disable this behavior, set exitOnException to false. Configuration Option: collectLogs Type: string[] Description: Optional. Default: ['error', 'info']. By default, Errsole collects both error and info logs. To collect only error logs, set this to ['error']. To disable log collection entirely, set this to an empty array, []. Configuration Option: enableConsoleOutput Type: boolean Description: Optional. Control whether log output is shown in the console. Configuration Option: enableDashboard Type: boolean Description: Optional. Default: true. Enable or disable the web dashboard feature. Configuration Option: port Type: number Description: Optional. Default: 8001. Specify the network port for the web dashboard. Configuration Option: path Type: string Description: Optional. Default: /. Define the base path for accessing the web dashboard. Configuration Option: appName Type: string Description: Optional. Specify the name of the app. Configuration Option: environmentName Type: string Description: Optional. Default: process.env.NODE_ENV. Specify the deployment environment. ``` -------------------------------- ### Utilize Errsole Advanced Logging Functions Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md Shows examples of Errsole's advanced logging functions, including `log`, `alert`, `error`, `warn`, `debug`, and `meta`. These functions allow developers to log messages at different severity levels and attach additional metadata for richer context. ```javascript errsole.log('Logging a message'); errsole.alert('Alert! Something critical happened'); errsole.error(new Error('An error occurred')); errsole.warn('This is a warning message'); errsole.debug('Debugging information'); errsole.meta({ reqBody: req.body, queryResults: results }).error(err); ``` -------------------------------- ### Initialize Errsole with Email Notification Integration Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md This example shows how to configure Errsole to send critical error notifications via email. It integrates SMTP settings directly into the `initialize` call, specifying host, port, credentials, sender, and recipient lists for automated alerts. ```javascript errsole.initialize({ storage: new ErrsolePostgres(options), appName: 'your-app-name', integrations: { email: { host: 'smtp.example.com', port: 587, username: 'your-smtp-username', password: 'your-smtp-password', sender: 'notifications@example.com', recipients: ['dev1@example.com', 'dev2@example.com'] } } }); ``` -------------------------------- ### Initialize Errsole logger with PostgreSQL storage Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md This snippet demonstrates how to initialize the Errsole logger to use `errsole-postgres` as its storage backend. It includes examples for both CommonJS and ESM/TypeScript module systems. Remember to replace placeholder values for host, user, password, database, and app name with your actual PostgreSQL credentials and application details. ```javascript const errsole = require('errsole'); const ErrsolePostgres = require('errsole-postgres'); errsole.initialize({ storage: new ErrsolePostgres({ host: 'postgres-host', // Replace with your actual PostgreSQL host user: 'database-user', // Replace with your actual PostgreSQL user password: 'database-password', // Replace with your actual PostgreSQL password database: 'database-name', // Replace with the name of your PostgreSQL database, tablePrefix: 'app-name', // Replace with your actual app name }), appName: 'app-name' // Replace with your actual app name }); module.exports = errsole; ``` ```javascript import errsole from 'errsole'; import ErrsolePostgres from 'errsole-postgres'; errsole.initialize({ storage: new ErrsolePostgres({ host: 'postgres-host', // Replace with your actual PostgreSQL host user: 'database-user', // Replace with your actual PostgreSQL user password: 'database-password', // Replace with your actual PostgreSQL password database: 'database-name', // Replace with the name of your PostgreSQL database, tablePrefix: 'app-name', // Replace with your actual app name }), appName: 'app-name' // Replace with your actual app name }); export default errsole; ``` -------------------------------- ### Initialize Errsole with Basic Configuration Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This snippet demonstrates how to initialize Errsole with fundamental settings such as storage, exception handling, log collection levels, console output, dashboard enablement, port, path, application name, environment name, and server identification. ```javascript errsole.initialize({ storage: new ErrsoleMongoDB(options), exitOnException: true, collectLogs: ['error', 'info'], enableConsoleOutput: true, enableDashboard: true, port: 8001, path: '/', appName: 'your-app-name', environmentName: 'your-environment-name', serverName: 'your-server-name' }); ``` -------------------------------- ### Configure Errsole with Slack Notification Integration Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md Illustrates initializing Errsole with Slack integration, providing the necessary webhook URL for sending critical error notifications to a Slack channel. This setup allows teams to receive real-time alerts in their Slack workspace. ```javascript errsole.initialize({ storage: new ErrsoleSQLite(logFile), appName: 'your-app-name', integrations: { slack: { url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' } } }); ``` -------------------------------- ### Utilize Errsole Advanced Logging Functions Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md This example showcases Errsole's advanced logging capabilities, allowing developers to categorize messages by severity (log, alert, error, warn, debug). It also demonstrates how to attach metadata to log entries for richer context, such as request body or query results. ```javascript errsole.log('Logging a message'); errsole.alert('Alert! Something critical happened'); errsole.error(new Error('An error occurred')); errsole.warn('This is a warning message'); errsole.debug('Debugging information'); errsole.meta({ reqBody: req.body, queryResults: results }).error(err); ``` -------------------------------- ### Errsole Application Configuration Options Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md This section details the available configuration options for the Errsole application, covering aspects like storage backend, exception handling, log collection, and web dashboard settings. These options are typically set during application initialization to customize its behavior. ```APIDOC Configuration Options: Option: storage Type: [ErrsoleSQLite|ErrsoleMySQL|ErrsolePostgres|ErrsoleMongoDB] Description: Required. Specify the storage backend along with connection details. Option: exitOnException Type: boolean Description: Optional. Default: true. By default, Errsole exits the process after capturing an uncaught exception. To disable this behavior, set exitOnException to false. Option: collectLogs Type: string[] Description: Optional. Default: ['error', 'info']. By default, Errsole collects both error and info logs. To collect only error logs, set this to ['error']. To disable log collection entirely, set this to an empty array, []. Option: enableConsoleOutput Type: boolean Description: Optional. Control whether log output is shown in the console. Option: enableDashboard Type: boolean Description: Optional. Default: true. Enable or disable the web dashboard feature. Option: port Type: number Description: Optional. Default: 8001. Specify the network port for the web dashboard. Option: path Type: string Description: Optional. Default: /. Define the base path for accessing the web dashboard. Option: appName Type: string Description: Optional. Specify the name of the app. Option: environmentName Type: string Description: Optional. Default: process.env.NODE_ENV. Specify the deployment environment. ``` -------------------------------- ### Integrate Errsole Logger into an Express Application Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md This snippet illustrates how to import and utilize the pre-configured Errsole logger within a simple Express.js application. It demonstrates a basic Express server setup that logs a message to Errsole upon successful startup. ```javascript import express from 'express'; import errsole from './logger.js'; const app = express(); app.get('/', (req, res) => { res.send('Hello World!'); }); const port = 3000; app.listen(port, () => { errsole.log(`Hello World app is listening on port ${port}`); }); ``` -------------------------------- ### Configure Errsole Slack Notifications Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Shows how to set up Slack notifications within Errsole's initialization. By providing a Slack Webhook URL, Errsole can post critical error alerts directly to a designated Slack channel. ```javascript errsole.initialize({ storage: new ErrsoleMySQL(options), appName: 'your-app-name', integrations: { slack: { url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' } } }); ``` -------------------------------- ### Configure Errsole Email Notifications Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This example illustrates how to integrate SMTP email settings into Errsole's initialization for critical error notifications. It includes parameters for host, port, username, password, sender email, and a list of recipient email addresses. ```javascript errsole.initialize({ storage: new ErrsoleMongoDB(options), appName: 'your-app-name', integrations: { email: { host: 'smtp.example.com', port: 587, username: 'your-smtp-username', password: 'your-smtp-password', sender: 'notifications@example.com', recipients: ['dev1@example.com', 'dev2@example.com'] } } }); ``` -------------------------------- ### Initialize Errsole with Slack Notification Integration Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md This snippet demonstrates configuring Errsole to send critical error notifications to Slack. It integrates the Slack Webhook URL directly into the `initialize` call, enabling automated alerts to a specified Slack channel. ```javascript errsole.initialize({ storage: new ErrsolePostgres(options), appName: 'your-app-name', integrations: { slack: { url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' } } }); ``` -------------------------------- ### Errsole Application Configuration Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md Defines the configurable parameters for the Errsole application, allowing users to customize its behavior, integrate with different storage solutions, manage logging, and control the web dashboard. ```APIDOC Errsole Configuration Options: storage: [ErrsoleSQLite|ErrsoleMySQL|ErrsolePostgres|ErrsoleMongoDB] - Required. Specify the storage backend along with connection details. exitOnException: boolean - Optional. Default: true. By default, Errsole exits the process after capturing an uncaught exception. To disable this behavior, set exitOnException to false. collectLogs: string[] - Optional. Default: ['error', 'info']. By default, Errsole collects both error and info logs. To collect only error logs, set this to ['error']. To disable log collection entirely, set this to an empty array, []. enableConsoleOutput: boolean - Optional. Control whether log output is shown in the console. enableDashboard: boolean - Optional. Default: true. Enable or disable the web dashboard feature. port: number - Optional. Default: 8001. Specify the network port for the web dashboard. path: string - Optional. Default: /. Define the base path for accessing the web dashboard. appName: string - Optional. Specify the name of the app. environmentName: string - Optional. Default: process.env.NODE_ENV. Specify the deployment environment. ``` -------------------------------- ### Reload NGINX Configuration Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md This command reloads the NGINX configuration, applying any changes made to the NGINX configuration file without restarting the server, ensuring continuous service availability. ```bash sudo nginx -s reload ``` -------------------------------- ### Configure NGINX for Errsole Web Dashboard Access Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Provides NGINX configuration directives to proxy requests to the Errsole Web Dashboard, allowing access through a custom URL path on your domain. This setup ensures the dashboard is accessible when your application is behind an NGINX reverse proxy. ```nginx 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"; } ``` -------------------------------- ### Reload NGINX to apply configuration changes Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md Execute this command to gracefully reload the NGINX server, applying any new configuration changes without interrupting active connections. This step is necessary after modifying your NGINX configuration file. ```bash sudo nginx -s reload ``` -------------------------------- ### Errsole Application Configuration Reference Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md Defines the available configuration parameters for the Errsole application, including settings for storage, exception handling, log collection, console output, web dashboard, and application metadata. These options allow users to tailor Errsole's functionality to their specific needs. ```APIDOC Errsole Configuration Options: storage: Type: ErrsoleSQLite | ErrsoleMySQL | ErrsolePostgres | ErrsoleMongoDB Description: Required. Specify the storage backend along with connection details. exitOnException: Type: boolean Description: Optional. Default: true. By default, Errsole exits the process after capturing an uncaught exception. To disable this behavior, set exitOnException to false. collectLogs: Type: string[] Description: Optional. Default: ['error', 'info']. By default, Errsole collects both error and info logs. To collect only error logs, set this to ['error']. To disable log collection entirely, set this to an empty array, []. enableConsoleOutput: Type: boolean Description: Optional. Control whether log output is shown in the console. enableDashboard: Type: boolean Description: Optional. Default: true. Enable or disable the web dashboard feature. port: Type: number Description: Optional. Default: 8001. Specify the network port for the web dashboard. path: Type: string Description: Optional. Default: /. Define the base path for accessing the web dashboard. appName: Type: string Description: Optional. Specify the name of the app. environmentName: Type: string Description: Optional. Default: process.env.NODE_ENV. Specify the deployment environment. ``` -------------------------------- ### Utilize Errsole's Advanced Logging Functions Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Demonstrates the various logging functions provided by Errsole, allowing developers to categorize and capture messages at different severity levels (log, alert, error, warn, debug). It also shows how to attach metadata to logs for richer context. ```javascript errsole.log('Logging a message'); errsole.alert('Alert! Something critical happened'); errsole.error(new Error('An error occurred')); errsole.warn('This is a warning message'); errsole.debug('Debugging information'); errsole.meta({ reqBody: req.body, queryResults: results }).error(err); ``` -------------------------------- ### Integrate Errsole Proxy Middleware with Hapi Source: https://github.com/errsole/errsole.js/blob/master/docs/proxy-middleware.md This snippet illustrates the setup of Errsole Proxy Middleware in a Hapi.js application. It initializes Errsole with SQLite storage and registers the `hapiProxyMiddleware` as the first plugin, making the Errsole Web Dashboard accessible at `/errsole`. ```javascript 'use strict'; const Hapi = require('@hapi/hapi'); const errsole = require('errsole'); const ErrsoleSQLite = require('errsole-sqlite'); // Insert the Errsole code snippet at the beginning of your app's main file errsole.initialize({ storage: new ErrsoleSQLite('/tmp/logs.sqlite') }); const init = async () => { const server = Hapi.server({ port: 3000, host: 'localhost' }); // Register the Errsole Proxy Middleware at the desired path (e.g., /errsole) // Make sure this is the first plugin to be registered await server.register({ plugin: errsole.hapiProxyMiddleware('/errsole') }); // Register other plugin below the Errsole Proxy Middleware await server.start(); console.log('Server running on %s', server.info.uri); }; process.on('unhandledRejection', (err) => { console.log(err); process.exit(1); }); init(); ``` -------------------------------- ### Configure Errsole Slack Notifications Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This snippet shows how to enable Slack integration for critical error notifications by providing a Slack Webhook URL within the Errsole initialization configuration. ```javascript errsole.initialize({ storage: new ErrsoleMongoDB(options), appName: 'your-app-name', integrations: { slack: { url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' } } }); ``` -------------------------------- ### Errsole Advanced Logging API Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Documentation for Errsole's advanced logging functions, allowing developers to emit logs with specific severity levels and attach contextual metadata. These functions enhance error tracking and debugging capabilities. ```APIDOC errsole.log(message: any, ...args: any[]) - Description: Logs a general message at the 'log' level. - Parameters: - message: The primary message to log. - ...args: Additional data to include with the log. errsole.alert(message: any, ...args: any[]) - Description: Logs a critical alert message. - Parameters: - message: The primary alert message. - ...args: Additional data. errsole.error(error: Error | string, ...args: any[]) - Description: Logs an error, typically an Error object or a string. - Parameters: - error: The Error object or error message. - ...args: Additional data. errsole.warn(message: any, ...args: any[]) - Description: Logs a warning message. - Parameters: - message: The primary warning message. - ...args: Additional data. errsole.debug(message: any, ...args: any[]) - Description: Logs a debug message, useful for development. - Parameters: - message: The primary debug message. - ...args: Additional data. errsole.meta(metadata: object): ErrsoleLogger - Description: Attaches custom metadata to the subsequent log call. - Parameters: - metadata: An object containing key-value pairs of metadata. - Returns: An ErrsoleLogger instance that can be chained with a logging method (e.g., .error(), .log()). ``` -------------------------------- ### Integrate Errsole with NestJS Application Source: https://github.com/errsole/errsole.js/blob/master/docs/proxy-middleware.md This example demonstrates how to initialize Errsole with SQLite storage and integrate its proxy middleware into a NestJS application. It covers setting up `body-parser` and registering the Errsole middleware at a specified path, ensuring it's among the first middlewares. It also includes commented-out code for Fastify integration. ```javascript import { NestFactory } from '@nestjs/core'; import * as bodyParser from 'body-parser'; import errsole from 'errsole'; import ErrsoleSQLite from 'errsole-sqlite'; import { AppModule } from './app.module'; // Insert the Errsole code snippet at the beginning of your app's main file errsole.initialize({ storage: new ErrsoleSQLite('/tmp/logs.sqlite') }); async function bootstrap () { const app = await NestFactory.create(AppModule); // Register the Errsole Proxy Middleware at the desired path (e.g., /errsole) // Make sure this is the first middleware used // Use body-parser middleware if NestJS is using Express app.use(bodyParser.json()); app.use('/errsole', (req, res, next) => { errsole.nestExpressProxyMiddleware('/errsole', req, res, next); }); // For Fastify, use the following middleware // app.use('/errsole', (req, res, next) => { // errsole.nestFastifyProxyMiddleware('/errsole', req, res); // }); // Add other middlewares below the Errsole Proxy Middleware await app.listen(3000); } bootstrap(); ``` -------------------------------- ### Reload NGINX Configuration Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This command reloads the NGINX configuration to apply any changes made to its settings, ensuring that new proxy rules for Errsole or other updates are active without restarting the server. ```bash sudo nginx -s reload ``` -------------------------------- ### Configure errsole.js Initialization with Email Integration Source: https://github.com/errsole/errsole.js/blob/master/docs/advanced-configuration.md This JavaScript example shows how to configure email integration within errsole.js initialization. It includes SMTP host, port, authentication credentials, sender, and recipient details for critical error notifications. ```javascript errsole.initialize({ storage: new ErrsoleSQLite(logsFile), appName: 'your-app-name', integrations: { email: { host: 'smtp.example.com', port: 587, username: 'your-smtp-username', password: 'your-smtp-password', sender: 'notifications@example.com', recipients: ['dev1@example.com', 'dev2@example.com'] } } }); ``` -------------------------------- ### Configure Errsole Email Notifications Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Illustrates how to integrate SMTP-based email notifications into Errsole's initialization. This allows Errsole to send critical error alerts to specified recipients via the configured SMTP server. ```javascript errsole.initialize({ storage: new ErrsoleMySQL(options), appName: 'your-app-name', integrations: { email: { host: 'smtp.example.com', port: 587, username: 'your-smtp-username', password: 'your-smtp-password', sender: 'notifications@example.com', recipients: ['dev1@example.com', 'dev2@example.com'] } } }); ``` -------------------------------- ### Initialize Errsole Logger with SQLite Storage Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md This snippet demonstrates how to initialize the Errsole logger to use `ErrsoleSQLite` for log storage. It provides configurations for both CommonJS and ESM/TypeScript environments, specifying the path to the SQLite database file and the application name. ```javascript const errsole = require('errsole'); const ErrsoleSQLite = require('errsole-sqlite'); errsole.initialize({ storage: new ErrsoleSQLite('path/to/database.sqlite'), appName: 'your-app-name' }); module.exports = errsole; ``` ```javascript import errsole from 'errsole'; import ErrsoleSQLite from 'errsole-sqlite'; errsole.initialize({ storage: new ErrsoleSQLite('path/to/database.sqlite'), appName: 'your-app-name' }); export default errsole; ``` -------------------------------- ### Reload NGINX Configuration Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md This command reloads the NGINX configuration, applying any changes made to the NGINX configuration files. It allows for updates to take effect without interrupting active connections or stopping the NGINX server. ```bash sudo nginx -s reload ``` -------------------------------- ### Utilize Errsole's Advanced Logging Functions Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This section demonstrates the use of Errsole's various logging levels, including `log`, `alert`, `error`, `warn`, and `debug`. It also shows how to attach custom metadata to error logs for enhanced debugging and context. ```javascript errsole.log('Logging a message'); errsole.alert('Alert! Something critical happened'); errsole.error(new Error('An error occurred')); errsole.warn('This is a warning message'); errsole.debug('Debugging information'); errsole.meta({ reqBody: req.body, queryResults: results }).error(err); ``` -------------------------------- ### Configure Errsole Logger with MySQL Storage Source: https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md Initializes the Errsole logger to use ErrsoleMySQL for persistent log storage. This configuration block sets up the connection to your MySQL database, requiring host, user, password, database name, and an application-specific table prefix. It also sets the application name for Errsole. ```javascript const errsole = require('errsole'); const ErrsoleMySQL = require('errsole-mysql'); errsole.initialize({ storage: new ErrsoleMySQL({ host: 'mysql-host', // Replace with your actual MySQL host user: 'database-user', // Replace with your actual MySQL user password: 'database-password', // Replace with your actual MySQL password database: 'database-name', // Replace with the name of your MySQL database tablePrefix: 'app-name' // Replace with your actual app name }), appName: 'app-name' // Replace with your actual app name }); module.exports = errsole; ``` ```javascript import errsole from 'errsole'; import ErrsoleMySQL from 'errsole-mysql'; errsole.initialize({ storage: new ErrsoleMySQL({ host: 'mysql-host', // Replace with your actual MySQL host user: 'database-user', // Replace with your actual MySQL user password: 'database-password', // Replace with your actual MySQL password database: 'database-name', // Replace with the name of your MySQL database tablePrefix: 'app-name' // Replace with your actual app name }), appName: 'app-name' // Replace with your actual app name }); export default errsole; ``` -------------------------------- ### Configure Errsole with Email Notification Integration Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md Demonstrates how to initialize Errsole with email integration settings, including SMTP host, port, username, password, sender, and recipient addresses. This configuration enables Errsole to send critical error notifications via email. ```javascript errsole.initialize({ storage: new ErrsoleSQLite(logFile), appName: 'your-app-name', integrations: { email: { host: 'smtp.example.com', port: 587, username: 'your-smtp-username', password: 'your-smtp-password', sender: 'notifications@example.com', recipients: ['dev1@example.com', 'dev2@example.com'] } } }); ``` -------------------------------- ### Configure NGINX for Errsole Web Dashboard Access Source: https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md This NGINX configuration snippet sets up a reverse proxy to expose the Errsole Web Dashboard through a custom URL path. It handles redirects and proxying for the dashboard interface, allowing access via your domain. ```nginx 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"; } ``` -------------------------------- ### Configure NGINX reverse proxy for Errsole Web Dashboard Source: https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md This NGINX configuration snippet sets up a reverse proxy to expose the Errsole Web Dashboard through a custom URL path on your domain. It includes a redirect for trailing slashes and handles WebSocket upgrades, ensuring proper access to the dashboard when your application is behind NGINX. ```nginx 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"; } ``` -------------------------------- ### Configure NGINX Proxy for Errsole Web Dashboard Source: https://github.com/errsole/errsole.js/blob/master/docs/sqlite-storage.md This NGINX configuration block sets up a reverse proxy to make the Errsole Web Dashboard accessible through a custom URL path on your domain. It includes a 301 redirect for trailing slashes and proxies requests to the local Errsole server running on port 8001. ```nginx 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"; } ``` -------------------------------- ### errsole.initialize Configuration Options API Reference Source: https://github.com/errsole/errsole.js/blob/master/docs/advanced-configuration.md Comprehensive API documentation for the `options` object passed to the `errsole.initialize` method. This includes details for server naming, and integration settings for email (SMTP host, port, credentials, sender, recipients) and Slack (Webhook URL). ```APIDOC errsole.initialize(options: object) - Description: Initializes the Errsole library with specified configurations. - Parameters: - options: object - Description: The configuration object for Errsole. - Properties: - serverName: string (Optional, Default: the hostname of the machine) - Description: Specify the name of the server. - integrations: object (Optional) - Description: Configuration for external integrations. - Properties: - email: object (Optional) - Description: SMTP configuration object for sending email notifications. - Properties: - host: string (Required) - Description: SMTP host or IP address. - port: number (Required) - Description: SMTP port number. - username: string (Required) - Description: SMTP username. - password: string (Required) - Description: SMTP password. - sender: string (Required) - Description: Email address from which notifications are sent. - recipients: string[] (Required) - Description: List of email addresses to receive notifications. - slack: object (Optional) - Description: Slack configuration object. - Properties: - url: string (Required) - Description: Slack Webhook URL for sending notifications. ```