colinodell / psr-testlogger
PSR-3 compliant test logger based on psr/log v1's, but compatible with v2 and v3 too!
Fund package maintenance!
colinodell
www.colinodell.com/sponsor
www.paypal.me/colinpodell/10.00
Installs: 5 538 333
Dependents: 24
Suggesters: 1
Security: 0
Stars: 14
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- php: ^8.0
- psr/log: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.9.2
- phpunit/phpunit: ^9.5.5
- scrutinizer/ocular: ^1.8.1
- unleashedtech/php-coding-standard: ^3.1
- vimeo/psalm: ^4.30.0
Provides
- psr/log-implementation: 1.0.0 || 2.0.0 || 3.0.0
README
PSR-3 compliant test logger based on psr/log v1's, but compatible with v2 and v3 too!
📦 Installation
This project requires PHP 8.0 or higher. To install it via Composer simply run:
$ composer require --dev colinodell/psr-testlogger
Usage
This package provides a PSR-3 compliant logger useful for testing. Simply log messages to it like usual, and use one of the many available methods to perform assertions on the logged messages.
hasRecords(string|int $level): bool
hasEmergencyRecords(): bool
hasAlertRecords(): bool
hasCriticalRecords(): bool
hasErrorRecords(): bool
hasWarningRecords(): bool
hasNoticeRecords(): bool
hasInfoRecords(): bool
hasDebugRecords(): bool
hasRecord(string|array $record, string|int $level): bool
hasEmergency(string|array $record): bool
hasAlert(string|array $record): bool
hasCritical(string|array $record): bool
hasError(string|array $record): bool
hasWarning(string|array $record): bool
hasNotice(string|array $record): bool
hasInfo(string|array $record): bool
hasDebug(string|array $record): bool
hasRecordThatContains(string $message, string|int|null $level = null): bool
hasEmergencyThatContains(string $message): bool
hasAlertThatContains(string $message): bool
hasCriticalThatContains(string $message): bool
hasErrorThatContains(string $message): bool
hasWarningThatContains(string $message): bool
hasNoticeThatContains(string $message): bool
hasInfoThatContains(string $message): bool
hasDebugThatContains(string $message): bool
hasRecordThatMatches(string $regex, string|int|null $level = null): bool
hasEmergencyThatMatches(string $regex): bool
hasAlertThatMatches(string $regex): bool
hasCriticalThatMatches(string $regex): bool
hasErrorThatMatches(string $regex): bool
hasWarningThatMatches(string $regex): bool
hasNoticeThatMatches(string $regex): bool
hasInfoThatMatches(string $regex): bool
hasDebugThatMatches(string $regex): bool
hasRecordThatPasses(callable $predicate, string|int|null $level = null): bool
hasEmergencyThatPasses(callable $predicate): bool
hasAlertThatPasses(callable $predicate): bool
hasCriticalThatPasses(callable $predicate): bool
hasErrorThatPasses(callable $predicate): bool
hasWarningThatPasses(callable $predicate): bool
hasNoticeThatPasses(callable $predicate): bool
hasInfoThatPasses(callable $predicate): bool
hasDebugThatPasses(callable $predicate): bool
In addition to the standard PSR-3 log levels, this test logger also supports custom string
and int
levels when using log()
. Other types are not supported.
Release Cycle
This library is considered stable. No new development is currently planned unless needed to fix issues or maintain compatibility with the psr/log library.
Issues and PRs for bug fixes are welcome and will be merged/released on an as-needed basis.
Backward Compatibility
This library strictly follows SemVer using Symfony's BC Promise as a guide.
Reporting Security Issues
Please report security issues directly to the library author instead of using the issue tracker. Contact info can be found in composer.json
.