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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user