1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-07 05:36:45 +02:00

Fix LogRecord "extra" data leaking between handlers (#1819)

Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
This commit is contained in:
Cosmin Ardeleanu
2023-10-27 17:54:39 +03:00
committed by GitHub
parent 8ff4ab5c94
commit b0f4bf7eb7
9 changed files with 128 additions and 19 deletions

View File

@@ -11,6 +11,7 @@
namespace Monolog\Handler;
use Monolog\LogRecord;
use Monolog\Test\TestCase;
use Monolog\Level;
@@ -117,4 +118,37 @@ class GroupHandlerTest extends TestCase
$this->assertTrue($records[1]['extra']['foo2']);
}
}
public function testProcessorsDoNotInterfereBetweenHandlers()
{
$t1 = new TestHandler();
$t2 = new TestHandler();
$handler = new GroupHandler([$t1, $t2]);
$t1->pushProcessor(function (LogRecord $record) {
$record->extra['foo'] = 'bar';
return $record;
});
$handler->handle($this->getRecord());
self::assertSame([], $t2->getRecords()[0]->extra);
}
public function testProcessorsDoNotInterfereBetweenHandlersWithBatch()
{
$t1 = new TestHandler();
$t2 = new TestHandler();
$handler = new GroupHandler([$t1, $t2]);
$t1->pushProcessor(function (LogRecord $record) {
$record->extra['foo'] = 'bar';
return $record;
});
$handler->handleBatch([$this->getRecord()]);
self::assertSame([], $t2->getRecords()[0]->extra);
}
}