{"id":26552096,"url":"https://github.com/webxsid/prosole-node","last_synced_at":"2026-04-05T23:37:36.306Z","repository":{"id":193910688,"uuid":"689719030","full_name":"webxsid/prosole-node","owner":"webxsid","description":"All-in-one logger and alerts utility designed for Node.js applications","archived":false,"fork":false,"pushed_at":"2025-05-13T08:24:41.000Z","size":166,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T09:34:22.949Z","etag":null,"topics":["developer-tools","logger","logging","node-js","npm-package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/prosole","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webxsid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-10T17:34:15.000Z","updated_at":"2025-05-13T08:24:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"70a2fa47-faea-474e-98d3-2cfde776ccb8","html_url":"https://github.com/webxsid/prosole-node","commit_stats":null,"previous_names":["sm2101/node-logger","sm2101/prosole-node"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/webxsid/prosole-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webxsid%2Fprosole-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webxsid%2Fprosole-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webxsid%2Fprosole-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webxsid%2Fprosole-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webxsid","download_url":"https://codeload.github.com/webxsid/prosole-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webxsid%2Fprosole-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31454199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-tools","logger","logging","node-js","npm-package"],"created_at":"2025-03-22T08:23:45.264Z","updated_at":"2026-04-05T23:37:36.290Z","avatar_url":"https://github.com/webxsid.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prosole\n\n[![npm version](https://img.shields.io/npm/v/prosole.svg)](https://www.npmjs.com/package/prosole) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sm2101prosole/blob/master/LICENSE)\nProsole is an all-in-one logger and alerts utility designed for Node.js applications. It simplifies the process of\nlogging information and generating alerts, making it an essential tool for developers looking to monitor, manage, and\ndebug their Node.js projects.\n\n## Change Log\n\n- v1.1.0\n    - Added Support for a custom template for log prefix\n- v0.1.1\n    - Fixed Interface Issue with logger and alert initialization\n\n## Features\n\n### Logger Utility\n\n- **Transport Configuration**:\n    - Specify one of three supported transports: console, file, or Socket.IO.\n    - Logs are directed to the specified transport, allowing customization based on different environments.\n- **Custom Base Log Level**:\n    - Set a base log level to filter log messages, allowing you to ignore messages below this level.\n    - Log levels range from \"Log\" (lowest) to \"Error\" (highest).\n- **Selective Logging**:\n    - Enable or disable logging by specifying a transport; no logs will be printed if no transport is specified.\n    - This feature provides flexibility in managing logging for different scenarios and environments.\n- **Console Integration**:\n    - Optionally extend the Node.js console object to seamlessly integrate logging features directly into it.\n    - Note that this feature is turned off by default and may not be recommended for all use cases.\n\n### Alert Utility\n\n- **Transport Configuration**:\n    - Choose from multiple alert transports, including Discord, Slack, or custom HTTP requests.\n    - Set up different transports for different environments.\n- **Selective Alerting**:\n    - Define alerting behavior by specifying a transport; no alerts will be sent if no transport is specified.\n    - This feature allows you to adapt alerting to your specific requirements and scenarios.\n- **Integration with Third-Party Platforms**:\n    - Send alert messages to third-party platforms like Slack for immediate notification.\n    - Also, send HTTP requests to a custom server to facilitate alerting.\n- **Console Integration**:\n    - Optionally extend the Node.js console object to seamlessly integrate alerting features directly into it.\n    - Note that this feature is turned off by default and may not be suitable for all use cases.\n\nYou can easily install Prosole via npm or yarn to start using it in your Node.js projects. Choose one of the following\nmethods to get started:\n\n## Installation\n\n### Using npm\n\n```bash\nnpm install prosole --save\n```\n\n### Using yarn\n\n```bash\nyarn add prosole\n```\n\n## Basic Usage\n\nGetting started with Prosole is quick and straightforward. Follow these steps to integrate the Logger and Alert Utility\ninto your Node.js project:\n\n### Importing the Package\n\nYou can import the Prosole package in your Node.js application using either ES6 import or CommonJS require syntax:\n\n**Using ES6 Import:**\n\n```javascript\nimport {logger, alerts} from \"prosole\";\n```\n\n**Using CommonJS Require:**\n\n```javascript\nconst {logger, alerts} = require(\"prosole\");\n```\n\n### Initializing the Logger\n\nTo begin using the logger, initialize it with your project details, preferred transport, and other configuration\noptions:\n\n```javascript\nlogger.init({\n    project: {\n        name: \"YourProjectName\",\n        version: \"1.0.0\", // will default to 1.0.0 if not specified\n    },\n    transport: \"console\", // Choose your preferred transport (e.g., \"console\", \"file\", \"Socket.IO\" or null to bypass)\n    env: \"development\", // Set the environment context\n});\n```\n\n### Logger Configuration Options\n\n| Option        | Description                                                                                                | Type         | Default Value | Accepted Values                |\n|---------------|------------------------------------------------------------------------------------------------------------|--------------|---------------|--------------------------------|\n| project       | An object containing information about the project, such as name and version.                              | Project      | N/A           | N/A                            |\n| transport     | Specifies the transport mechanism for logging: console, file, or Socket.IO.                                | string       | null          | 'console', 'file', 'Socket.IO' |\n| baseLevel     | Sets the base log level to filter log messages. Log levels range from \"Log\" (lowest) to \"Error\" (highest). | string       | N/A           | 'Log', 'Info', 'Warn', 'Error' |\n| env           | Specifies the environment in which the logger is running.                                                  | string       | N/A           | Any string value               |\n| extendConsole | Optionally extends the Node.js console object to integrate logging features directly into it.              | boolean      | false         | true, false                    |\n| template      | Defines a template or formatting function for log message output, allowing for custom formatting.          | Template     | N/A           | N/A                            |\n| file          | Configuration options for file-based logging, including the directory and optional prefix.                 | LogsFile     | N/A           | N/A                            |\n| socketIO      | Configuration options for Socket.IO-based logging, including the base URL, optional headers, and events.   | LogsSocketIO | N/A           | N/A                            |\n| Option        | Description                                                                                                | Type         | Default Value | Accepted Values                |\n\n#### Examples\n\n##### Template Configuration\n\nTo configure a custom template for log messages, you can use the following syntax:\n\n```javascript\nconst loggerConfig = {\n    template: \"{{metadata}} - {{timestamp}} [{{level}}]\",\n};\n\n// or\nconst loggerConfig = {\n    template: (metadata, timestamp, level) =\u003e {\n        return `${metadata} - ${timestamp} [${level}]`;\n    },\n};\n```\n\nAvailable variables for the template:\n\n- timestamp: The timestamp when the log message is generated.\n- level: The log level (e.g., 'Info', 'Warn', 'Error').\n- metadata: The name and version of the project (e.g., \"MyProject:1.0\").\n\n### File Transport Configuration\n\nTo configure file-based logging, specify the directory where logs will be stored:\n\n```javascript\nconst loggerConfig = {\n    transport: \"file\",\n    file: {\n        directory: \"/var/log/myapp\",\n        prefix: \"myapp\",\n    },\n};\n```\n\n### Socket.IO Transport Configuration\n\nTo configure Socket.IO-based logging, specify the base URL and optional headers and the events to be used:\n\n```javascript\nconst loggerConfig = {\n    transport: \"Socket.IO\",\n    socketIO: {\n        baseUrl: \"http://example.com/logs\",\n        headers: {\n            Authorization: \"Bearer YOUR_ACCESS_TOKEN\",\n        },\n        events: {\n            log: \"log\",\n            error: \"error\",\n            ...\u003cmore events\u003e,\n                },\n                },\n                };\n```\n\n### Initializing Alerts\n\nTo set up alerting, initialize it with your project details, preferred alert transport (e.g., Discord), and other\nrelevant options:\n\n```javascript\nalerts.init({\n    project: {\n        name: \"YourProjectName\",\n        version: \"1.0.0\",\n    },\n    transport: \"slack\", // Choose your preferred alert transport (\"slack\", \"http\" or null to bypass )\n    environment: \"development\", // Set the environment context\n    slack: {\n        channels: {\n            \"channel-name\": \u003cwebhook url\u003e\n                },\n                },\n                });\n```\n\n### Alert Configuration Options\n\n| Option        | Description                                                                                         | Type       | Default Value | Accepted Values  |\n|---------------|-----------------------------------------------------------------------------------------------------|------------|---------------|------------------|\n| project       | An object containing information about the project, such as name and version.                       | Project    | N/A           | N/A              |\n| transport     | Specifies the transport mechanism for sending alerts: slack or HTTP.                                | string     | null          | 'slack', 'http'  |\n| environment   | Specifies the environment in which alerts are triggered.                                            | string     | N/A           | Any string value |\n| extendConsole | Optionally extends the Node.js console object to integrate alerting features directly into it.      | boolean    | false         | true, false      |\n| slack         | Configuration options for Slack alerts, including channels to send alerts to.                       | SlackAlert | N/A           | N/A              |\n| http          | Configuration options for HTTP alerts, including the alert URL, headers, and health check settings. | ApiAlert   | N/A           | N/A              |\n\n#### Examples\n\n##### Slack Alert Configuration\n\nTo configure Slack alerts, specify the channels to send alerts to:\n\n```javascript\nconst alertConfig = {\n    transport: \"slack\",\n    slack: {\n        channels: {\n            \"#channel1\": \"webhook_url1\",\n            \"#channel2\": \"webhook_url2\",\n        },\n    },\n};\n```\n\n##### HTTP Alert Configuration\n\nTo configure HTTP alerts, specify the alert URL and optional headers:\n\n```javascript\nconst alertConfig = {\n    transport: \"http\",\n    http: {\n        alertUrl: \"http://example.com/alerts\",\n        headers: {\n            Authorization: \"Bearer YOUR_ACCESS_TOKEN\",\n        },\n        healthCheck: {\n            path: \"/health\",\n            method: \"GET\",\n        },\n        body: (type, project, environment, alert) =\u003e {\n            return {\n                type,\n                project,\n                environment,\n                alert,\n            };\n        },\n    },\n};\n```\n\n### Getting the Slack Webhook URL\n\nTo send alerts to Slack, you need to provide a webhook URL. You can get this URL by using the \"incoming webhook\" feature\nin Slack. Click [here](https://github.com/sm2101/prosole/blob/main/Documentation/Alerts/Slack.md) to see how to set up\nan incoming webhook in Slack.\n\n### Actual Usage\n\nNow that you have initialized the Logger and Alert Utility, you can start using them in your code. Here's how you can\nlog an error message and send an alert message:\n\n#### Logging an Error Message\n\n```javascript\nlogger.error(\"This is an error\", ...\u003cmore data\u003e);\n```\n\n#### Sending an alert using Slack\n\n```javascript\nalerts.error(\"This is an error alert\", \"\u003cslack-channel\u003e\");\n```\n\n#### Sending an alert using HTTP\n\n```javascript\nalerts.error(\"This is an error alert\");\n```\n\nThese simple examples demonstrate how to use Prosole for logging and alerting in your Node.js application. Customize the\nlog and alert messages, as well as the destinations, to meet your specific needs.\n\nFor more detailed usage examples and additional features, please refer to the documentation or code samples provided in\nthe repository.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n\n## Support\n\nIf you have any questions or issues, please open an issue on\nthe [GitHub repository](https://github.com/sm2101/prosole-node).\n\n## Author\n\n- Siddharth Mittal\n    - GitHub: [webxsid](https://github.com/webxsid)\n    - Portfolio: [https://webxsid.com](https://webxsid.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebxsid%2Fprosole-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebxsid%2Fprosole-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebxsid%2Fprosole-node/lists"}