1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-21 16:46:11 +02:00

Merge pull request #541 from smazurov/patch-2

made raven user context less destructive
This commit is contained in:
Jordi Boggiano
2015-06-01 22:06:43 +01:00
3 changed files with 34 additions and 15 deletions

View File

@@ -127,8 +127,7 @@ class RavenHandler extends AbstractProcessingHandler
*/
protected function write(array $record)
{
// ensures user context is empty
$this->ravenClient->user_context(null);
$previousUserContext = false;
$options = array();
$options['level'] = $this->logLevels[$record['level']];
$options['tags'] = array();
@@ -149,6 +148,7 @@ class RavenHandler extends AbstractProcessingHandler
if (!empty($record['context'])) {
$options['extra']['context'] = $record['context'];
if (!empty($record['context']['user'])) {
$previousUserContext = $this->ravenClient->context->user;
$this->ravenClient->user_context($record['context']['user']);
unset($options['extra']['context']['user']);
}
@@ -160,11 +160,14 @@ class RavenHandler extends AbstractProcessingHandler
if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
$options['extra']['message'] = $record['formatted'];
$this->ravenClient->captureException($record['context']['exception'], $options);
return;
} else {
$this->ravenClient->captureMessage($record['formatted'], array(), $options);
}
if ($previousUserContext !== false) {
$this->ravenClient->user_context($previousUserContext);
}
$this->ravenClient->captureMessage($record['formatted'], array(), $options);
}
/**