diff --git a/composer.json b/composer.json index ea3e7c12..c89e1886 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "mlehner/gelf-php": "1.0.*", - "raven/raven": "0.3.*", + "raven/raven": "0.5.*", "doctrine/couchdb": "dev-master" }, "suggest": { diff --git a/src/Monolog/Handler/RavenHandler.php b/src/Monolog/Handler/RavenHandler.php index a9ea4fad..d6c58441 100644 --- a/src/Monolog/Handler/RavenHandler.php +++ b/src/Monolog/Handler/RavenHandler.php @@ -60,10 +60,8 @@ class RavenHandler extends AbstractProcessingHandler */ protected function write(array $record) { - $level = $this->logLevels[$record['level']]; - $options = array(); - $options['level'] = $level; + $options['level'] = $this->logLevels[$record['level']]; if (!empty($record['context'])) { $options['extra']['context'] = $record['context']; } @@ -71,15 +69,13 @@ class RavenHandler extends AbstractProcessingHandler $options['extra']['extra'] = $record['extra']; } - $this->ravenClient->captureMessage( - $record['formatted'], - array(), // $params - not used - version_compare(Raven_Client::VERSION, '0.1.0', '>') ? $options : $level, // $level or $options - false // $stack - ); - if ($record['level'] >= Logger::ERROR && isset($record['context']['exception'])) { - $this->ravenClient->captureException($record['context']['exception']); + if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { + $options['extra']['message'] = $record['formatted']; + $this->ravenClient->captureException($record['context']['exception'], $options); + return; } + + $this->ravenClient->captureMessage($record['formatted'], array(), $options); } /** diff --git a/tests/Monolog/Handler/MockRavenClient.php b/tests/Monolog/Handler/MockRavenClient.php index f1f54a8f..fbaab9bc 100644 --- a/tests/Monolog/Handler/MockRavenClient.php +++ b/tests/Monolog/Handler/MockRavenClient.php @@ -15,7 +15,7 @@ use Raven_Client; class MockRavenClient extends Raven_Client { - public function capture($data, $stack) + public function capture($data, $stack, $vars = null) { $this->lastData = $data; $this->lastStack = $stack;