summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-10-22 09:25:13 -0400
committerEvan Prodromou <evan@status.net>2010-10-22 09:25:13 -0400
commit07bc50eaedd262573bf1560b075670d803e17a63 (patch)
tree1a1b77ff2742b41f7236cd494ab2c1589c7a93c9
parente1e79e62360191626fbb3eae9f5d2af249780ac9 (diff)
parent2484d8edc2acfd37af5e56e0c7d5c5632f85a91b (diff)
Merge branch 'bettercachelog' into 0.9.x
-rw-r--r--plugins/CacheLog/CacheLogPlugin.php43
1 files changed, 25 insertions, 18 deletions
diff --git a/plugins/CacheLog/CacheLogPlugin.php b/plugins/CacheLog/CacheLogPlugin.php
index 5b0b43935..ab9538df0 100644
--- a/plugins/CacheLog/CacheLogPlugin.php
+++ b/plugins/CacheLog/CacheLogPlugin.php
@@ -61,36 +61,26 @@ class CacheLogPlugin extends Plugin
function onEndCacheGet($key, &$value)
{
if ($value === false) {
- $this->log(LOG_INFO, "Cache MISS for key '$key'");
+ $this->log(LOG_INFO, sprintf('Cache MISS for key "%s"', $key));
} else {
- $this->log(LOG_INFO, "Cache HIT for key '$key'");
+ $this->log(LOG_INFO, sprintf('Cache HIT for key "%s": %s', $key, self::showValue($value)));
}
return true;
}
function onStartCacheSet(&$key, &$value, &$flag, &$expiry, &$success)
{
- if (empty($value)) {
- if (is_array($value)) {
- $this->log(LOG_INFO, "Setting empty array for key '$key'");
- } else if (is_null($value)) {
- $this->log(LOG_INFO, "Setting null value for key '$key'");
- } else if (is_string($value)) {
- $this->log(LOG_INFO, "Setting empty string for key '$key'");
- } else if (is_integer($value)) {
- $this->log(LOG_INFO, "Setting integer 0 for key '$key'");
- } else {
- $this->log(LOG_INFO, "Setting empty value '$value' for key '$key'");
- }
- } else {
- $this->log(LOG_INFO, "Setting non-empty value for key '$key'");
- }
+ $this->log(LOG_INFO, "Begin setting cache value for key '$key'");
return true;
}
function onEndCacheSet($key, $value, $flag, $expiry)
{
- $this->log(LOG_INFO, "Done setting cache value for key '$key'");
+ $this->log(LOG_INFO, sprintf('Set cache value %s for key "%s" (flags: %d, expiry %d)',
+ self::showValue($value),
+ $key,
+ $flag,
+ $expiry));
return true;
}
@@ -116,4 +106,21 @@ class CacheLogPlugin extends Plugin
_m('Log reads and writes to the cache.'));
return true;
}
+
+ static function showValue($value)
+ {
+ if (is_object($value)) {
+ return sprintf('object of class %s', get_class($value));
+ } else if (is_array($value)) {
+ return sprintf('array of length %d', count($value));
+ } else if (is_string($value)) {
+ return sprintf('string "%s"', $value);
+ } else if (is_integer($value)) {
+ return sprintf('integer %d', $value);
+ } else if (is_null($value)) {
+ return 'null';
+ } else {
+ return 'unknown';
+ }
+ }
}