phpnomad / logger
1.2.0
2026-03-31 15:22 UTC
Requires (Dev)
- phpnomad/di: ^2.0
- phpnomad/facade: ^1.0
- phpnomad/singleton: ^1.0
- phpnomad/tests: ^0.1.0 || ^0.3.0
This package is auto-updated.
Last update: 2026-04-10 02:10:31 UTC
README
phpnomad/logger defines the logging contract used throughout PHPNomad applications. It ships the LoggerStrategy interface, the CanLogException trait, and the LoggerLevel constants, and nothing else. Implementations live in other packages or in your own application code, so you can swap logging destinations without touching the code that calls the logger.
Installation
composer require phpnomad/logger
Overview
The package provides a small, focused set of building blocks:
LoggerStrategyinterface with eight level methods (emergency,alert,critical,error,warning,notice,info,debug) pluslogExceptionfor structured exception logging.CanLogExceptiontrait that implementslogExceptionby attaching the exception to context and dispatching to the configured level method (defaults tocritical).LoggerLevelconstants for the eight level strings, matching PSR-3 conventions.- Zero runtime dependencies. The package is pure abstraction.
- Pairs with
phpnomad/core, which ships an event-broadcasting strategy and a staticLoggerfacade. Transports likephpnomad/sentry-integrationsubscribe to those events in production builds.
Usage
Inject LoggerStrategy and call the appropriate level:
use PHPNomad\Logger\Interfaces\LoggerStrategy; class OrderService { public function __construct(private LoggerStrategy $logger) {} public function process(Order $order): void { $this->logger->info('Processing order', ['order_id' => $order->getId()]); } }
Documentation
Full documentation for the logger package and the rest of PHPNomad lives at phpnomad.com.
License
MIT. See LICENSE.txt.