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

Merge pull request #1281 from GreYY/fix-duplicate-record-in-group-handler

Fix create duplicate records in *GroupHandler 1.x
This commit is contained in:
Jordi Boggiano
2019-07-01 16:54:34 +02:00
committed by GitHub
4 changed files with 18 additions and 2 deletions

View File

@@ -80,8 +80,9 @@ class GroupHandler extends AbstractHandler
$processed = array();
foreach ($records as $record) {
foreach ($this->processors as $processor) {
$processed[] = call_user_func($processor, $record);
$record = call_user_func($processor, $record);
}
$processed[] = $record;
}
$records = $processed;
}

View File

@@ -52,8 +52,9 @@ class WhatFailureGroupHandler extends GroupHandler
$processed = array();
foreach ($records as $record) {
foreach ($this->processors as $processor) {
$processed[] = call_user_func($processor, $record);
$record = call_user_func($processor, $record);
}
$processed[] = $record;
}
$records = $processed;
}

View File

@@ -99,6 +99,11 @@ class GroupHandlerTest extends TestCase
return $record;
});
$handler->pushProcessor(function ($record) {
$record['extra']['foo2'] = true;
return $record;
});
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
foreach ($testHandlers as $test) {
$this->assertTrue($test->hasDebugRecords());
@@ -107,6 +112,8 @@ class GroupHandlerTest extends TestCase
$records = $test->getRecords();
$this->assertTrue($records[0]['extra']['foo']);
$this->assertTrue($records[1]['extra']['foo']);
$this->assertTrue($records[0]['extra']['foo2']);
$this->assertTrue($records[1]['extra']['foo2']);
}
}
}

View File

@@ -99,6 +99,11 @@ class WhatFailureGroupHandlerTest extends TestCase
return $record;
});
$handler->pushProcessor(function ($record) {
$record['extra']['foo2'] = true;
return $record;
});
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
foreach ($testHandlers as $test) {
$this->assertTrue($test->hasDebugRecords());
@@ -107,6 +112,8 @@ class WhatFailureGroupHandlerTest extends TestCase
$records = $test->getRecords();
$this->assertTrue($records[0]['extra']['foo']);
$this->assertTrue($records[1]['extra']['foo']);
$this->assertTrue($records[0]['extra']['foo2']);
$this->assertTrue($records[1]['extra']['foo2']);
}
}