Permalink
Browse files

Fixed up the logging/profiler integration.

Made several improvements to the display of information in the profiler.

Began the process of repairing memcache support.
  • Loading branch information...
1 parent 87f0521 commit f1a623a18f651a000d52039abb7f87cb511d822c @jhallbachner committed Sep 30, 2012
@@ -56,7 +56,7 @@ public function collect(Request $request, Response $response, \Exception $except
$pieces = explode('\\', $handler);
$info['availableHandlers'][] = array_pop($pieces);
}
- $info['availableHandlers'] = join(', ', $info['availableHandlers']);
+ $info['availableHandlers'] = $info['availableHandlers'];
$info['default'] = $this->defaultCache;
$this->data = $info;
@@ -119,12 +119,14 @@ public function addHandlerSettings($handler, $rootNode)
if($handler == 'Memcache') {
$finalNode = $handlerNode
- ->arrayNode('servers')
- ->prototype('array')
- ->children()
- ->scalarNode('server')->defaultIfNotSet('127.0.0.1')->end()
- ->scalarNode('port')->defaultIfNotSet('11211')->end()
- ->scalarNode('weight')->end()
+ ->children()
+ ->arrayNode('servers')
+ ->prototype('array')
+ ->children()
+ ->scalarNode('server')->defaultValue('127.0.0.1')->end()
+ ->scalarNode('port')->defaultValue('11211')->end()
+ ->scalarNode('weight')->end()
+ ->end()
->end()
->end()
;
@@ -69,7 +69,8 @@ protected function addCacheService($name, $cache, $container)
->setDefinition(sprintf('stash.%s_cache', $name), new DefinitionDecorator('stash.cache'))
->setArguments(array(
$name,
- new Reference(sprintf('stash.handler.%s_cache', $name))
+ new Reference(sprintf('stash.handler.%s_cache', $name)),
+ new Reference(sprintf('stash.logger.%s_cache', $name))
))
->setAbstract(false)
;
@@ -14,14 +14,14 @@ static function createHandler($types, $options)
foreach($types as $type) {
$class = $handlers[$type];
$opts = isset($options[$type]) ? $options[$type] : array();
- $h[] = new $class[$opts];
+ $h[] = new $class($opts);
}
if(count($h) == 1) {
return reset($h);
}
$class = $handlers['MultiHandler'];
- return new $class(array('handlers' => $h);
+ return new $class(array('handlers' => $h));
}
}
@@ -7,11 +7,21 @@
{% endset %}
{% set text %}
<div class="sf-toolbar-info-piece">
- <b>Default Handler</b> <span>{{ collector.default }}</span>
+ <b>Total Response</b> <span class="sf-toolbar-status sf-toolbar-status-green">{{ collector.calls }} / {{ collector.hits }}</span>
+ </div>
+ <div class="sf-toolbar-info-piece">
+ <b>Default Queue</b> <span>{{ collector.default }}</span>
+ </div>
+ <div class="sf-toolbar-info-piece">
+ <b>Av. Handlers</b> <span>{{ collector.handlers|join(', ') }}</span>
</div>
{% for name, details in collector.caches %}
+ <hr style="border: 1px solid #ccc;">
+ <div class="sf-toolbar-info-piece">
+ <b><i>{{ name }}</i></b> <span class="sf-toolbar-status sf-toolbar-status-green">{{ details.calls }} / {{ details.hits }}</span>
+ </div>
<div class="sf-toolbar-info-piece">
- <b>{{ name }}</b> <span class="sf-toolbar-status sf-toolbar-status-green">{{ details.calls }} / {{ details.hits }}</span>
+ <b>Handlers</b> <span>{{ details.options.handlers|join(', ') }}</span>
</div>
{% endfor %}
{% endset %}
@@ -36,7 +46,7 @@
<td>{{ collector.default }}</td>
<tr>
<th>Available Handlers</th>
- <td>{{ collector.handlers }}</td>
+ <td>{{ collector.handlers|join(', ') }}</td>
</tr>
<tr>
<th>Total Requests</th>
@@ -54,7 +64,7 @@
<table>
<tr>
<th>Handlers</th>
- <td>{{ details.options.handlers|join(',') }}</td>
+ <td>{{ details.options.handlers|join(', ') }}</td>
</tr>
<tr>
<th>Calls</th>
@@ -69,16 +79,29 @@
<h3>Handler Options</h3>
<table>
{% for name, options in details.options %}
- {% if name != 'handlers' %}
+ {% if name != 'handlers' and name in details.options.handlers %}
<tr>
<th colspan="2"><h3 style="font-size: 16px; margin-bottom: 0;">{{ name }} settings</h3></th>
</tr>
- {% for oname, ovalue in options %}
- <tr>
- <th>{{ oname }}</th>
- <td>{{ ovalue }}</td>
- </tr>
- {% endfor %}
+ {% if name == 'Memcache' %}
+ {% for ovalue in options %}
+ <tr>
+ <th>Server</th>
+ <td>{{ ovalue.server }}:{{ ovalue.port }} (weight {{ ovalue.weight }})</td>
+ </tr>
+ {% endfor %}
+ {% else %}
+ {% for oname, ovalue in options %}
+ <tr>
+ <th>{{ oname }}</th>
+ {% if oname == 'filePermissions' or oname == 'dirPermissions' %}
+ <td>{{ "%o"|format(ovalue) }}
+ {% else %}
+ <td>{{ ovalue }}</td>
+ {% endif %}
+ </tr>
+ {% endfor %}
+ {% endif %}
{% endif %}
{% endfor %}
</table>
View
@@ -27,6 +27,18 @@ public function logRequest($key, $hit, $value)
if($hit) {
$this->hits++;
}
+
+ $leader = sprintf('@@_%s_@@/', $this->name);
+ if(strpos($key, $leader) === 0) {
+ $key = substr($key, strlen($leader));
+ }
+
+ $hit = $hit ? 'true' : 'false';
+
+ ob_start();
+ print_r($value);
+ $value = sprintf('(%s) %s', gettype($value), ob_get_clean());
+
$this->queries[] = array(
'key' => $key,
'hit' => $hit,
@@ -8,7 +8,7 @@
*
* @author Josh Hall-Bachner <jhallbachner@gmail.com>
*/
-class Cache
+class CacheResultObject
{
protected $cache;
protected $logger;
View
@@ -49,7 +49,7 @@ public function get()
$handler = (isset($this->handler)) ? $this->handler : null;
$cache = new StashCache($handler);
- $stash = new CacheResultObject($cache, $logger);
+ $stash = new CacheResultObject($cache, $this->logger);
if(count($args) > 0)
$stash->setupKey($args);

0 comments on commit f1a623a

Please sign in to comment.