Skip to content

Commit

Permalink
[HttpKernel] Group deprecation notices
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas authored and fabpot committed Aug 31, 2015
1 parent a1d0f53 commit 8d6e337
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
Expand Up @@ -116,6 +116,10 @@
{% set stack = log.context.stack|default([]) %}
{% set id = 'sf-call-stack-' ~ log_index %}

{% if log.context.errorCount is defined %}
({{ log.context.errorCount }}x)
{% endif %}

{% if stack %}
<a href="#" onclick="Sfjs.toggle('{{ id }}', document.getElementById('{{ id }}-on'), document.getElementById('{{ id }}-off')); return false;">
<img class="toggle" id="{{ id }}-off" alt="-" src="data:image/gif;base64,R0lGODlhEgASAMQSANft94TG57Hb8GS44ez1+mC24IvK6ePx+Wa44dXs92+942e54o3L6W2844/M6dnu+P/+/l614P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAASABIAQAVCoCQBTBOd6Kk4gJhGBCTPxysJb44K0qD/ER/wlxjmisZkMqBEBW5NHrMZmVKvv9hMVsO+hE0EoNAstEYGxG9heIhCADs=" style="display:none">
Expand Down
Expand Up @@ -97,15 +97,46 @@ public function getName()

private function sanitizeLogs($logs)
{
foreach ($logs as $i => $log) {
$errorContextById = array();
$sanitizedLogs = array();

foreach ($logs as $log) {
$context = $this->sanitizeContext($log['context']);
if (isset($context['type'], $context['level']) && !($context['type'] & $context['level'])) {
$context['scream'] = true;

if (isset($context['type'], $context['file'], $context['line'], $context['level'])) {
$errorId = md5("{$context['type']}/{$context['line']}/{$context['file']}\x00{$log['message']}", true);
$silenced = !($context['type'] & $context['level']);

if (isset($errorContextById[$errorId])) {
if (isset($errorContextById[$errorId]['errorCount'])) {
++$errorContextById[$errorId]['errorCount'];
} else {
$errorContextById[$errorId]['errorCount'] = 2;
}

if (!$silenced && isset($errorContextById[$errorId]['scream'])) {
unset($errorContextById[$errorId]['scream']);
$errorContextById[$errorId]['level'] = $context['level'];
}

continue;
}

$errorContextById[$errorId] = &$context;
if ($silenced) {
$context['scream'] = true;
}

$log['context'] = &$context;
unset($context);
} else {
$log['context'] = $context;
}
$logs[$i]['context'] = $context;

$sanitizedLogs[] = $log;
}

return $logs;
return $sanitizedLogs;
}

private function sanitizeContext($context)
Expand Down
Expand Up @@ -75,8 +75,18 @@ public function getCollectTestData()
),
array(
1,
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0), 'priority' => 100, 'priorityName' => 'DEBUG')),
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')),
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG')),
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')),
0,
1,
),
array(
1,
array(
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'),
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'),
),
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123, 'errorCount' => 2), 'priority' => 100, 'priorityName' => 'DEBUG')),
0,
1,
),
Expand Down

0 comments on commit 8d6e337

Please sign in to comment.