antidot-fw / logger
Anti.Framework logger adapter library
Fund package maintenance!
kpicaza
Requires
- php: ~8.1.0 || ~8.2.0
- psr/http-server-middleware: ^1.0
- psr/log: ^3.0
Requires (Dev)
- icanhazstring/composer-unused: ^0.8.9
- infection/infection: ^0.27
- phpro/grumphp: ~0.17 || ~1.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^8.0 || ^9.0
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-12-01 00:11:43 UTC
README
Application PSR-15 logger middleware:
- RequestLoggerMiddleware
- ExceptionLoggerMiddleware
Installation
Require package with composer package manager.
composer require antidot-fw/logger
Add both Middleware to your Pipeline
<?php // with Antidot Framework, Zend Expressive or Zend Stratigility $app->pipe(\Antidot\Logger\Application\Http\Middleware\ExceptionLoggerMiddleware::class); $app->pipe(\Antidot\Logger\Application\Http\Middleware\RequestLoggerMiddleware::class);
Using Zend Config Aggregator
It installs the library automatically
To use both middlewares in Zend Expressive you need to create factory classes
<?php // src/App/Container/ExceptionLoggerMiddlewareFactory.php namespace App\Container; use Antidot\Logger\Application\Http\Middleware\ExceptionLoggerMiddleware; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; class ExceptionLoggerMiddlewareFactory { public function __invoke(ContainerInterface $container) { return new ExceptionLoggerMiddleware($container->get(LoggerInterface::class)); } }
<?php // src/App/Container/RequestLoggerMiddlewareFactory.php namespace App\Container; use Antidot\Logger\Application\Http\Middleware\RequestLoggerMiddleware; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; class RequestLoggerMiddlewareFactory { public function __invoke(ContainerInterface $container) { return new RequestLoggerMiddleware($container->get(LoggerInterface::class)); } }