mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 12:17:35 +02:00
Fix WhatFailureGroupHandler::handleBatch when the handler has processors
This commit is contained in:
committed by
Jordi Boggiano
parent
22b92c7c00
commit
3035d4a251
@@ -48,6 +48,16 @@ class WhatFailureGroupHandler extends GroupHandler
|
|||||||
*/
|
*/
|
||||||
public function handleBatch(array $records)
|
public function handleBatch(array $records)
|
||||||
{
|
{
|
||||||
|
if ($this->processors) {
|
||||||
|
$processed = array();
|
||||||
|
foreach ($records as $record) {
|
||||||
|
foreach ($this->processors as $processor) {
|
||||||
|
$processed[] = call_user_func($processor, $record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$records = $processed;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->handlers as $handler) {
|
foreach ($this->handlers as $handler) {
|
||||||
try {
|
try {
|
||||||
$handler->handleBatch($records);
|
$handler->handleBatch($records);
|
||||||
|
@@ -87,6 +87,29 @@ class WhatFailureGroupHandlerTest extends TestCase
|
|||||||
$this->assertTrue($records[0]['extra']['foo']);
|
$this->assertTrue($records[0]['extra']['foo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Monolog\Handler\WhatFailureGroupHandler::handleBatch
|
||||||
|
*/
|
||||||
|
public function testHandleBatchUsesProcessors()
|
||||||
|
{
|
||||||
|
$testHandlers = array(new TestHandler(), new TestHandler());
|
||||||
|
$handler = new WhatFailureGroupHandler($testHandlers);
|
||||||
|
$handler->pushProcessor(function ($record) {
|
||||||
|
$record['extra']['foo'] = true;
|
||||||
|
|
||||||
|
return $record;
|
||||||
|
});
|
||||||
|
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
|
||||||
|
foreach ($testHandlers as $test) {
|
||||||
|
$this->assertTrue($test->hasDebugRecords());
|
||||||
|
$this->assertTrue($test->hasInfoRecords());
|
||||||
|
$this->assertTrue(count($test->getRecords()) === 2);
|
||||||
|
$records = $test->getRecords();
|
||||||
|
$this->assertTrue($records[0]['extra']['foo']);
|
||||||
|
$this->assertTrue($records[1]['extra']['foo']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Monolog\Handler\WhatFailureGroupHandler::handle
|
* @covers Monolog\Handler\WhatFailureGroupHandler::handle
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user