bugnotify
v1.0.0
Published
Add console.text to send error logs to your backend notification service.
Maintainers
Readme
bugnotify
A simple npm package to add console.text for sending error logs to your custom backend notification service.
Features
- Adds
console.textto the global console object - Sends error messages to your backend (email, SMS, etc.)
- Easy to configure with your API key and endpoint
- Works in Node.js (CommonJS and ESM)
Installation
npm install bugnotifyUsage
1. Import and configure at the top of your entry file:
// CommonJS
require('bugnotify')({
apiKey: 'YOUR_API_KEY',
endpoint: 'http://localhost:3000/notifications/send',
defaultType: 'email',
env: 'production',
});
// or ES Module
import setupConsoleText from 'bugnotify';
setupConsoleText({
apiKey: 'YOUR_API_KEY',
endpoint: 'http://localhost:3000/notifications/send',
});2. Use in your code:
try {
// ...your code...
} catch (err) {
console.text(err, { type: 'sms' });
}API
setupConsoleText(options)
apiKey(string, required): Your API key for the backend.endpoint(string, required): Backend endpoint URL.defaultType(string, optional): Default notification type (email,sms, etc.).env(string, optional): Environment name (e.g.,production).
console.text(error, options?)
error: Error object or string.options.type: Notification type (email,sms, etc.).options.env: Override environment.
MIT License
