mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-12 16:14:08 +02:00
get record with highest log level in raven batch
This commit is contained in:
@@ -80,10 +80,10 @@ class RavenHandler extends AbstractProcessingHandler
|
|||||||
// the record with the highest severity is the "main" one
|
// the record with the highest severity is the "main" one
|
||||||
$record = array_reduce($records, function($highest, $record) {
|
$record = array_reduce($records, function($highest, $record) {
|
||||||
if ($record['level'] >= $highest['level']) {
|
if ($record['level'] >= $highest['level']) {
|
||||||
$highest = $record;
|
return $record;
|
||||||
|
|
||||||
return $highest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $highest;
|
||||||
});
|
});
|
||||||
|
|
||||||
// the other ones are added as a context item
|
// the other ones are added as a context item
|
||||||
|
@@ -92,12 +92,16 @@ class RavenHandlerTest extends TestCase
|
|||||||
public function testHandleBatch()
|
public function testHandleBatch()
|
||||||
{
|
{
|
||||||
$records = $this->getMultipleRecords();
|
$records = $this->getMultipleRecords();
|
||||||
|
$records[] = $this->getRecord(Logger::WARNING, 'warning');
|
||||||
|
$records[] = $this->getRecord(Logger::WARNING, 'warning');
|
||||||
|
|
||||||
$logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
$logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
||||||
$logFormatter->expects($this->once())->method('formatBatch');
|
$logFormatter->expects($this->once())->method('formatBatch');
|
||||||
|
|
||||||
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
||||||
$formatter->expects($this->once())->method('format');
|
$formatter->expects($this->once())->method('format')->with($this->callback(function($record) {
|
||||||
|
return $record['level'] == 400;
|
||||||
|
}));
|
||||||
|
|
||||||
$handler = $this->getHandler($this->getRavenClient());
|
$handler = $this->getHandler($this->getRavenClient());
|
||||||
$handler->setBatchFormatter($logFormatter);
|
$handler->setBatchFormatter($logFormatter);
|
||||||
|
Reference in New Issue
Block a user