Permalink
Browse files

Allow Negating Categories in CLogRoutes

  • Loading branch information...
Josh Priestly unknown
Josh Priestly authored and unknown committed Sep 11, 2012
1 parent bfd756f commit dc89ce3ecd61c5790dd4416bbe0aa588e9c839c5
Showing with 11 additions and 3 deletions.
  1. +1 −0 framework/logging/CLogRoute.php
  2. +10 −3 framework/logging/CLogger.php
@@ -40,6 +40,7 @@
public $levels='';
/**
* @var string list of categories separated by comma or space. Defaults to empty, meaning all categories.
+ * Allows negating categories, use ! before a category name to not include it.
*/
public $categories='';
/**
@@ -149,13 +149,20 @@ public function getLogs($levels='',$categories='')
*/
private function filterByCategory($value)
{
+ $cat=strtolower($value[2]);
+ $negateOnly=true;
foreach($this->_categories as $category)
{
- $cat=strtolower($value[2]);
+ if (substr($category, 0,1) === '!')
+ $category = substr($category,1);
+ else
+ $negateOnly = false;
+
if($cat===$category || (($c=rtrim($category,'.*'))!==$category && strpos($cat,$c)===0))
- return true;
+ return !$negateOnly;
+
}
- return false;
+ return $negateOnly;
}
/**

0 comments on commit dc89ce3

Please sign in to comment.