Pros:
Monolog), requiring minimal architectural changes.user_id, request_id), enabling downstream filtering/analysis.MessageBuilder and Block interfaces allow tailoring to domain-specific needs (e.g., adding organization data to user logs).stack channel, enabling parallel logging (e.g., to files + Logplex).Cons:
config/logging.php and updating .env.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Logplex Dependency | Package assumes Logplex-compatible endpoints (e.g., Heroku, Papertrail). Non-compatible users lose value. | Validate target logging service’s API compatibility early. Offer fallback channels. |
| Customization Complexity | Extending blocks/builder requires PHP interface knowledge. | Provide starter templates (e.g., UserBlock, RequestBlock) in docs. |
| Performance | Slack message formatting adds overhead (~5–10ms per log). | Disable Slack formatting in production if latency is critical. Use logplex channel for core logs only. |
| Error Handling | Limited visibility into Logplex API failures (e.g., rate limits, auth errors). | Add retry logic or integrate with Laravel’s Log::error() for fallback alerts. |
| User Model Assumptions | Relies on Laravel’s User model with specific methods (e.g., getAuthIdentifier()). |
Document customization paths for non-standard auth (e.g., API tokens, SSO). |
tenant_id, device_type) should be included in logs?MessageBuilder/Block classes long-term?user.organization).logplex channel alongside existing channels (e.g., stack).Log::error(), Log::debug() calls.MessageBuilder for critical paths (e.g., auth failures).logplex channel for non-critical logs (e.g., info level).stack channel for all logs, deprecating legacy handlers.PaymentBlock).LOGPLEX_LEVEL) based on noise analysis.| Component | Compatibility Notes |
|---|---|
| Laravel Version | Tested on Laravel 8+. PHP 8.0+ required. |
| Logging Channels | Works with stack, single, or custom channels. |
| User Model | Assumes Laravel’s Illuminate\Contracts\Auth\Authenticatable. Customize if using API tokens/SSO. |
| Slack Integration | Optional. Disable via MessageBuilder if not needed. |
| Monolog Handlers | Extends Monolog\Logger, so existing handlers (e.g., StreamHandler) remain compatible. |
LOG_DRAIN_URL).composer require shureban/laravel-logplex.php artisan vendor:publish --provider="Shureban\LaravelLogplex\LogplexServiceProvider".config/logging.php:
'logplex' => [
'driver' => 'custom',
'via' => \Shureban\LaravelLogplex\LogplexLogger::class,
'level' => env('LOGPLEX_LEVEL', \Monolog\Level::Error),
],
LOG_CHANNEL=logplex
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'logplex'], // 'single' for local files
],
LOG_STACK_CHANNELS=single,logplex
app/Logging/Logplex/CustomMessageBuilder.php to extend functionality.TenantBlock for multi-tenancy support.How can I help you explore Laravel packages today?