[Profiler] Profilers now return a status which is used for visual feedback
This commit is contained in:
parent
66f8ed8e51
commit
f752dd34a0
@ -67,4 +67,11 @@ class DoctrineDataCollector extends DataCollector
|
||||
{
|
||||
return 'db';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStatus() {
|
||||
return $this->getQueryCount() < 10 ? self::INFO : self::WARNING;
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
<img width="20" height="28" alt="Database" style="vertical-align: middle; margin-right: 10px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAcCAYAAABh2p9gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQRJREFUeNpi/P//PwM1ARMDlcGogZQDlpMnT7pxc3NbA9nhQKxOpL5rQLwJiPeBsI6Ozl+YBOOOHTv+AOllQNwtLS39F2owKYZ/gRq8G4i3ggxEToggWzvc3d2Pk+1lNL4fFAs6ODi8JzdS7mMRVyDVoAMHDsANdAPiOCC+jCQvQKqBQB/BDbwBxK5AHA3E/kB8nKJkA8TMQBwLxaBIKQbi70AvTADSBiSadwFXpCikpKQU8PDwkGTaly9fHFigkaKIJid4584dkiMFFI6jkTJII0WVmpHCAixZQEXWYhDeuXMnyLsVlEQKI45qFBQZ8eRECi4DBaAlDqle/8A48ip6gAADANdQY88Uc0oGAAAAAElFTkSuQmCC"/>
|
||||
{% endset %}
|
||||
{% set text %}
|
||||
<span style="color: {{ collector.querycount < 10 ? '#000' : '#d22' }}" title="{{ '%0.2f'|format(collector.time * 1000) }} ms">{{ collector.querycount }}</span>
|
||||
<span title="{{ '%0.2f'|format(collector.time * 1000) }} ms">{{ collector.querycount }}</span>
|
||||
{% endset %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text } only %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text, 'status' : collector.status } only %}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu %}
|
||||
|
@ -56,4 +56,11 @@ class DoctrineMongoDBDataCollector extends DataCollector
|
||||
{
|
||||
return 'mongodb';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStatus() {
|
||||
return $this->getQueryCount() < 10 ? self::INFO : self::WARNING;
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
<img width="20" height="28" alt="Mongo" style="vertical-align: middle; margin-right: 10px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAcCAYAAABh2p9gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQRJREFUeNpi/P//PwM1ARMDlcGogZQDlpMnT7pxc3NbA9nhQKxOpL5rQLwJiPeBsI6Ozl+YBOOOHTv+AOllQNwtLS39F2owKYZ/gRq8G4i3ggxEToggWzvc3d2Pk+1lNL4fFAs6ODi8JzdS7mMRVyDVoAMHDsANdAPiOCC+jCQvQKqBQB/BDbwBxK5AHA3E/kB8nKJkA8TMQBwLxaBIKQbi70AvTADSBiSadwFXpCikpKQU8PDwkGTaly9fHFigkaKIJid4584dkiMFFI6jkTJII0WVmpHCAixZQEXWYhDeuXMnyLsVlEQKI45qFBQZ8eRECi4DBaAlDqle/8A48ip6gAADANdQY88Uc0oGAAAAAElFTkSuQmCC"/>
|
||||
{% endset %}
|
||||
{% set text %}
|
||||
<span style="color: {{ collector.querycount < 10 ? '#000' : '#d22' }}">{{ collector.querycount }}</span>
|
||||
<span>{{ collector.querycount }}</span>
|
||||
{% endset %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text } only %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text, 'status' : collector.status } only %}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu %}
|
||||
|
@ -15,7 +15,7 @@
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endset %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text } only %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text, 'status' : collector.status } only %}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu %}
|
||||
|
@ -7,7 +7,7 @@
|
||||
{% set text %}
|
||||
<span>{{ collector.counterrors }}</span>
|
||||
{% endset %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text } only %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text, 'status' : collector.status } only %}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu %}
|
||||
|
@ -7,5 +7,5 @@
|
||||
{% set text %}
|
||||
{{ '%.0f'|format(collector.memory / 1024) }} KB
|
||||
{% endset %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text } only %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text, 'status' : collector.status } only %}
|
||||
{% endblock %}
|
||||
|
@ -13,7 +13,7 @@
|
||||
<span style="margin: 0; padding: 0; color: #979696;">|</span>
|
||||
{{ collector.contenttype }}
|
||||
{% endset %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text } only %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text, 'status' : collector.status } only %}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu %}
|
||||
|
@ -7,5 +7,5 @@
|
||||
{% set text %}
|
||||
{{ '%.0f'|format(collector.time * 1000) }} ms
|
||||
{% endset %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text } only %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with {'icon' : icon, 'text' : text, 'status' : collector.status } only %}
|
||||
{% endblock %}
|
||||
|
@ -1,5 +1,12 @@
|
||||
<span style="white-space:nowrap; color:#2f2f2f; display:inline-block; min-height:24px; border-right:1px solid #cdcdcd; padding:5px 10px 5px 6px; ">
|
||||
{% set style = '' %}
|
||||
{% if status is defined %}
|
||||
{% if 'error' == status %}
|
||||
{% set style = 'background-color: #f66;' %}
|
||||
{% elseif 'warning' == status %}
|
||||
{% set style = 'background-color: #fa2;' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<span style="{{ style }}white-space:nowrap; color:#2f2f2f; display:inline-block; min-height:24px; border-right:1px solid #cdcdcd; padding:5px 10px 5px 6px; ">
|
||||
{% if icon is defined %}{{ icon }}{% endif %}
|
||||
{% if text is defined %}{{ text }}{% endif %}
|
||||
</span>
|
||||
|
||||
</span>
|
@ -24,6 +24,16 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
|
||||
{
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Returns the status of the collector.
|
||||
*
|
||||
* @return integer The status of the collector
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return self::INFO;
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return serialize($this->data);
|
||||
|
@ -22,6 +22,10 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
interface DataCollectorInterface
|
||||
{
|
||||
const INFO = 'info';
|
||||
const WARNING = 'warning';
|
||||
const ERROR = 'error';
|
||||
|
||||
/**
|
||||
* Collects data for the given Request and Response.
|
||||
*
|
||||
@ -37,4 +41,11 @@ interface DataCollectorInterface
|
||||
* @return string The collector name
|
||||
*/
|
||||
function getName();
|
||||
|
||||
/**
|
||||
* Returns the status of the collector.
|
||||
*
|
||||
* @return string The status of the collector
|
||||
*/
|
||||
function getStatus();
|
||||
}
|
||||
|
@ -72,4 +72,12 @@ class LoggerDataCollector extends DataCollector
|
||||
{
|
||||
return 'logger';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return 0 === $this->countErrors() ? self::INFO : self::ERROR;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user