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

Logger Extra Bundle Laravel Package

deamon/logger-extra-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel Compatibility: The bundle’s core functionality—enriching logs with contextual data—aligns well with Laravel’s observability needs, particularly for structured logging in APIs or microservices. However, its Symfony-centric design (e.g., SecurityCore, HttpFoundation) introduces misalignment. The deprecation fixes in v7.1.0 suggest the bundle is trimming Symfony-specific cruft, but Laravel’s Monolog v2.x may still face edge cases.
  • Monolog Integration: Laravel’s built-in Monolog support is robust, but lacks automated context injection for request/user metadata. This bundle could fill that gap with minimal effort, provided Symfony dependencies are excluded.
  • Value Proposition: Justifies adoption for teams needing zero-config context enrichment (e.g., user_id, request_id, client_ip) without manual log formatting. The bundle’s MIT license and Symfony 6.x compatibility reduce risk for modern stacks.

Integration Feasibility

  • Symfony Dependency Isolation: The bundle’s Monolog processor classes (e.g., ExtraContextProcessor) are likely reusable in Laravel, but:
    • Critical Check: Verify no hidden Symfony dependencies exist (e.g., via composer why symfony/security-core).
    • Workaround: Use a composer alias or fork to strip Symfony dependencies if needed.
  • Configuration Overhead: The bundle’s YAML config is Symfony-specific, but Laravel can replicate functionality via:
    // config/logging.php
    'processors' => [
        \Deamon\LoggerExtraBundle\Processor\ExtraContextProcessor::class,
    ],
    
  • Backward Compatibility: Supports Monolog v2.x (Laravel’s default), but the deprecation fixes imply potential API changes. Test with:
    composer require monolog/monolog:^2.0 --dev
    

Technical Risk

  • Symfony Residuals: Even with pruning, undocumented Symfony dependencies could emerge. Mitigation: Run composer why symfony post-installation.
  • Maintenance Risk: Low stars/contributors suggest no long-term guarantees. Mitigation:
    • Fork the bundle to remove Symfony dependencies.
    • Monitor for Monolog v3.x compatibility (Laravel may upgrade).
  • Performance: Context injection adds overhead (~1–5ms per log). Mitigation: Benchmark with laravel-debugbar or blackfire.io.

