diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig index 3fb596b096..6f819e4275 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig @@ -53,10 +53,12 @@ {% else %} {# sort collected logs in groups #} - {% set deprecation_logs, debug_logs, info_and_error_logs = [], [], [] %} + {% set deprecation_logs, debug_logs, info_and_error_logs, silenced_logs = [], [], [], [] %} {% for log in collector.logs %} {% if log.context.level is defined and log.context.type is defined and log.context.type in [constant('E_DEPRECATED'), constant('E_USER_DEPRECATED')] %} {% set deprecation_logs = deprecation_logs|merge([log]) %} + {% elseif log.context.scream is defined and log.context.scream == true %} + {% set silenced_logs = silenced_logs|merge([log]) %} {% elseif log.priorityName == 'DEBUG' %} {% set debug_logs = debug_logs|merge([log]) %} {% else %} @@ -108,6 +110,21 @@ {% endif %} + +
+

Silenced Errors {{ collector.countscreams|default(0) }}

+ +
+ {% if silenced_logs is empty %} +
+

There are no log messages of this level.

+
+ {% else %} + {{ helper.render_table(silenced_logs) }} + {% endif %} +
+
+ {% endif %} {% endblock %} diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index 12584345a2..11a4cc8125 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -22,6 +22,24 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; */ class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface { + private $errorNames = array( + E_DEPRECATED => 'E_DEPRECATED', + E_USER_DEPRECATED => 'E_USER_DEPRECATED', + E_NOTICE => 'E_NOTICE', + E_USER_NOTICE => 'E_USER_NOTICE', + E_STRICT => 'E_STRICT', + E_WARNING => 'E_WARNING', + E_USER_WARNING => 'E_USER_WARNING', + E_COMPILE_WARNING => 'E_COMPILE_WARNING', + E_CORE_WARNING => 'E_CORE_WARNING', + E_USER_ERROR => 'E_USER_ERROR', + E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', + E_COMPILE_ERROR => 'E_COMPILE_ERROR', + E_PARSE => 'E_PARSE', + E_ERROR => 'E_ERROR', + E_CORE_ERROR => 'E_CORE_ERROR', + ); + private $logger; public function __construct($logger = null) @@ -106,6 +124,9 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte 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($this->errorNames[$context['type']])) { + $context = array_merge(array('name' => $this->errorNames[$context['type']]), $context); + } if (isset($errorContextById[$errorId])) { if (isset($errorContextById[$errorId]['errorCount'])) { diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index dd1608ce7f..4c1f380d41 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -75,8 +75,8 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase ), array( 1, - 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')), + array(array('message' => 'foo3', 'context' => array('name' => 'E_USER_WARNING', 'type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG')), + 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')), 0, 1, ), @@ -86,7 +86,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase 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')), + 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')), 0, 1, ),