bugs-connector
v1.0.5
Published
A connector to log system events to a proprietary Bugs server for centralized monitoring.
Downloads
61
Readme
Bugs Connector
bugs-connector
is a package designed to log system events to Slack by providing an easy connector to a proprietary ViaMedia Bugs
server. This allows you to track and monitor logs effectively.
Features
- Categorized log types: bad, warn, good, and info.
- Flexible logging with optional per-log channel specification.
- Configurable with environment variables for easy integration across services.
Installation
To install bugs-connector
in your project:
npm install bugs-connector
Usage
Initialization
Before you can start logging messages, you need to initialize the Bugs
system with the URL of your proprietary Bugs
server. You can also set an optional default channel for logs.
import bugs from 'bugs-connector';
bugs.init('https://your-bugs-server-url.com', 'default-channel');
Alternatively, you can use environment variables to configure the URL and default channel:
BUGS_HOST_URL
: The URL of the Bugs server.BUGS_DEFAULT_CHANNEL_ID
: The default Slack channel ID for logging.
These can be configured either by
- using a
.env
file:BUGS_HOST_URL=https://your-bugs-server-url.com BUGS_DEFAULT_CHANNEL_ID=0A1B2C3D;
- or defining them in your project:
process.env.BUGS_HOST_URL = 'https://your-bugs-server-url.com'; process.env.BUGS_DEFAULT_CHANNEL_ID = '0A1B2C3D';
Logging Messages
Once initialized, you can start logging messages using the following methods:
bugs.bad(message, channel)
: Logs a "bad" (error) message.bugs.warn(message, channel)
: Logs a warning message.bugs.info(message, channel)
: Logs an informational message.bugs.good(message, channel)
: Logs a "good" (success) message.
If you don't provide a channel, the default channel (if set) will be used.
// Log a "bad" error message to the default channel
await bugs.bad('Database connection failed');
// Log a "good" message to a specific channel
await bugs.good('Server is running smoothly', 'status-updates');
// Log an informational message
await bugs.info('User login successful');
Error Handling
If no channel or URL is provided during initialization or via environment variables, the system will log a warning to the console.
[bugs://warn] No channel provided! (Use `bugs.init` to set up the default channel, or set process.env.BUGS_DEFAULT_CHANNEL_ID)
[bugs://good] No URL provided! (Use `bugs.init` to set up the URL, or set process.env.BUGS_HOST_URL)
Configuration
You can configure the bugs-connector
either by initializing it programmatically using the init
method or by setting the following environment variables:
BUGS_HOST_URL
: The URL of your Bugs server.BUGS_DEFAULT_CHANNEL_ID
: The default channel for logs.
Example
import Bugs from 'bugs-connector';
// Initialize Bugs with the server URL and default channel
bugs.init('https://your-bugs-server-url.com', 'general');
// Log a "bad" message
await bugs.bad('Critical failure in the payment system');
// Log a "good" message
await bugs.good('Payment processed successfully');
// Log a "warn" message in a specific channel
await bugs.warn('Low disk space on server', 'alerts');
License
This package is proprietary and intended for internal use with the Bugs
logging server.