Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: pgaultier/yii
base: b74342a949
...
head fork: pgaultier/yii
compare: 47a99df26a
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 3 contributors
Showing with 41 additions and 14 deletions.
  1. +2 −1  CHANGELOG
  2. +39 −13 framework/logging/CLogger.php
View
3  CHANGELOG 100755 → 100644
@@ -20,15 +20,16 @@ Version 1.1.11 work in progress
- Bug #618: Fixed caching of CWebUser::checkAccess() when it is called first time with and second time without $params (cebe)
- Bug #660: Fixed error when calling CDbCache::getValues (zilles)
- Bug #749: CActiveRecord::refresh() did not work in afterSave() for new records, will now always refresh, when db entry exists (cebe)
+- Bug #697: Fixed WSDLGenerator now generating proper namespace for certain complexTypes (BBoom)
- Bug: Fixed CMenu::isItemActive() to work properly when there is a hash in the item's url (SlKelevro)
- Bug: Added missing return statement to CAuthItem->revoke() (mdomba)
-- Bug #697: Fixed WSDLGenerator now generating proper namespace for certain complexTypes (BBoom)
- Bug: CHtml::resolveValue() ignoring of array elements accessor at the beginning of the $attribute argument now works properly (resurtm)
- Enh #581: Added formatSize method in CFormatter to format file sizes into units of different order - KB, MB, etc (brilyuhns, samdark)
- Enh #120: Added ability to set cookies in an object based style without specifying the cookie-name twice (suralc)
- Enh #136: Added ability to select database connection in Gii model generator (samdark)
- Enh #165: Allow CCacheDependency to be reusable across multiple cache calls (phpnode)
- Enh #171: Added support for PUT and DELETE request tunneled through POST via parameter named _method in POST body (musterknabe)
+- Enh #179: CLogger now supports filtering profile timings by multiple & wildcard categories (intel352)
- Enh #191: Added ability to customize HTML classes of CLinkPager via its public properties (mashingan)
- Enh #206: Added ability to pass CDbCriteria object as AR relation parameter (samdark)
- Enh #220: The URL pointing to the Google API in CGoogleApi is now protocol relative (suralc)
View
52 framework/logging/CLogger.php
@@ -133,20 +133,20 @@ public function getLogs($levels='',$categories='')
if(empty($levels) && empty($categories))
return $this->_logs;
else if(empty($levels))
- return array_values(array_filter(array_filter($this->_logs,array($this,'filterByCategory'))));
+ return array_values(array_filter($this->_logs,array($this,'filterByCategory')));
else if(empty($categories))
- return array_values(array_filter(array_filter($this->_logs,array($this,'filterByLevel'))));
+ return array_values(array_filter($this->_logs,array($this,'filterByLevel')));
else
{
- $ret=array_values(array_filter(array_filter($this->_logs,array($this,'filterByLevel'))));
- return array_values(array_filter(array_filter($ret,array($this,'filterByCategory'))));
+ $ret=array_filter($this->_logs,array($this,'filterByLevel'));
+ return array_values(array_filter($ret,array($this,'filterByCategory')));
}
}
/**
* Filter function used by {@link getLogs}
* @param array $value element to be filtered
- * @return array valid log, false if not.
+ * @return bool true if valid log, false if not.
*/
private function filterByCategory($value)
{
@@ -154,7 +154,23 @@ private function filterByCategory($value)
{
$cat=strtolower($value[2]);
if($cat===$category || (($c=rtrim($category,'.*'))!==$category && strpos($cat,$c)===0))
- return $value;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Filter function used by {@link getProfilingResults}
+ * @param array $value element to be filtered
+ * @return bool true if valid timing entry, false if not.
+ */
+ private function filterTimingByCategory($value)
+ {
+ foreach($this->_categories as $category)
+ {
+ $cat=strtolower($value[1]);
+ if($cat===$category || (($c=rtrim($category,'.*'))!==$category && strpos($cat,$c)===0))
+ return true;
}
return false;
}
@@ -162,11 +178,11 @@ private function filterByCategory($value)
/**
* Filter function used by {@link getLogs}
* @param array $value element to be filtered
- * @return array valid log, false if not.
+ * @return bool true if valid log, false if not.
*/
private function filterByLevel($value)
{
- return in_array(strtolower($value[1]),$this->_levels)?$value:false;
+ return in_array(strtolower($value[1]),$this->_levels);
}
/**
@@ -218,22 +234,32 @@ public function getMemoryUsage()
* If no filter is specified, the returned results would be an array with each element
* being array($token,$category,$time).
* If a filter is specified, the results would be an array of timings.
+ *
+ * Since 1.1.11, filtering results by category supports the same format used for filtering logs in
+ * {@link getLogs}, and similarly supports filtering by multiple categories and wildcard.
* @param string $token token filter. Defaults to null, meaning not filtered by token.
- * @param string $category category filter. Defaults to null, meaning not filtered by category.
+ * @param string $categories category filter. Defaults to null, meaning not filtered by category.
* @param boolean $refresh whether to refresh the internal timing calculations. If false,
* only the first time calling this method will the timings be calculated internally.
* @return array the profiling results.
*/
- public function getProfilingResults($token=null,$category=null,$refresh=false)
+ public function getProfilingResults($token=null,$categories=null,$refresh=false)
{
if($this->_timings===null || $refresh)
$this->calculateTimings();
- if($token===null && $category===null)
+ if($token===null && $categories===null)
return $this->_timings;
+
+ $timings = $this->_timings;
+ if($categories!==null) {
+ $this->_categories=preg_split('/[\s,]+/',strtolower($categories),-1,PREG_SPLIT_NO_EMPTY);
+ $timings=array_filter($timings,array($this,'filterTimingByCategory'));
+ }
+
$results=array();
- foreach($this->_timings as $timing)
+ foreach($timings as $timing)
{
- if(($category===null || $timing[1]===$category) && ($token===null || $timing[0]===$token))
+ if($token===null || $timing[0]===$token)
$results[]=$timing[2];
}
return $results;

No commit comments for this range

Something went wrong with that request. Please try again.