mj-zana / logging
PSR-3 logging with channels, handlers, formatters and processors for Zana applications
v2.37.0
2026-11-20 20:29 UTC
Requires
- php: ^8.5
- mj-zana/core: ^2.4
- psr/log: ^3.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
None
Provides
Conflicts
None
Replaces
None
- dev-main
- v2.37.0
- v2.36.0
- v2.35.0
- v2.34.0
- v2.33.0
- v2.32.0
- v2.31.0
- v2.30.0
- v2.29.0
- v2.28.0
- v2.27.0
- v2.26.0
- v2.25.0
- v2.24.0
- v2.23.0
- v2.22.0
- v2.21.0
- v2.20.0
- v2.19.0
- v2.18.0
- v2.17.0
- v2.16.0
- v2.15.0
- v2.14.0
- v2.13.0
- v2.12.0
- v2.11.0
- v2.10.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- v2.0.0-rc.1
- v2.0.0-beta.3
- v2.0.0-beta.2
- v2.0.0-beta.1
- v2.0.0-alpha.3
This package is auto-updated.
Last update: 2026-11-24 16:54:42 UTC
README
A PSR-3 logger with named channels, handlers, formatters and processors. Requires PHP 8.5 or later.
composer require mj-zana/logging
Usage
Register LoggingServiceProvider and configure channels in config/logging.php:
return [ 'default' => 'app', 'channels' => [ 'app' => ['handler' => 'stream', 'path' => 'var/log/app.log', 'level' => 'info', 'formatter' => 'json'], 'audit' => ['handler' => 'stream', 'path' => 'var/log/audit.log'], 'test' => ['handler' => 'array'], ], ];
public function __construct(private LoggerInterface $logger) {} $this->logger->info('BMI {bmi} recorded for {patient}', ['bmi' => 22.5, 'patient' => $id]); $manager->channel('audit')->notice('Patient record exported');
- Handlers:
stream(a file, created with its directory, orphp://stderr),array(keeps records for tests) andnull. - Formatters:
lineandjson. Exceptions, dates, objects and resources in the context are normalized. - Without configuration: the default channel logs warnings and above to
php://stderr.
LogContext values (for example the correlation id that mj-zana/http sets for
each request) are added to every record's extra.
License
MIT — see LICENSE.