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

Log Laravel Package

guzzle/log

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Use Case Alignment: The guzzle/log package is a niche but valuable tool for structured HTTP request/response logging in Laravel applications using Guzzle. It aligns well with:
    • Debugging: Capturing raw payloads, headers, and metadata for API troubleshooting (e.g., webhook failures, third-party integrations).
    • Observability: Integrating with Laravel’s Monolog stack for centralized logging (e.g., ELK, Sentry).
    • Compliance: Auditing sensitive API interactions (e.g., payment gateways, OAuth flows) for GDPR/PCI compliance.
  • Laravel Synergy:
    • Pros: Leverages Laravel’s Monolog (PSR-3 compliant) for consistency. Works seamlessly with Laravel’s logging channels (e.g., stack, single).
    • Cons: Laravel’s HttpClient (built on Guzzle) already includes middleware for logging, reducing the need for this package unless using custom Guzzle instances.
  • Alternatives:
    • Laravel HttpClient: Native middleware for logging (preferred for Laravel-specific projects).
    • guzzlehttp/logger-middleware: Official, maintained alternative for Guzzle 6/7.
    • Monolog Handlers: Custom PSR-3 handlers for Guzzle logging.

Integration Feasibility

  • Low-Coupling: The package is a PSR-3 adapter, requiring minimal changes to existing Guzzle clients.
  • Backward Compatibility:
    • Guzzle 3.x: High risk (EOL since 2015). Avoid unless maintaining legacy code.
    • Guzzle 6/7.x: Untested (package is unmaintained). Use alternatives for modern Laravel.
  • Customization:
    • Supports custom log formats, handlers, and context enrichment (e.g., adding request IDs).
    • Can be extended to redact sensitive data (e.g., tokens, passwords).

Technical Risk

  • Critical Risks:
    • Deprecation: Guzzle 3.x is abandoned. Using this package locks the project into an unsupported stack.
    • Maintenance: No updates since 2015. Risk of breaking changes if Guzzle evolves.
    • Lack of Testing: No CI/CD or test suite. Manual validation required for production use.
  • Mitigation Strategies:
    • Short-Term: Use only for Guzzle 3.x (legacy systems) with clear migration plans.
    • Long-Term: Migrate to Guzzle 7.x + guzzlehttp/logger-middleware or Laravel’s HttpClient.
    • Fallback: Implement custom logging middleware if the package fails.

Key Questions

  1. Guzzle Version:
    • Is the project using Guzzle 3.x (avoid this package) or 6/7.x (use alternatives)?
  2. Logging Stack:
    • Does Laravel’s Monolog support the required PSR-3 handlers? (Yes, but verify configuration.)
  3. Performance:
    • Will structured logging impact API latency? (Negligible for most use cases; benchmark if critical.)
  4. Sensitive Data:
    • How will PII (e.g., tokens, passwords) be redacted in logs? (Requires custom Monolog processors.)
  5. Long-Term Viability:
    • Is this a temporary fix or a core dependency? If the latter, consider forking/maintaining the package.
  6. Alternatives:
    • Why not use Laravel’s HttpClient middleware or guzzlehttp/logger-middleware?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Monolog: The package’s PSR-3 adapter integrates natively with Laravel’s logging system.
    • Observability Tools: Logs can be forwarded to ELK, Datadog, or Sentry via Monolog handlers.
    • CLI/Queues: Useful for logging HTTP interactions in Artisan commands or background jobs.
  • Non-Laravel PHP:
    • Works in any PSR-3-compatible app (e.g., Symfony, Lumen) using Guzzle.
  • Guzzle Version:
    • Guzzle 3.x: Only use if maintaining legacy code (high risk).
    • Guzzle 6/7.x: Avoid this package; use guzzlehttp/logger-middleware instead.

