From 4551b8c63b4617438e7c1f47a7deb014dd4bed75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Sat, 15 Aug 2015 17:58:48 +0200 Subject: [PATCH] RavenHandler handles custom checksums --- src/Monolog/Handler/RavenHandler.php | 8 ++++++++ tests/Monolog/Handler/RavenHandlerTest.php | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Monolog/Handler/RavenHandler.php b/src/Monolog/Handler/RavenHandler.php index c37dbf31..5a29e496 100644 --- a/src/Monolog/Handler/RavenHandler.php +++ b/src/Monolog/Handler/RavenHandler.php @@ -145,6 +145,14 @@ class RavenHandler extends AbstractProcessingHandler } else { $options['logger'] = $record['channel']; } + if (!empty($record['extra']['checksum'])) { + $options['checksum'] = $record['extra']['checksum']; + unset($record['extra']['checksum']); + } + if (!empty($record['context']['checksum'])) { + $options['checksum'] = $record['context']['checksum']; + unset($record['context']['checksum']); + } if (!empty($record['context'])) { $options['extra']['context'] = $record['context']; if (!empty($record['context']['user'])) { diff --git a/tests/Monolog/Handler/RavenHandlerTest.php b/tests/Monolog/Handler/RavenHandlerTest.php index 9a9d1006..815748d7 100644 --- a/tests/Monolog/Handler/RavenHandlerTest.php +++ b/tests/Monolog/Handler/RavenHandlerTest.php @@ -85,6 +85,18 @@ class RavenHandlerTest extends TestCase $this->assertEquals($tags, $ravenClient->lastData['tags']); } + public function testChecksum() + { + $ravenClient = $this->getRavenClient(); + $handler = $this->getHandler($ravenClient); + + $checksum = '098f6bcd4621d373cade4e832627b4f6'; + $record = $this->getRecord(Logger::INFO, 'test', array('checksum' => $checksum)); + $handler->handle($record); + + $this->assertEquals($checksum, $ravenClient->lastData['checksum']); + } + public function testUserContext() { $ravenClient = $this->getRavenClient();