mirror of
https://github.com/zhamao-robot/zhamao-logger.git
synced 2026-03-17 20:44:52 +08:00
31 lines
630 B
PHP
31 lines
630 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Tests;
|
||
|
|
|
||
|
|
use Psr\Log\LoggerInterface;
|
||
|
|
use Psr\Log\LogLevel;
|
||
|
|
use ZM\Logger\ConsoleLogger;
|
||
|
|
|
||
|
|
class TestCase extends \PHPUnit\Framework\TestCase
|
||
|
|
{
|
||
|
|
protected $logs = [];
|
||
|
|
|
||
|
|
protected function getLogger(): LoggerInterface
|
||
|
|
{
|
||
|
|
$logger = new ConsoleLogger(LogLevel::DEBUG);
|
||
|
|
$logger::$format = '%body%';
|
||
|
|
$logger->addLogCallback(function ($level, $output, $message, $context) {
|
||
|
|
$this->logs[] = $output;
|
||
|
|
return false;
|
||
|
|
});
|
||
|
|
return $logger;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function getLogs(): array
|
||
|
|
{
|
||
|
|
return $this->logs;
|
||
|
|
}
|
||
|
|
}
|