mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-11 07:34:12 +02:00
Merge pull request #1 from pvanliefland/raven-improvements
Amended PR #203 (RavenHandler batch improvements)
This commit is contained in:
@@ -66,20 +66,25 @@ class RavenHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
public function handleBatch(array $records)
|
public function handleBatch(array $records)
|
||||||
{
|
{
|
||||||
// the last records is the "main" one
|
$level = $this->level;
|
||||||
$record = array_pop($records);
|
|
||||||
|
|
||||||
// no need to go further if the main record is not at the right level
|
// filter records based on their level
|
||||||
if ($record['level'] < $this->level) {
|
$records = array_filter($records, function($record) use($level) {
|
||||||
return;
|
return $record['level'] >= $level;
|
||||||
}
|
});
|
||||||
|
|
||||||
|
// the record with the highest severity is the "main" one
|
||||||
|
$record = array_reduce($records, function($highest, $record) {
|
||||||
|
if($record['level'] >= $highest['level']) {
|
||||||
|
$highest = $record;
|
||||||
|
|
||||||
|
return $highest;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// the other ones are added as a context item
|
// the other ones are added as a context item
|
||||||
$logs = array();
|
$logs = array();
|
||||||
foreach ($records as $r) {
|
foreach ($records as $r) {
|
||||||
if ($r['level'] < $this->level) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$logs[] = $this->processRecord($r);
|
$logs[] = $this->processRecord($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user