Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 499b816

Browse filesBrowse files
committed
feature #16760 Show silenced errors in separate tab (peterrehm)
This PR was merged into the 2.8 branch. Discussion ---------- Show silenced errors in separate tab | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16740 | License | MIT | Doc PR | - Show the silenced errors in a separate tab other than the debug information to reflect also the counts of the toolbar. Also related to @javiereguiluz's comment here #10466 (comment). <img width="1119" alt="bildschirmfoto 2015-11-30 um 16 46 09" src="https://cloud.githubusercontent.com/assets/2010989/11476234/e7fc71a4-9781-11e5-8c2c-0bee587699de.png"> <img width="180" alt="bildschirmfoto 2015-11-30 um 16 47 05" src="https://cloud.githubusercontent.com/assets/2010989/11476256/04957eb4-9782-11e5-8a04-8513f076489c.png"> Commits ------- 81d9b9d Show silenced errors in separate tab
2 parents 04cbc10 + 81d9b9d commit 499b816
Copy full SHA for 499b816

File tree

Expand file treeCollapse file tree

3 files changed

+42
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+42
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig
+18-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php
+21Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
+3-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.