filisko / fake-psr3-logger
Fake PSR-3 logger implementation for integration testing
v1.1.0
2025-05-12 12:41 UTC
Requires
- php: >=7.1
- psr/log: ^1 || ^2 || ^3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- phpstan/phpstan: ^1 || ^2
- phpunit/phpunit: ^7 || ^8 || ^9
- squizlabs/php_codesniffer: ^3
Provides
- psr/log-implementation: ^1 || ^2 || ^3
README
A package that provides a simple PSR-3 implementation for integration tests.
Requirements
- PHP >= 7.1
Installation
This package is installable and autoloadable via Composer as filisko/fake-psr3-logger.
composer require filisko/fake-psr3-logger --dev
Usage
This package provides a PSR-3 (Psr\Log\LoggerInterface
) implementation that allows you to verify the logging your code has made.
use Filisko\FakeLogger; // PHP Unit scenario $logger = new FakeLogger(); $logger->info('Something interesting happened', [ 'user_id' => 1 ]); // logs exposed $logs = $logger->logs(); $this->assertSame([ [ 'level' => 'info', 'message' => 'Something interesting happened', 'context' => [ 'user_id' => 1, ], ] ], $logs); $this->assertSame(1, $logger->count());
Other testing utilities
- PSR-16 fake cache: kodus/mock-cache
- PSR-15 middleware dispatcher: middlewares/utils (used in conjuction with PSR-7 and PSR-17)
- Testable PHP functions: filisko/testable-phpfunctions
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.