psr/log
The PSR-3 common logger interface that lets PHP libraries accept any logger without depending on a specific implementation.
Repository Health
Technical Analysis
psr/log is the reference implementation of PSR-3, the PHP-FIG standard that defines a common LoggerInterface for logging libraries. It ships no logging backend of its own — no file writers, no formatters — only the interface, a LogLevel constants class, an AbstractLogger/LoggerTrait base implementation, a NullLogger no-op, and a LoggerAwareInterface/LoggerAwareTrait pair for injecting a logger into consumer classes. Because nearly every major PHP framework and logging library (Monolog, Symfony, Laravel’s underlying stack, Guzzle) type-hints against Psr\Log\LoggerInterface rather than a concrete class, packages that accept a PSR-3 logger can be wired up to whichever logging implementation the application already uses, with zero coupling to that implementation’s internals.
What You Get
Psr\Log\LoggerInterfacewith the eight RFC 5424 severity levels (emergency, alert, critical, error, warning, notice, info, debug) plus a genericlog($level, $message, $context)methodPsr\Log\LogLevel— a constants class enumerating the eight level strings for type-safe comparisonsPsr\Log\AbstractLoggerandPsr\Log\LoggerTrait— base implementations that let you implement onlylog()and get the eight level-specific methods for freePsr\Log\NullLogger— a no-op implementation for disabling logging or satisfying a required constructor argument in testsPsr\Log\LoggerAwareInterfaceandPsr\Log\LoggerAwareTrait— a standardsetLogger()contract for injecting a logger into any class after construction
Common Use Cases
- Accepting an optional logger constructor argument in a library so consumers can plug in Monolog, Symfony’s logger, or any PSR-3-compatible implementation
- Writing framework-agnostic packages that need to emit log messages without pulling in a concrete logging dependency
- Using
NullLoggeras a safe default when no logger is configured, avoiding null checks scattered through the codebase - Implementing
LoggerAwareInterfaceso a DI container can inject a logger into any service that declares the trait
Under The Hood
Architecture - The package is purely a set of interfaces, a small enum-like constants class (LogLevel), and thin trait/abstract-class helpers; there is no runtime logic beyond LoggerTrait::log() delegating to the appropriate level method and NullLogger swallowing all calls. Consumers depend on LoggerInterface and receive whatever concrete logger implementation (e.g. Monolog) the application wires in, so the actual log-writing behavior lives entirely outside this repository. Tech Stack - Plain PHP 8+ with PSR-4 autoloading (Psr\Log\ mapped to src/) and no runtime dependencies at all; the package only declares a php: >=8.0.0 platform requirement in composer.json. Code Quality - The codebase is deliberately minimal — eight small files, each under 100 lines, with typed method signatures and PHPDoc blocks on every interface method describing expected $level, $message, and $context semantics; there is no test suite in the repository since there is no executable behavior to test beyond NullLogger and LoggerTrait, which are exercised indirectly by every downstream implementation’s own test suite. API Design - The interface mirrors the RFC 5424 syslog severity levels exactly, which any PHP developer already familiar with logging conventions will recognize instantly; the eight level methods plus one generic log() method give implementers freedom in how messages are formatted while giving consumers a single, ubiquitous type to depend on.
Used by 5 apps in this directory
EspoCRM
Marketing · Ecommerce · CRM
Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.
FreeScout
Customer Support
Run your own help desk and shared inbox — a fully self-hosted, open-source alternative to Zendesk and Help Scout with no per-agent fees.
Kimai
Invoicing Finance · Project Management
Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.
matomo
Analytics
Open-source, privacy-first web and app analytics that puts you in complete control of your data.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.