Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81d9b9d

Browse files
committed
Show silenced errors in separate tab
1 parent 7ed176f commit 81d9b9d

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
</div>
5454
{% else %}
5555
{# sort collected logs in groups #}
56-
{% set deprecation_logs, debug_logs, info_and_error_logs = [], [], [] %}
56+
{% set deprecation_logs, debug_logs, info_and_error_logs, silenced_logs = [], [], [], [] %}
5757
{% for log in collector.logs %}
5858
{% if log.context.level is defined and log.context.type is defined and log.context.type in [constant('E_DEPRECATED'), constant('E_USER_DEPRECATED')] %}
5959
{% set deprecation_logs = deprecation_logs|merge([log]) %}
60+
{% elseif log.context.scream is defined and log.context.scream == true %}
61+
{% set silenced_logs = silenced_logs|merge([log]) %}
6062
{% elseif log.priorityName == 'DEBUG' %}
6163
{% set debug_logs = debug_logs|merge([log]) %}
6264
{% else %}
@@ -108,6 +110,21 @@
108110
{% endif %}
109111
</div>
110112
</div>
113+
114+
<div class="tab">
115+
<h3 class="tab-title">Silenced Errors <span class="badge">{{ collector.countscreams|default(0) }}</span></h3>
116+
117+
<div class="tab-content">
118+
{% if silenced_logs is empty %}
119+
<div class="empty">
120+
<p>There are no log messages of this level.</p>
121+
</div>
122+
{% else %}
123+
{{ helper.render_table(silenced_logs) }}
124+
{% endif %}
125+
</div>
126+
</div>
127+
111128
</div>
112129
{% endif %}
113130
{% endblock %}

src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@
2222
*/
2323
class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface
2424
{
25+
private $errorNames = array(
26+
E_DEPRECATED => 'E_DEPRECATED',
27+
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
28+
E_NOTICE => 'E_NOTICE',
29+
E_USER_NOTICE => 'E_USER_NOTICE',
30+
E_STRICT => 'E_STRICT',
31+
E_WARNING => 'E_WARNING',
32+
E_USER_WARNING => 'E_USER_WARNING',
33+
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
34+
E_CORE_WARNING => 'E_CORE_WARNING',
35+
E_USER_ERROR => 'E_USER_ERROR',
36+
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
37+
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
38+
E_PARSE => 'E_PARSE',
39+
E_ERROR => 'E_ERROR',
40+
E_CORE_ERROR => 'E_CORE_ERROR',
41+
);
42+
2543
private $logger;
2644

2745
public function __construct($logger = null)
@@ -106,6 +124,9 @@ private function sanitizeLogs($logs)
106124
if (isset($context['type'], $context['file'], $context['line'], $context['level'])) {
107125
$errorId = md5("{$context['type']}/{$context['line']}/{$context['file']}\x00{$log['message']}", true);
108126
$silenced = !($context['type'] & $context['level']);
127+
if (isset($this->errorNames[$context['type']])) {
128+
$context = array_merge(array('name' => $this->errorNames[$context['type']]), $context);
129+
}
109130

110131
if (isset($errorContextById[$errorId])) {
111132
if (isset($errorContextById[$errorId]['errorCount'])) {

src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function getCollectTestData()
7575
),
7676
array(
7777
1,
78-
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG')),
79-
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')),
78+
array(array('message' => 'foo3', 'context' => array('name' => 'E_USER_WARNING', 'type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG')),
79+
array(array('message' => 'foo3', 'context' => array('name' => 'E_USER_WARNING', 'type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')),
8080
0,
8181
1,
8282
),
@@ -86,7 +86,7 @@ public function getCollectTestData()
8686
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'),
8787
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'),
8888
),
89-
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123, 'errorCount' => 2), 'priority' => 100, 'priorityName' => 'DEBUG')),
89+
array(array('message' => 'foo3', 'context' => array('name' => 'E_USER_WARNING', 'type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123, 'errorCount' => 2), 'priority' => 100, 'priorityName' => 'DEBUG')),
9090
0,
9191
1,
9292
),

0 commit comments

Comments
 (0)