colinodell / psr-testlogger
基于psr/log v1的PSR-3兼容测试日志记录器,也兼容v2和v3!
v1.3.0
2023-11-29 23:03 UTC
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/log v1的PSR-3兼容测试日志记录器,也兼容v2和v3!
📦 安装
此项目需要PHP 8.0或更高版本。要使用Composer安装,只需运行
$ composer require --dev colinodell/psr-testlogger
用法
此包提供了一个PSR-3兼容的日志记录器,适用于测试。只需像平常一样记录消息,并使用许多可用方法之一对记录的消息进行断言。
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
除了标准的PSR-3日志级别外,此测试日志记录器在调用log()
时还支持自定义的string
和int
级别。其他类型不支持。
发布周期
此库被认为是稳定的。除非需要修复问题或保持与psr/log库的兼容性,否则目前没有计划进行新开发。
欢迎提交有关错误修复的问题和PR,将在需要时合并/发布。
向后兼容性
此库严格遵循SemVer,并使用Symfony的BC承诺作为指南。
报告安全问题
请直接向库作者报告安全问题,而不是使用问题跟踪器。联系信息可在composer.json
中找到。