Key Questions

  1. Symfony Dependency Audit:
    • Are there undocumented symfony/* dependencies in the bundle’s composer.json or autoload?
    • Example: Does ExtraContextProcessor extend a Symfony class?
  2. Monolog Version Support:
    • Does the bundle work with Laravel’s Monolog v2.x? Are there known issues with addRecord() or processRecord() signatures?
  3. Context Customization:
    • Can Laravel override default context keys (e.g., user_id) via config or service binding?
  4. Fallback Implementation:
    • What’s the effort to build a Laravel-native equivalent (e.g., a LogContext facade)?
    • Example:
      Log::withContext(['user_id' => auth()->id()])->info('Event');
      

Integration Approach

Stack Fit

  • Laravel Monolog Integration:
    • Action: Use the bundle’s processor classes only, excluding Symfony bundles.
    • Implementation:
      // app/Providers/AppServiceProvider.php
      use Deamon\LoggerExtraBundle\Processor\ExtraContextProcessor;
      
      public function boot()
      {
          \Log::tap(function ($monolog) {
              $monolog->pushProcessor(new ExtraContextProcessor());
          });
      }
      
    • Validation: Ensure no Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface errors.
  • Configuration:
    • Replace YAML config with Laravel’s config/logging.php:
      'processors' => [
          \Deamon\LoggerExtraBundle\Processor\ExtraContextProcessor::class,
      ],
      
    • Override defaults (e.g., user_class) via service binding:
      $this->app->bind(\Deamon\LoggerExtraBundle\Processor\ExtraContextProcessor::class, function ($app) {
          return new ExtraContextProcessor([
              'user_class' => \App\Models\User::class,
              'user_methods' => ['getId' => 'id'],
          ]);
      });
      

Migration Path

  1. Dependency Isolation:
    • Install the bundle without Symfony:
      composer require deamon/logger-extra-bundle --dev
      composer remove symfony/security-bundle symfony/http-foundation
      
    • If errors persist, fork the bundle and remove Symfony dependencies.
  2. Processor Registration:
    • Register the processor in AppServiceProvider (as above).
    • Test with:
      \Log::info('Test', ['custom' => 'data']);
      
      Expected output: Log includes extra.request_id, extra.user_id, etc.
  3. Configuration Migration:
    • Map YAML config to Laravel’s config/logging.php or a custom config file.
    • Example:
      // config/deamon_logger.php
      return [
          'handlers' => ['single'], // Laravel's default handler
          'display' => [
              'env' => env('APP_DEBUG'),
              'user' => true,
          ],
      ];
      

Compatibility

  • Monolog v2.x: Laravel’s default. Test for:
    • processRecord() method compatibility.
    • No deprecated Monolog API usage (e.g., addRecord()).
  • Laravel 10.x: Ensure no PHP 8.2+ features break compatibility.
  • Symfony Residuals: Use composer why symfony to audit dependencies.

Sequencing

  1. PoC Phase:
    • Install the bundle in a staging environment.
    • Verify logs include expected context (e.g., extra.request_id).
  2. Production Rollout:
    • Gradually enable in non-critical routes first.
    • Monitor log volume/performance impact (context injection adds overhead).
  3. Fallback:
    • If issues arise, replace with a custom processor or spatie/laravel-logging.

Operational Impact

Maintenance

  • Bundle Updates:
    • Risk: Low stars imply infrequent updates. Mitigation:
      • Pin to a specific version (e.g., 7.1.0).
      • Monitor for Monolog v3.x compatibility.
    • Process: Test updates in CI (e.g., GitHub Actions) before merging.
  • Customization:
    • Override defaults via service binding (as shown above).
    • Extend context keys by subclassing ExtraContextProcessor.

Support

  • Debugging:
    • Logs may include Symfony-specific errors if dependencies aren’t pruned.
    • Tooling: Use composer why symfony to diagnose residual dependencies.
  • Community:
    • Limited support (1 star). Workaround:
      • Open issues with Laravel-specific context.
      • Fork and maintain a Laravel-compatible version.

Scaling

  • Performance:
    • Context injection adds ~1–5ms per log. Mitigation:
      • Disable in non-critical handlers (e.g., single vs. daily).
      • Use Log::withoutOverhead() for bulk operations.
    • Benchmark: Compare with spatie/laravel-logging or custom solutions.
  • Log Volume:
    • Enriched logs increase size. Mitigation:
      • Compress logs (e.g., Monolog\Handler\StreamHandler with gzip).
      • Sample logs in production (e.g., Monolog\Handler\FilterHandler).

Failure Modes

Failure Impact Mitigation
Symfony dependency errors Logs fail to process Fork the bundle; remove Symfony classes.
Monolog version mismatch Processor crashes Pin Monolog to v2.x; test with v3.x.
Context injection overhead High latency in logging Disable for non-critical handlers.
Bundle abandonment No future updates Fork and maintain Laravel-specific version.

Ramp-Up

  • Onboarding:
    • Documentation: Create a Laravel-specific README.md for the forked version.
    • Example Config:
      // config/logging.php
      'processors' => [
          \Vendor\LoggerExtraBundle\Processor\LaravelExtraContextProcessor::class,
      ],
      
  • Training:
    • For Devs: Focus on:
      • Registering the processor in AppServiceProvider.
      • Overriding defaults via service binding.
    • For Ops: Highlight log size/performance tradeoffs.
  • Tooling:
    • Integrate with Laravel Forge or Telescope for log monitoring.
    • Use Laravel Debugbar to inspect context injection
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.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
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