You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by ih...@apache.org on 2010/09/18 09:46:03 UTC

svn commit: r998420 - in /logging/log4php/trunk/src: changes/changes.xml main/php/LoggerLevel.php main/php/layouts/LoggerLayoutHtml.php main/php/layouts/LoggerLayoutSimple.php main/php/layouts/LoggerLayoutTTCC.php

Author: ihabunek
Date: Sat Sep 18 07:46:03 2010
New Revision: 998420

URL: http://svn.apache.org/viewvc?rev=998420&view=rev
Log:
Added __toString magic method to LoggerLevel.

Modified:
    logging/log4php/trunk/src/changes/changes.xml
    logging/log4php/trunk/src/main/php/LoggerLevel.php
    logging/log4php/trunk/src/main/php/layouts/LoggerLayoutHtml.php
    logging/log4php/trunk/src/main/php/layouts/LoggerLayoutSimple.php
    logging/log4php/trunk/src/main/php/layouts/LoggerLayoutTTCC.php

Modified: logging/log4php/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/changes/changes.xml?rev=998420&r1=998419&r2=998420&view=diff
==============================================================================
--- logging/log4php/trunk/src/changes/changes.xml (original)
+++ logging/log4php/trunk/src/changes/changes.xml Sat Sep 18 07:46:03 2010
@@ -24,6 +24,7 @@
   </properties>
   <body>
   	<release version="2.1" description="Stabilizing">
+  		<action type="update" by="Ivan Habunek">Added __toString magic method to LoggerLevel.</action>
   		<action type="fix" issue="LOG4PHP-117" by="Maciej Mazur, Ivan Habunek">LoggerConfiguratorIni::configure() and unexptected results from error_get_last()</action>
   		<action type="fix" issue="LOG4PHP-113" by="Ivan Habunek">Milliseconds do not change when using LoggerLayoutPattern</action>
   		<action type="fix" issue="LOG4PHP-115" by="Vaceletm">Instanciate LoggerAppenderPDO by hand throw exception</action>

Modified: logging/log4php/trunk/src/main/php/LoggerLevel.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/LoggerLevel.php?rev=998420&r1=998419&r2=998420&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/LoggerLevel.php (original)
+++ logging/log4php/trunk/src/main/php/LoggerLevel.php Sat Sep 18 07:46:03 2010
@@ -213,13 +213,20 @@ class LoggerLevel {
 	}
 
 	/**
-	 * Returns the string representation of this priority.
+	 * Returns the string representation of this level.
 	 * @return string
-	 * @final
 	 */
 	public function toString() {
 		return $this->levelStr;
 	}
+	
+	/**
+	 * Returns the string representation of this level.
+	 * @return string
+	 */
+	public function __toString() {
+		return $this->toString();
+	}
 
 	/**
 	 * Returns the integer representation of this level.

Modified: logging/log4php/trunk/src/main/php/layouts/LoggerLayoutHtml.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/layouts/LoggerLayoutHtml.php?rev=998420&r1=998419&r2=998420&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/layouts/LoggerLayoutHtml.php (original)
+++ logging/log4php/trunk/src/main/php/layouts/LoggerLayoutHtml.php Sat Sep 18 07:46:03 2010
@@ -145,15 +145,11 @@ class LoggerLayoutHtml extends LoggerLay
         $level = $event->getLevel();
         
         if ($level->equals(LoggerLevel::getLevelDebug())) {
-          $sbuf .= "<font color=\"#339933\">";
-          $sbuf .= $level->toString();
-          $sbuf .= "</font>";
+          $sbuf .= "<font color=\"#339933\">$level</font>";
         } else if ($level->equals(LoggerLevel::getLevelWarn())) {
-          $sbuf .= "<font color=\"#993300\"><strong>";
-          $sbuf .= $level->toString();
-          $sbuf .= "</strong></font>";
+          $sbuf .= "<font color=\"#993300\"><strong>$level</strong></font>";
         } else {
-          $sbuf .= $level->toString();
+          $sbuf .= $level;
         }
         $sbuf .= "</td>" . PHP_EOL;
     

Modified: logging/log4php/trunk/src/main/php/layouts/LoggerLayoutSimple.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/layouts/LoggerLayoutSimple.php?rev=998420&r1=998419&r2=998420&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/layouts/LoggerLayoutSimple.php (original)
+++ logging/log4php/trunk/src/main/php/layouts/LoggerLayoutSimple.php Sat Sep 18 07:46:03 2010
@@ -56,6 +56,7 @@ class LoggerLayoutSimple extends LoggerL
      */
     public function format(LoggerLoggingEvent $event) {
         $level = $event->getLevel();
-        return $level->toString() . ' - ' . $event->getRenderedMessage(). PHP_EOL;
+        $message = $event->getRenderedMessage();
+        return "$level - $message" . PHP_EOL;
     }
 }

Modified: logging/log4php/trunk/src/main/php/layouts/LoggerLayoutTTCC.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/layouts/LoggerLayoutTTCC.php?rev=998420&r1=998419&r2=998420&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/layouts/LoggerLayoutTTCC.php (original)
+++ logging/log4php/trunk/src/main/php/layouts/LoggerLayoutTTCC.php Sat Sep 18 07:46:03 2010
@@ -190,7 +190,7 @@ class LoggerLayoutTTCC extends LoggerLay
         }
         
         $level = $event->getLevel();
-        $format .= $level->toString().' ';
+        $format .= $level.' ';
         
         if($this->categoryPrefixing) {
             $format .= $event->getLoggerName().' ';