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 Implementations Laravel Package

psr-discovery/log-implementations

Discover available PSR-3 logger implementations at runtime without hard dependencies. Searches for well-known classes and returns the first compatible LoggerInterface instance, ideal for SDKs and libraries; supports multiple popular loggers and mocking/testing options.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Standardized Logging for Laravel Ecosystem Packages: Enable Laravel packages (e.g., auth, payment gateways, analytics) to support PSR-3 logging without forcing users to configure dependencies. Reduces friction for developers integrating your package into Laravel apps. Example: A package could auto-detect Monolog (Laravel’s default) or Laminas Log without requiring explicit setup.

  • Decoupled Plugin Architecture: Build modular Laravel plugins where logging is optional but pluggable. Users can inject their preferred logger (e.g., Monolog, Cloud Logging) without breaking changes. Aligns with Laravel’s service provider pattern for extensibility.

  • Testing and CI/CD Optimization: Prioritize mock implementations (e.g., psr-mock/log-implementation) in PHPUnit/Pest tests to eliminate flaky tests caused by real logging dependencies. Ensures CI pipelines run faster and more reliably.

  • Roadmap: "Bring Your Own Logger" (BYOL) for Laravel: Justify a BYOL feature in your Laravel package by leveraging this package to auto-detect and delegate to user-provided loggers. Reduces support overhead for edge cases (e.g., users with custom logging setups).

  • Build vs. Buy Decision: Buy: Use this package to avoid reinventing logger discovery logic in Laravel packages. Build: Only if you need custom discovery rules (e.g., prioritizing Laravel’s built-in logger or cloud-specific loggers like google/cloud-logging).

  • Performance-Critical Packages: Reduce bundle size and startup overhead by avoiding hard dependencies on logging libraries. Ideal for Laravel packages where performance is critical (e.g., high-frequency APIs, real-time systems).


When to Consider This Package

Adopt if:

  • You’re building a Laravel package (not an end-user app) that needs to support PSR-3 logging without hard dependencies.
  • You want to simplify integration by auto-detecting loggers (e.g., "Just use Laravel’s default logger, or install Monolog/Laminas if you prefer").
  • Testing is a priority: Mock priority ensures tests run without real logging dependencies, speeding up CI/CD pipelines.
  • Your package targets PHP 8.2+ and Laravel 10+ (no legacy compatibility needed).
  • You need minimal configuration for logging support (e.g., no config/logging.php required).

Look elsewhere if:

  • You’re building a Laravel application (not a package) and need full control over logging (use Laravel’s built-in logging or Monolog directly).
  • Your package requires custom logger discovery logic (e.g., environment-specific fallbacks or Laravel-specific integrations like Log::channel()).
  • You need advanced Laravel-specific logging features (e.g., stack drivers, channel-specific logging) beyond PSR-3 (use Laravel’s logging directly or extend Monolog).
  • Your package supports PHP < 8.2 (upgrade or use a legacy fork like psr-discovery/log-implementations:^1.0).
  • You’re building a microservice where logging is tightly coupled to the framework (e.g., using Laravel’s Log facade exclusively).

How to Pitch It (Stakeholders)

For Executives: "This package lets our Laravel packages automatically use the customer’s preferred logger—whether it’s Laravel’s default, Monolog, or Laminas—without forcing them to configure anything. It’s like ‘auto-detect’ for logging, which reduces support tickets, speeds up integrations, and keeps our packages lean. For example, a developer using our payment gateway package can just install Monolog if they want, and our package will use it seamlessly. Mock support also ensures our tests run faster and more reliably in CI/CD. This is a no-brainer for packages targeting the Laravel ecosystem."

For Engineering (Laravel Team): *"This solves the ‘chicken-and-egg’ problem of requiring users to configure logging in our Laravel packages. Key benefits:

  • Zero forced dependencies: Users choose their logger; we auto-detect it. No more ‘install Monolog to use our package’ friction.
  • Test-friendly: Mock implementations are prioritized in dev environments, so our tests run faster and don’t depend on real logging.
  • Extensible: We can prefer() or use() specific loggers if needed (e.g., for cloud integrations or Laravel-specific setups).
  • PSR-compliant: Aligns with Laravel’s existing logging ecosystem (Monolog, PSR-3), making our packages easier to adopt.

Tradeoff: We cede some control over logging behavior, but the flexibility outweighs the cost for a Laravel package. Example use case: Our analytics module can now log to any PSR-3-compatible system without breaking changes or requiring user configuration.*

For Developers (Package Contributors): *"Add this to your Laravel package’s composer.json:

composer require psr-discovery/log-implementations

Then use Discover::log() to get a PSR-3 logger instance. It’ll pick the first available logger (or a mock in tests). No config needed—just works. Need to force a specific logger? Use:

use PsrDiscovery\Implementations\Psr3\Logs;
Logs::use('monolog/monolog'); // Force Monolog
$log = Discover::log();

Or prefer Laravel’s default logger:

Logs::prefer('monolog/monolog'); // Prefer Monolog over others

Works seamlessly with Laravel’s service container and testing tools like Pest/PHPUnit."*

For Laravel Core Team (if proposing integration): *"This package could be integrated into Laravel’s core to enable ‘auto-detect’ logging for third-party packages. For example:

  • Extend Log::driver() to delegate to Discover::log() for dynamic resolution.
  • Provide a LogServiceProvider that falls back to discovered loggers if no config is set.
  • Use Discover::logs() to inspect available implementations for runtime decisions (e.g., feature flags based on logging capabilities).

This would reduce the barrier for packages to support logging without requiring users to configure config/logging.php."*

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.
terminal42/code-quality-tools
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