How spatie/laravel-http-logger works
Main Components
a. Request Flow Layer:
• HTTP Request Entry Point
• Laravel Middleware Pipeline
• HTTP Logger Middleware (central component)
b. Core Components:
• LogProfile Interface/Implementation
• LogWriter Interface/Implementation
• Sanitizer Component
• Service Provider
c. Configuration:
• Config Management
• Environment Variables
Component Relationships
[HTTP Request] → [Laravel Middleware Pipeline]
• ↓
• [HTTP Logger Middleware]
• ↙ ↘
• [LogProfile] [LogWriter]
• (shouldLogRequest) (logRequest)
• ↓ ↓
• [Logic Layer] [Sanitizer]
• ↓
• [Laravel Logger]
• ↓
• [Log Storage]
Important Elements to Highlight
a. Request Processing Flow:
• How requests pass through the middleware
• Decision point where LogProfile determines if logging occurs
• Sanitization process for sensitive data
b. Configuration Integration:
• How environment variables influence the system
• Config file integration points
c. Extension Points:
• Interfaces (LogProfile, LogWriter) as extension points
• Custom implementation possibilities
Additional Details
• Notes about supported HTTP methods (POST, PUT, PATCH, DELETE)
• Configuration options (enabled/disabled state)
• Header sanitization process
• Log channel configuration
Implementation Details
• Relationship between HttpLoggerServiceProvider and Laravel's service container
• Where custom implementations can be injected
• Log message format and structure