bugsnag/bugsnag-psr-logger
PSR-3 logger implementation for Bugsnag. Provides BugsnagLogger to send notifications for messages above a configurable level, plus MultiLogger to fan out logs to Bugsnag and other PSR-3 loggers. Built on bugsnag-php.
Log::error()) and Monolog stack, enabling structured error tracking without disrupting existing workflows.AbstractLogger simplifies the class hierarchy, reducing maintenance overhead.Log::channel('bugsnag')->error()).AppServiceProvider or custom logging channels remains straightforward. The removal of protected methods (limit) reduces surface area for custom extensions.BugsnagLogger or MultiLogger must update due to:
AbstractLogger (now uses Psr\Log\AbstractLogger).limit method (if custom logic relied on it).spatie/laravel-bugsnag?spatie/laravel-bugsnag (Laravel-specific, actively maintained) or the native BugSnag PHP SDK (more features but less Laravel integration).^1.0 of this package. Assess migration effort.Phase 1: Dependency Update
^2.0:
composer require bugsnag/bugsnag-psr-logger:^2.0
^1.0 or migrate to v3.Phase 2: Configuration
config/logging.php to use the new channel (unchanged from v1):
'bugsnag' => [
'driver' => 'custom',
'via' => \Bugsnag\PsrLogger\BugsnagLogger::class,
'bugsnag' => [
'apiKey' => env('BUGSNAG_API_KEY'),
],
],
Phase 3: Custom Implementation Updates
BugsnagLogger:
AbstractLogger with Psr\Log\AbstractLogger.public function log($level, \Stringable|string $message, array $context = []): void).limit method.// Before (v1.x)
class CustomLogger extends \Bugsnag\PsrLogger\BugsnagLogger {
protected function limit() { ... }
}
// After (v2.0)
class CustomLogger extends \Bugsnag\PsrLogger\BugsnagLogger {
// No AbstractLogger inheritance needed; use Psr\Log\AbstractLogger directly if desired.
// Remove limit() method if not overriding.
}
Phase 4: Testing
Log::channel('bugsnag')->error('Test', ['context' => 'data']);
// App/Exceptions/Handler.php
public function report(Throwable $e) {
Log::channel('bugsnag')->error($e->getMessage(), [
'exception' => $e,
'user' => auth()->user()?->toArray(),
]);
}
bugsnag/bugsnag-php (e.g., v7.x for Laravel 10).^1.0 of this package.config/services/bugsnag.php to avoid hardcoding.bugsnag/bugsnag-php for breaking changes (e.g., API key format, context structure).^2.0 and test custom implementations.UPGRADE.md file detailing v2.0 migration steps (e.g., type hints, AbstractLogger removal).README with PSR-3 v3 usage examples.Log::stack().BugsnagLogger may need support for type hint adjustments or AbstractLogger removal.sendInterval to reduce API calls in high-throughput apps.How can I help you explore Laravel packages today?