1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 14:16:42 +02:00

Fix bug with level in GitProcessor (#1749)

This commit is contained in:
Grégoire Pineau
2022-08-17 23:30:28 +02:00
committed by GitHub
parent 8471abd5ef
commit 5df3238664
2 changed files with 13 additions and 1 deletions

View File

@@ -44,7 +44,7 @@ class GitProcessor implements ProcessorInterface
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord
{ {
// return if the level is not high enough // return if the level is not high enough
if ($record->level < $this->level) { if ($record->level->isLowerThan($this->level)) {
return $record; return $record;
} }

View File

@@ -11,6 +11,7 @@
namespace Monolog\Processor; namespace Monolog\Processor;
use Monolog\Level;
use Monolog\Test\TestCase; use Monolog\Test\TestCase;
class GitProcessorTest extends TestCase class GitProcessorTest extends TestCase
@@ -26,4 +27,15 @@ class GitProcessorTest extends TestCase
$this->assertArrayHasKey('git', $record->extra); $this->assertArrayHasKey('git', $record->extra);
$this->assertTrue(!is_array($record->extra['git']['branch'])); $this->assertTrue(!is_array($record->extra['git']['branch']));
} }
/**
* @covers Monolog\Processor\GitProcessor::__invoke
*/
public function testProcessorWithLevel()
{
$processor = new GitProcessor(Level::Error);
$record = $processor($this->getRecord());
$this->assertArrayNotHasKey('git', $record->extra);
}
} }