Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,21 @@
<td>
<form id="priority-form" action="" method="get" style="display: inline">
<input type="hidden" name="panel" value="logger">
<label for="priority">Priority</label>
<label for="priority">Min. Priority</label>
<select id="priority" name="priority" onchange="document.getElementById('priority-form').submit(); ">
{# values < 0 are custom levels #}
{% for value, text in { 100: 'DEBUG', 200: 'INFO', 250: 'NOTICE', 300: 'WARNING', 400: 'ERROR', 500: 'CRITICAL', 550: 'ALERT', 600: 'EMERGENCY', '-100': 'DEPRECATION only' } %}
<option value="{{ value }}"{{ value == priority ? ' selected' : '' }}>{{ text }}</option>
{% for value, level in collector.priorities %}
{% if not priority and value > 100 %}
{% set priority = value %}
{% endif %}
<option value="{{ value }}"{{ value == priority ? ' selected' : '' }}>{{ level.name }} ({{ level.count }})</option>
{% endfor %}
{% if collector.countdeprecations %}
{% if not priority %}
{% set priority = "-100" %}
{% endif %}
<option value="-100"{{ "-100" == priority ? ' selected' : '' }}>DEPRECATION only ({{ collector.countdeprecations }})</option>
{% endif %}
</select>
<noscript>
<input type="submit" value="refresh">
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function handleFatal()
'line' => $error['line'],
);

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

if (!$this->displayErrors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public function getLogs()
return isset($this->data['logs']) ? $this->data['logs'] : array();
}

public function getPriorities()
{
return isset($this->data['priorities']) ? $this->data['priorities'] : array();
}

public function countDeprecations()
{
return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0;
Expand Down Expand Up @@ -127,9 +132,19 @@ private function computeErrorsCount()
'error_count' => $this->logger->countErrors(),
'deprecation_count' => 0,
'scream_count' => 0,
'priorities' => array(),
);

foreach ($this->logger->getLogs() as $log) {
if (isset($count['priorities'][$log['priority']])) {
++$count['priorities'][$log['priority']]['count'];
} else {
$count['priorities'][$log['priority']] = array(
'count' => 1,
'name' => $log['priorityName'],
);
}

if (isset($log['context']['type'])) {
if (ErrorHandler::TYPE_DEPRECATION === $log['context']['type']) {
++$count['deprecation_count'];
Expand All @@ -139,6 +154,8 @@ private function computeErrorsCount()
}
}

ksort($count['priorities']);

return $count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getCollectTestData
*/
public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount)
public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null)
{
$logger = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
$logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
Expand All @@ -33,42 +33,47 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount
$this->assertSame($expectedLogs ? $expectedLogs : $logs, $c->getLogs());
$this->assertSame($expectedDeprecationCount, $c->countDeprecations());
$this->assertSame($expectedScreamCount, $c->countScreams());

if (isset($expectedPriorities)) {
$this->assertSame($expectedPriorities, $c->getPriorities());
}
}

public function getCollectTestData()
{
return array(
array(
1,
array(array('message' => 'foo', 'context' => array())),
array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')),
null,
0,
0,
),
array(
1,
array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')))),
array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'))),
array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')), 'priority' => 100, 'priorityName' => 'DEBUG')),
array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'), 'priority' => 100, 'priorityName' => 'DEBUG')),
0,
0,
),
array(
1,
array(array('message' => 'foo', 'context' => array('foo' => new \stdClass()))),
array(array('message' => 'foo', 'context' => array('foo' => 'Object(stdClass)'))),
array(array('message' => 'foo', 'context' => array('foo' => new \stdClass()), 'priority' => 100, 'priorityName' => 'DEBUG')),
array(array('message' => 'foo', 'context' => array('foo' => 'Object(stdClass)'), 'priority' => 100, 'priorityName' => 'DEBUG')),
0,
0,
),
array(
1,
array(
array('message' => 'foo', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)),
array('message' => 'foo2', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)),
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'scream' => 0)),
array('message' => 'foo', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION), 'priority' => 100, 'priorityName' => 'DEBUG'),
array('message' => 'foo2', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION), 'priority' => 100, 'priorityName' => 'DEBUG'),
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'scream' => 0), 'priority' => 100, 'priorityName' => 'DEBUG'),
),
null,
2,
1,
array(100 => array('count' => 3, 'name' => 'DEBUG')),
),
);
}
Expand Down