Author: ihabunek
Date: Thu Mar 29 13:24:30 2012
New Revision: 1306842
URL: http://svn.apache.org/viewvc?rev=1306842&view=rev
Log:
Added a helper function which prints the Logger Hierarchy.
Modified:
logging/log4php/trunk/src/main/php/LoggerHierarchy.php
Modified: logging/log4php/trunk/src/main/php/LoggerHierarchy.php
URL:
http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/LoggerHierarchy.php?rev=1306842&r1=1306841&r2=1306842&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/LoggerHierarchy.php (original)
+++ logging/log4php/trunk/src/main/php/LoggerHierarchy.php Thu Mar 29 13:24:30
2012
@@ -237,4 +237,24 @@ class LoggerHierarchy {
$logger->removeAllAppenders();
}
}
+
+ /**
+ * Prints the current Logger hierarchy tree. Useful for debugging.
+ */
+ public function printHierarchy() {
+ $this->printHierarchyInner($this->getRootLogger(), 0);
+ }
+
+ private function printHierarchyInner(Logger $current, $level) {
+ for ($i = 0; $i < $level; $i++) {
+ echo ($i == $level - 1) ? "|--" : "| ";
+ }
+ echo $current->getName() . "\n";
+
+ foreach($this->loggers as $logger) {
+ if ($logger->getParent() == $current) {
+ $this->printHierarchyInner($logger, $level + 1);
+ }
+ }
+ }
}