switon / log
PSR-3 logging with automatic categories, structured context, and category-aware level filtering for Switon Framework
v1.0.0
2026-06-06 13:43 UTC
Requires
- php: >=8.3
- psr/event-dispatcher: ^1.0
- psr/log: ^2.0
- switon/core: ^1.0
- switon/event: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- switon/testing: ^1.0
README
Switon's PSR-3 logger for application services that want automatic categories, structured context, per-category filtering, and low-setup defaults.
Highlights
- Standard logger contract:
LoggerInterfaceis the main logging contract. - Automatic category routing: log categories can be derived from the caller.
- Structured context: placeholder interpolation and extra context stay structured.
- Output backends: stdout, file, syslog, and memory sinks are available.
- Category-aware filtering:
Loggerderives categories from the caller and applies per-category levels.
Installation
composer require switon/log
Quick Start
use Psr\Log\LoggerInterface; use Switon\Core\Attribute\Autowired; class UserService { #[Autowired] protected LoggerInterface $logger; public function login(int $userId): void { $this->logger->info('User logged in', ['user_id' => $userId]); } }
Docs: https://docs.switon.dev/latest/log
License
MIT.