Migration Path

  1. For Guzzle 3.x Users:
    • Short-Term: Use guzzle/log as-is with warnings about EOL support.
    • Long-Term:
      • Migrate to Guzzle 7.x.
      • Replace with guzzlehttp/logger-middleware or Laravel’s HttpClient.
  2. For Guzzle 6/7.x Users:
    • Avoid this package. Use:
      • Laravel HttpClient:
        $response = Http::withOptions(['debug' => true])->get('https://api.example.com');
        
      • guzzlehttp/logger-middleware:
        use GuzzleHttp\HandlerStack;
        use GuzzleHttp\Middleware;
        use GuzzleHttp\Handler\CurlHandler;
        
        $handler = HandlerStack::create(new CurlHandler());
        $handler->push(Middleware::tap(function ($request) {
            // Custom logging logic
        }));
        

Compatibility

  • Laravel Versions:
    • Laravel 5.5–8.x: Compatible with Guzzle 6/7 via Monolog (but avoid this package).
    • Laravel 9+: Prefer HttpClient middleware (native support).
  • PHP Versions:
    • Guzzle 3.x: PHP 5.6+ (legacy).
    • Guzzle 6/7: PHP 7.2+ (Laravel 8+ requirement).
  • Handler Support:
    • Works with any PSR-3 logger (e.g., Monolog\Handler\StreamHandler, FirePHPHandler).
    • Requires Monolog for structured formatting (e.g., JSON).

Sequencing

  1. Assess Guzzle Version:
    • Confirm whether the project uses Guzzle 3.x (avoid) or 6/7.x (use alternatives).
  2. Configure Monolog:
    // config/logging.php
    'channels' => [
        'guzzle' => [
            'driver' => 'single',
            'path' => storage_path('logs/guzzle.log'),
            'level' => env('LOG_LEVEL', 'debug'),
        ],
    ],
    
  3. Integrate Adapter (Guzzle 3.x only):
    use Guzzle3\Log\LogAdapter;
    use Monolog\Logger;
    
    $logger = new Logger('guzzle');
    $logAdapter = new LogAdapter($logger);
    $client = new Guzzle3\Client(['logger' => $logAdapter]);
    
  4. Test Edge Cases:
    • Validate logging for redirects, retries, and binary payloads.
    • Ensure sensitive data is redacted (e.g., auth headers).

Operational Impact

Maintenance

  • Proactive Risks:
    • Deprecation: Guzzle 3.x is unsupported. Schedule a migration if using this package.
    • Package Abandonment: No updates since 2015. Monitor for forks or alternatives.
  • Laravel-Specific:
    • Log rotation/retention is managed by Monolog (no additional config).
    • Centralized logging (e.g., ELK) requires no changes to this package.
  • Mitigation:
    • Set reminders to migrate off Guzzle 3.x.
    • Document the package’s limitations in the codebase.

Support

  • Debugging:
    • Provides end-to-end visibility for HTTP failures (e.g., 4xx/5xx responses, timeouts).
    • Contextual data (headers, payloads) aids in troubleshooting third-party APIs.
  • Limitations:
    • No built-in support for structured logging (e.g., JSON). Requires Monolog formatters.
    • No official support; rely on community GitHub issues (low activity).
  • Best Practices:
    • Use Monolog processors to redact sensitive data:
      $logger->pushProcessor(function (array $record) {
          unset($record['context']['request']['headers']['authorization']);
          return $record;
      });
      

Scaling

  • Performance:
    • Logging adds ~1–5ms per request. Critical for high-throughput systems (e.g., webhooks).
    • Disable in production if not needed (e.g., via environment config):
      $client = new Guzzle3\Client([
          'logger' => env('APP_DEBUG') ? $logAdapter : null,
      ]);
      
  • Log Volume:
    • High-frequency HTTP calls (e.g., polling APIs) may generate large log volumes.
    • Use Monolog’s FilterHandler to reduce noise:
      $logger->pushHandler(new \Monolog\Handler\FilterHandler(
          new StreamHandler('php://stdout'),
          function ($record) {
              return strpos($record
      
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony