- How do I install and set up this package in Laravel?
- Run `composer require bzilee/multichannel-log-notification`, publish the config with `php artisan vendor:publish --tag=config`, then configure `.env` and `config/logging.php` to enable channels like Telegram or Email. Queue support requires setting `QUEUE_CONNECTION` and running `php artisan queue:work --queue=multichannel-logs`.
- Which Laravel versions does this package support?
- The package officially supports Laravel 11.x and requires PHP 8.0+. Check the `composer.json` for minor version compatibility if using older Laravel releases, though Laravel 10.x may work with adjustments.
- Can I route different log levels (e.g., errors vs. info) to separate channels?
- Yes. Define `channels_by_level` in `config/multichannel_log.php` to map log levels (e.g., `error` to Telegram + Email, `info` to Email only). The package handles the routing automatically when using `Log::channel('multichannel')`.
- Does this package support async/queue-based log notifications?
- Yes, notifications are queued by default to avoid blocking requests. Configure `QUEUE_CONNECTION` in `.env` (e.g., Redis or database) and run a queue worker (`php artisan queue:work --queue=multichannel-logs`) to process logs asynchronously.
- How do I add custom channels like Slack or Discord?
- Extend the `MultichannelLogHandler` by creating a custom handler class that implements the same interface. Register it in `config/logging.php` and configure it in `config/multichannel_log.php` under `custom_channels`. The package’s modular design makes this straightforward.
- What happens if a channel (e.g., SMS or HTTP) fails to send a notification?
- Failed notifications are not retried by default. To handle retries, integrate Laravel’s queue failure system or use a dead-letter queue. Log failures to another channel (e.g., Email) by configuring `failed_channel` in the config.
- Is there a way to test this package without hitting real APIs (e.g., Telegram, SMS)?
- Mock external channels by stubbing their dependencies (e.g., `TelegramBot` or `VonageClient`) in your tests. Use Laravel’s `Mockery` or `PHPUnit` to fake HTTP responses or SMS delivery. No built-in test utilities exist, but the package’s dependency injection makes mocking feasible.
- Can I use this package in a microservices architecture or non-Laravel PHP app?
- The package is tightly coupled to Laravel’s Log facade and Monolog, so adoption in microservices or non-Laravel PHP requires wrapping the handler logic or abstracting the logging system. Consider alternatives like Sentry or custom Monolog handlers for broader compatibility.
- Are there any performance concerns with high-volume logs (e.g., 10K+ messages/day)?
- Queue-based delivery mitigates performance issues, but ensure your queue worker (`multichannel-logs`) can handle the load. For extreme volumes, batch notifications or use a dedicated monitoring tool like Sentry to filter critical logs before routing.
- What are the alternatives to this package for Laravel log notifications?
- Alternatives include Laravel’s built-in `Notification` system with channels (e.g., Telegram, Mail), third-party packages like `spatie/laravel-logging` for Monolog extensions, or observability tools like Sentry or LogDNA. Choose based on needs: this package excels for multi-channel routing with queue support.