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

made raven user context less destructive

This commit is contained in:
Stepan Mazurov
2015-04-13 19:22:16 -06:00
parent a54d460500
commit 09be78d62a
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);
}
/**