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 3e6c940

Browse filesBrowse files
[WebProfilerBundle] enhance logs display
1 parent 71dc07c commit 3e6c940
Copy full SHA for 3e6c940

File tree

Expand file treeCollapse file tree

4 files changed

+44
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+44
-13
lines changed
Open diff view settings
Collapse file

‎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
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,21 @@
6262
<td>
6363
<form id="priority-form" action="" method="get" style="display: inline">
6464
<input type="hidden" name="panel" value="logger">
65-
<label for="priority">Priority</label>
65+
<label for="priority">Min. Priority</label>
6666
<select id="priority" name="priority" onchange="document.getElementById('priority-form').submit(); ">
6767
{# values < 0 are custom levels #}
68-
{% for value, text in { 100: 'DEBUG', 200: 'INFO', 250: 'NOTICE', 300: 'WARNING', 400: 'ERROR', 500: 'CRITICAL', 550: 'ALERT', 600: 'EMERGENCY', '-100': 'DEPRECATION only' } %}
69-
<option value="{{ value }}"{{ value == priority ? ' selected' : '' }}>{{ text }}</option>
68+
{% for value, level in collector.priorities %}
69+
{% if not priority and value > 100 %}
70+
{% set priority = value %}
71+
{% endif %}
72+
<option value="{{ value }}"{{ value == priority ? ' selected' : '' }}>{{ level.name }} ({{ level.count }})</option>
7073
{% endfor %}
74+
{% if collector.countdeprecations %}
75+
{% if not priority %}
76+
{% set priority = "-100" %}
77+
{% endif %}
78+
<option value="-100"{{ "-100" == priority ? ' selected' : '' }}>DEPRECATION only ({{ collector.countdeprecations }})</option>
79+
{% endif %}
7180
</select>
7281
<noscript>
7382
<input type="submit" value="refresh">
Collapse file

‎src/Symfony/Component/Debug/ErrorHandler.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ErrorHandler.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function handleFatal()
278278
'line' => $error['line'],
279279
);
280280

281-
self::$loggers['emergency']->emerg($error['message'], $fatal);
281+
self::$loggers['emergency']->emergency($error['message'], $fatal);
282282
}
283283

284284
if (!$this->displayErrors) {
Collapse file

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public function getLogs()
7373
return isset($this->data['logs']) ? $this->data['logs'] : array();
7474
}
7575

76+
public function getPriorities()
77+
{
78+
return isset($this->data['priorities']) ? $this->data['priorities'] : array();
79+
}
80+
7681
public function countDeprecations()
7782
{
7883
return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0;
@@ -127,9 +132,19 @@ private function computeErrorsCount()
127132
'error_count' => $this->logger->countErrors(),
128133
'deprecation_count' => 0,
129134
'scream_count' => 0,
135+
'priorities' => array(),
130136
);
131137

132138
foreach ($this->logger->getLogs() as $log) {
139+
if (isset($count['priorities'][$log['priority']])) {
140+
++$count['priorities'][$log['priority']]['count'];
141+
} else {
142+
$count['priorities'][$log['priority']] = array(
143+
'count' => 1,
144+
'name' => $log['priorityName'],
145+
);
146+
}
147+
133148
if (isset($log['context']['type'])) {
134149
if (ErrorHandler::TYPE_DEPRECATION === $log['context']['type']) {
135150
++$count['deprecation_count'];
@@ -139,6 +154,8 @@ private function computeErrorsCount()
139154
}
140155
}
141156

157+
ksort($count['priorities']);
158+
142159
return $count;
143160
}
144161
}
Collapse file

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
1919
/**
2020
* @dataProvider getCollectTestData
2121
*/
22-
public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount)
22+
public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null)
2323
{
2424
$logger = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
2525
$logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
@@ -33,42 +33,47 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount
3333
$this->assertSame($expectedLogs ? $expectedLogs : $logs, $c->getLogs());
3434
$this->assertSame($expectedDeprecationCount, $c->countDeprecations());
3535
$this->assertSame($expectedScreamCount, $c->countScreams());
36+
37+
if (isset($expectedPriorities)) {
38+
$this->assertSame($expectedPriorities, $c->getPriorities());
39+
}
3640
}
3741

3842
public function getCollectTestData()
3943
{
4044
return array(
4145
array(
4246
1,
43-
array(array('message' => 'foo', 'context' => array())),
47+
array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')),
4448
null,
4549
0,
4650
0,
4751
),
4852
array(
4953
1,
50-
array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')))),
51-
array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'))),
54+
array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')), 'priority' => 100, 'priorityName' => 'DEBUG')),
55+
array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'), 'priority' => 100, 'priorityName' => 'DEBUG')),
5256
0,
5357
0,
5458
),
5559
array(
5660
1,
57-
array(array('message' => 'foo', 'context' => array('foo' => new \stdClass()))),
58-
array(array('message' => 'foo', 'context' => array('foo' => 'Object(stdClass)'))),
61+
array(array('message' => 'foo', 'context' => array('foo' => new \stdClass()), 'priority' => 100, 'priorityName' => 'DEBUG')),
62+
array(array('message' => 'foo', 'context' => array('foo' => 'Object(stdClass)'), 'priority' => 100, 'priorityName' => 'DEBUG')),
5963
0,
6064
0,
6165
),
6266
array(
6367
1,
6468
array(
65-
array('message' => 'foo', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)),
66-
array('message' => 'foo2', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)),
67-
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'scream' => 0)),
69+
array('message' => 'foo', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION), 'priority' => 100, 'priorityName' => 'DEBUG'),
70+
array('message' => 'foo2', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION), 'priority' => 100, 'priorityName' => 'DEBUG'),
71+
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'scream' => 0), 'priority' => 100, 'priorityName' => 'DEBUG'),
6872
),
6973
null,
7074
2,
7175
1,
76+
array(100 => array('count' => 3, 'name' => 'DEBUG')),
7277
),
7378
);
7479
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.