Skip to content

Commit

Permalink
[Profiler] Profilers now return a status which is used for visual fee…
Browse files Browse the repository at this point in the history
…dback
  • Loading branch information
vicb committed Mar 13, 2011
1 parent 66f8ed8 commit f752dd3
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 12 deletions.
Expand Up @@ -67,4 +67,11 @@ public function getName()
{
return 'db';
}

/**
* {@inheritdoc}
*/
public function getStatus() {
return $this->getQueryCount() < 10 ? self::INFO : self::WARNING;
}
}
Expand Up @@ -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 %}
Expand Down
Expand Up @@ -56,4 +56,11 @@ public function getName()
{
return 'mongodb';
}

/**
* {@inheritdoc}
*/
public function getStatus() {
return $this->getQueryCount() < 10 ? self::INFO : self::WARNING;
}
}
Expand Up @@ -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 %}
Expand Down
Expand Up @@ -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 %}
Expand Down
Expand Up @@ -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 %}
Expand Down
Expand Up @@ -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 %}
Expand Up @@ -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 %}
Expand Down
Expand Up @@ -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>
10 changes: 10 additions & 0 deletions src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php
Expand Up @@ -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);
Expand Down
Expand Up @@ -22,6 +22,10 @@
*/
interface DataCollectorInterface
{
const INFO = 'info';
const WARNING = 'warning';
const ERROR = 'error';

/**
* Collects data for the given Request and Response.
*
Expand All @@ -37,4 +41,11 @@ function collect(Request $request, Response $response, \Exception $exception = n
* @return string The collector name
*/
function getName();

/**
* Returns the status of the collector.
*
* @return string The status of the collector
*/
function getStatus();
}
Expand Up @@ -72,4 +72,12 @@ public function getName()
{
return 'logger';
}

/**
* {@inheritdoc}
*/
public function getStatus()
{
return 0 === $this->countErrors() ? self::INFO : self::ERROR;
}
}

0 comments on commit f752dd3

Please sign in to comment.