1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-28 19:14:04 +01:00

Merge branch '1.x'

This commit is contained in:
Jordi Boggiano
2016-11-13 20:26:27 +01:00
5 changed files with 51 additions and 6 deletions

View File

@@ -76,6 +76,7 @@ class LineFormatter extends NormalizerFormatter
}
}
foreach ($vars['context'] as $var => $val) {
if (false !== strpos($output, '%context.'.$var.'%')) {
$output = str_replace('%context.'.$var.'%', $this->stringify($val), $output);
@@ -101,6 +102,11 @@ class LineFormatter extends NormalizerFormatter
}
}
// remove leftover %extra.xxx% and %context.xxx% if any
if (false !== strpos($output, '%')) {
$output = preg_replace('/%(?:extra|context)\..+?%/', '', $output);
}
return $output;
}

View File

@@ -112,7 +112,7 @@ class AmqpHandler extends AbstractProcessingHandler
* @param array $record
* @return string
*/
private function getRoutingKey(array $record)
protected function getRoutingKey(array $record)
{
$routingKey = sprintf('%s.%s', $record['level_name'], $record['channel']);

View File

@@ -84,7 +84,7 @@ class RavenHandler extends AbstractProcessingHandler
// the record with the highest severity is the "main" one
$record = array_reduce($records, function ($highest, $record) {
if ($record['level'] >= $highest['level']) {
if ($record['level'] > $highest['level']) {
return $record;
}

View File

@@ -58,6 +58,8 @@ class RollbarHandler extends AbstractProcessingHandler
*/
private $hasRecords = false;
protected $initialized = false;
/**
* @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
* @param int $level The minimum logging level at which this handler will be triggered
@@ -75,6 +77,12 @@ class RollbarHandler extends AbstractProcessingHandler
*/
protected function write(array $record)
{
if (!$this->initialized) {
// __destructor() doesn't get called on Fatal errors
register_shutdown_function(array($this, 'close'));
$this->initialized = true;
}
$context = $record['context'];
$payload = [];
if (isset($context['payload'])) {
@@ -105,14 +113,19 @@ class RollbarHandler extends AbstractProcessingHandler
$this->hasRecords = true;
}
/**
* {@inheritdoc}
*/
public function close()
public function flush()
{
if ($this->hasRecords) {
$this->rollbarNotifier->flush();
$this->hasRecords = false;
}
}
/**
* {@inheritdoc}
*/
public function close()
{
$this->flush();
}
}