Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Bugsnag Psr Logger Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • PSR-3 v3 Compliance: Now fully aligned with the latest PSR-3 standard, ensuring compatibility with modern Laravel (v9+) and PHP logging ecosystems. This strengthens integration with Laravel’s Monolog (which supports PSR-3 v3) and future-proofs the package against deprecations.
  • Event-Driven Observability: Retains seamless integration with Laravel’s logging facade (Log::error()) and Monolog stack, enabling structured error tracking without disrupting existing workflows.
  • Separation of Concerns: Continues to treat error reporting as a modular concern, avoiding coupling with core logic. The removal of AbstractLogger simplifies the class hierarchy, reducing maintenance overhead.

Integration Feasibility

  • PSR-3 v3 Compatibility: Directly compatible with Laravel’s Monolog (v2.0+) and PHP’s latest PSR standards. No breaking changes for basic usage (e.g., Log::channel('bugsnag')->error()).
  • Configuration Flexibility: Unchanged—still supports environment variables and Laravel’s config system. The addition of parameter/return types improves IDE support and type safety.
  • Middleware/Service Provider Hooks: Integration via AppServiceProvider or custom logging channels remains straightforward. The removal of protected methods (limit) reduces surface area for custom extensions.

Technical Risk

  • Deprecation Risk: Mitigated but not resolved. While PSR-3 v1 is deprecated, the package now enforces v3, which is actively maintained. However, the last release was in 2022, and the repo shows no recent activity. Monitor:
  • Performance Overhead: Unchanged. Network calls to BugSnag’s API may still introduce latency. Test with production-like error volumes.
  • Data Privacy: Unchanged. Review BugSnag’s data handling policies for GDPR/CCPA compliance.
  • Breaking Changes for Extenders:
    • Critical: Users extending BugsnagLogger or MultiLogger must update due to:
      • Removal of AbstractLogger (now uses Psr\Log\AbstractLogger).
      • Added type hints (may break dynamic method calls).
      • Removed limit method (if custom logic relied on it).
    • Impact: Low for most users (only affects custom implementations).

Key Questions

  1. Maintenance Status:
    • Is the package’s GitHub repo monitored for issues? Are there open PRs or community forks?
    • Is BugSnag’s PHP SDK (dependency) actively updated for Laravel 10+?
  2. Feature Parity:
    • Does PSR-3 v3 support all BugSnag features (e.g., release staging, user context, breadcrumbs)?
    • Are there gaps compared to the native BugSnag PHP SDK or spatie/laravel-bugsnag?
  3. Alternatives:
    • Compare with spatie/laravel-bugsnag (Laravel-specific, actively maintained) or the native BugSnag PHP SDK (more features but less Laravel integration).
  4. Cost:
  5. Testing:
    • How do PSR-3 v3 logs differ from Laravel’s exception handler logs? Overlap or gaps?
  6. Backward Compatibility:
    • For teams using PSR-3 v1, they must migrate to ^1.0 of this package. Assess migration effort.

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Ideal for: Laravel 9/10 apps using Monolog (PSR-3 v3 compliant). No changes needed for basic usage.
    • Microservices: Still useful for distributed systems with centralized error tracking.
    • Legacy Systems: Can augment non-Laravel PHP apps using PSR-3 v3 loggers.
  • Type Safety:
    • Added parameter/return types improve IDE support (e.g., PHPStorm) and reduce runtime errors in custom implementations.

Migration Path

  1. Phase 1: Dependency Update

    • Update Composer dependency to ^2.0:
      composer require bugsnag/bugsnag-psr-logger:^2.0
      
    • If using PSR-3 v1, downgrade to ^1.0 or migrate to v3.
  2. Phase 2: Configuration

    • Update 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'),
          ],
      ],
      
  3. Phase 3: Custom Implementation Updates

    • If extending BugsnagLogger:
      • Replace AbstractLogger with Psr\Log\AbstractLogger.
      • Update method signatures to include type hints (e.g., public function log($level, \Stringable|string $message, array $context = []): void).
      • Remove any calls to the deprecated limit method.
    • Example:
      // 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.
      }
      
  4. Phase 4: Testing

    • Verify PSR-3 v3 compliance with:
      Log::channel('bugsnag')->error('Test', ['context' => 'data']);
      
    • Test Laravel’s exception handler integration:
      // App/Exceptions/Handler.php
      public function report(Throwable $e) {
          Log::channel('bugsnag')->error($e->getMessage(), [
              'exception' => $e,
              'user' => auth()->user()?->toArray(),
          ]);
      }
      

Compatibility

  • Laravel Versions: Tested with Laravel 9/10 (Monolog ^2.0). Laravel 11+ may require validation.
  • PHP Versions: Requires PHP ^8.0 (PSR-3 v3 and type hints). Laravel 10+ supports this.
  • BugSnag SDK: Ensure compatibility with bugsnag/bugsnag-php (e.g., v7.x for Laravel 10).
  • PSR-3 v1 Deprecation: Apps using PSR-3 v1 must migrate to v3 or use ^1.0 of this package.

Sequencing

  1. Prioritize Critical Paths: Start with error logging in high-impact areas (e.g., payments, auth).
  2. Monitor Overhead: Use Laravel Debugbar or Blackfire to measure BugSnag API latency.
  3. Gradual Rollout:
    • Enable in staging first.
    • Use feature flags for production rollout if needed.
  4. Fallback Mechanism: Implement local caching (e.g., database) for errors during BugSnag API outages.

Operational Impact

Maintenance

  • Configuration Drift: Centralize BugSnag settings in config/services/bugsnag.php to avoid hardcoding.
  • Dependency Updates:
    • Monitor bugsnag/bugsnag-php for breaking changes (e.g., API key format, context structure).
    • Update this package to ^2.0 and test custom implementations.
  • Documentation:
    • Add a UPGRADE.md file detailing v2.0 migration steps (e.g., type hints, AbstractLogger removal).
    • Update Laravel’s README with PSR-3 v3 usage examples.

Support

  • Debugging Workflow:
    • Train devs to correlate BugSnag errors with Laravel logs using Log::stack().
    • Ensure support teams can access BugSnag dashboards and integrate with Jira/Linear.
  • SLA Impact: BugSnag’s uptime SLA (e.g., 99.9%) may still affect incident response times.
  • Custom Implementation Risks:
    • Users extending BugsnagLogger may need support for type hint adjustments or AbstractLogger removal.

Scaling

  • Rate Limits: BugSnag’s free tier has event limits. Plan for paid tiers if scaling beyond 100k events/month.
  • Batching: Configure BugSnag’s sendInterval to reduce API calls in high-throughput apps.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor