Logging
This commit is contained in:
parent
f1d46dacb6
commit
75ce822b84
6 changed files with 399 additions and 1 deletions
36
tests/Logging/CustomLogger.php
Normal file
36
tests/Logging/CustomLogger.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Logging;
|
||||
|
||||
use Psr\Log\AbstractLogger;
|
||||
|
||||
class CustomLogger extends AbstractLogger
|
||||
{
|
||||
public array $logs = [];
|
||||
|
||||
public function log($level, string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->logs[] = [
|
||||
'level' => $level,
|
||||
'message' => $message,
|
||||
'context' => $context,
|
||||
];
|
||||
}
|
||||
|
||||
public function hasLog(string $level, string $contains): bool
|
||||
{
|
||||
foreach ($this->logs as $log) {
|
||||
if ($log['level'] === $level && str_contains($log['message'], $contains)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->logs = [];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue