[FrameworkBundle] Treat all log messages >=ERR as errors

This commit is contained in:
Jordi Boggiano 2011-05-02 18:31:51 +02:00
parent fc3be8a7cf
commit 25d7009c1c
2 changed files with 10 additions and 4 deletions

View File

@ -1,7 +1,8 @@
<ol class="traces">
{% for log in logs %}
<li>
{% if 'ERR' == log.priorityName %}
{% if 'EMERG' == log.priorityName or 'ERR' == log.priorityName or 'CRIT' == log.priorityName
or 'ALERT' == log.priorityName or 'ERROR' == log.priorityName or 'CRITICAL' == log.priorityName %}
<em>{{ log.priorityName }}</em>
{% else %}
{{ log.priorityName }}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\MonologBundle\Logger;
use Monolog\Logger;
use Monolog\Handler\TestHandler;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
@ -43,8 +44,12 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
*/
public function countErrors()
{
return isset($this->recordsByLevel[\Monolog\Logger::ERROR])
? count($this->recordsByLevel[\Monolog\Logger::ERROR])
: 0;
$cnt = 0;
foreach (array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT) as $level) {
if (isset($this->recordsByLevel[$level])) {
$cnt += count($this->recordsByLevel[$level])
}
}
return $cnt;
}
}