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 ku...@apache.org on 2009/05/04 08:46:42 UTC

svn commit: r771204 - in /incubator/log4php/trunk/src/main/php: helpers/ spi/ varia/

Author: kurdalen
Date: Mon May  4 06:46:25 2009
New Revision: 771204

URL: http://svn.apache.org/viewvc?rev=771204&view=rev
Log:
fixing code style

Modified:
    incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php
    incubator/log4php/trunk/src/main/php/helpers/LoggerPatternConverter.php
    incubator/log4php/trunk/src/main/php/helpers/LoggerPatternParser.php
    incubator/log4php/trunk/src/main/php/helpers/LoggerTransform.php
    incubator/log4php/trunk/src/main/php/spi/LoggerLocationInfo.php
    incubator/log4php/trunk/src/main/php/spi/LoggerLoggingEvent.php
    incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php

Modified: incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php?rev=771204&r1=771203&r2=771204&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php (original)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php Mon May  4 06:46:25 2009
@@ -168,7 +168,7 @@
 
 		// This is degenerate case but you never know.
 		if("NULL" == strtoupper($levelName)) {
-				return null;
+			return null;
 		}
 
 		$clazz = basename($clazz);

Modified: incubator/log4php/trunk/src/main/php/helpers/LoggerPatternConverter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerPatternConverter.php?rev=771204&r1=771203&r2=771204&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerPatternConverter.php (original)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerPatternConverter.php Mon May  4 06:46:25 2009
@@ -1,13 +1,13 @@
 <?php
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *	   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,11 +22,15 @@
 
 /**
  * Array for fast space padding
- * Used by {@link LoggerPatternConverter::spacePad()}.  
+ * Used by {@link LoggerPatternConverter::spacePad()}.	
  */
-$GLOBALS['log4php.LoggerPatternConverter.spaces'] = array(" ", "  ", "    ", "        ", //1,2,4,8 spaces
-                            "                ", // 16 spaces
-                            "                                " ); // 32 spaces
+$GLOBALS['log4php.LoggerPatternConverter.spaces'] = array(
+	" ", // 1 space
+	"  ", // 2 spaces
+	"    ", // 4 spaces
+	"        ", // 8 spaces
+	"                ", // 16 spaces
+	"                                " ); // 32 spaces
 
 /**
  * LoggerPatternConverter is an abstract class that provides the formatting 
@@ -44,97 +48,95 @@
  */
 class LoggerPatternConverter {
 
-    /**
-     * @var LoggerPatternConverter next converter in converter chain
-     */
-    var $next = null;
-    
-    var $min = -1;
-    var $max = 0x7FFFFFFF;
-    var $leftAlign = false;
-
-    /**
-     * Constructor 
-     *
-     * @param LoggerFormattingInfo $fi
-     */
-    function LoggerPatternConverter($fi = null) 
-    {  
-        if ($fi !== null) {
-            $this->min = $fi->min;
-            $this->max = $fi->max;
-            $this->leftAlign = $fi->leftAlign;
-        }
-    }
+	/**
+	 * @var LoggerPatternConverter next converter in converter chain
+	 */
+	var $next = null;
+	
+	var $min = -1;
+	var $max = 0x7FFFFFFF;
+	var $leftAlign = false;
+
+	/**
+	 * Constructor 
+	 *
+	 * @param LoggerFormattingInfo $fi
+	 */
+	function LoggerPatternConverter($fi = null) {  
+		if($fi !== null) {
+			$this->min = $fi->min;
+			$this->max = $fi->max;
+			$this->leftAlign = $fi->leftAlign;
+		}
+	}
   
-    /**
-     * Derived pattern converters must override this method in order to
-     * convert conversion specifiers in the correct way.
-     *
-     * @param LoggerLoggingEvent $event
-     */
-    function convert($event) {}
-
-    /**
-     * A template method for formatting in a converter specific way.
-     *
-     * @param string &$sbuf string buffer
-     * @param LoggerLoggingEvent $e
-     */
-    function format(&$sbuf, $e) {
-        $s = $this->convert($e);
-        
-        if($s == null or empty($s)) {
-            if(0 < $this->min)
-                $this->spacePad($sbuf, $this->min);
-            return;
-        }
-        
-        $len = strlen($s);
-    
-        if($len > $this->max) {
-            $sbuf .= substr($s , 0, ($len - $this->max));
-        } elseif($len < $this->min) {
-            if($this->leftAlign) {      
-                $sbuf .= $s;
-                $this->spacePad($sbuf, ($this->min - $len));
-            } else {
-                $this->spacePad($sbuf, ($this->min - $len));
-                $sbuf .= $s;
-            }
-        } else {
-            $sbuf .= $s;
-        }
-    }   
-
-
-    /**
-     * Fast space padding method.
-     *
-     * @param string    &$sbuf     string buffer
-     * @param integer   $length    pad length
-     *
-     * @todo reimplement using PHP string functions
-     */
-    function spacePad(&$sbuf, $length)
-    {
-        while($length >= 32) {
-          $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5];
-          $length -= 32;
-        }
-        
-        for($i = 4; $i >= 0; $i--) {    
-            if(($length & (1<<$i)) != 0) {
-                $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i];
-            }
-        }
+	/**
+	 * Derived pattern converters must override this method in order to
+	 * convert conversion specifiers in the correct way.
+	 *
+	 * @param LoggerLoggingEvent $event
+	 */
+	function convert($event) {}
+
+	/**
+	 * A template method for formatting in a converter specific way.
+	 *
+	 * @param string &$sbuf string buffer
+	 * @param LoggerLoggingEvent $e
+	 */
+	function format(&$sbuf, $e) {
+		$s = $this->convert($e);
+		
+		if($s == null or empty($s)) {
+			if(0 < $this->min) {
+				$this->spacePad($sbuf, $this->min);
+			}
+			return;
+		}
+		
+		$len = strlen($s);
+	
+		if($len > $this->max) {
+			$sbuf .= substr($s , 0, ($len - $this->max));
+		} else if($len < $this->min) {
+			if($this->leftAlign) {		
+				$sbuf .= $s;
+				$this->spacePad($sbuf, ($this->min - $len));
+			} else {
+				$this->spacePad($sbuf, ($this->min - $len));
+				$sbuf .= $s;
+			}
+		} else {
+			$sbuf .= $s;
+		}
+	}	
+
+	/**
+	 * Fast space padding method.
+	 *
+	 * @param string	&$sbuf	   string buffer
+	 * @param integer	$length	   pad length
+	 *
+	 * @todo reimplement using PHP string functions
+	 */
+	function spacePad(&$sbuf, $length) {
+		while($length >= 32) {
+		  $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5];
+		  $length -= 32;
+		}
+		
+		for($i = 4; $i >= 0; $i--) {	
+			if(($length & (1<<$i)) != 0) {
+				$sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i];
+			}
+		}
 
-        // $sbuf = str_pad($sbuf, $length);
-    }
+		// $sbuf = str_pad($sbuf, $length);
+	}
 }
 
 // ---------------------------------------------------------------------
-//                      PatternConverters
+//						PatternConverters
 // ---------------------------------------------------------------------
 
 /**
@@ -143,52 +145,50 @@
  */
 class LoggerBasicPatternConverter extends LoggerPatternConverter {
 
-    /**
-     * @var integer
-     */
-    var $type;
-
-    /**
-     * Constructor
-     *
-     * @param string $formattingInfo
-     * @param integer $type
-     */
-    function LoggerBasicPatternConverter($formattingInfo, $type)
-    {
-      $this->LoggerPatternConverter($formattingInfo);
-      $this->type = $type;
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     */
-    function convert($event)
-    {
-        switch($this->type) {
-            case LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER:
-                $timeStamp = $event->getTimeStamp();
-                $startTime = LoggerLoggingEvent::getStartTime();
-                    return (string)(int)($timeStamp * 1000 - $startTime * 1000);
-                
-            case LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER:
-                    return $event->getThreadName();
-
-            case LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER:
-                $level = $event->getLevel();
-                    return $level->toString();
-
-            case LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER:
-                    return $event->getNDC();
-
-            case LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER:
-                    return $event->getRenderedMessage();
-                
-            default: 
-                return '';
-        }
-    }
+	/**
+	 * @var integer
+	 */
+	var $type;
+
+	/**
+	 * Constructor
+	 *
+	 * @param string $formattingInfo
+	 * @param integer $type
+	 */
+	function LoggerBasicPatternConverter($formattingInfo, $type) {
+	  $this->LoggerPatternConverter($formattingInfo);
+	  $this->type = $type;
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 */
+	function convert($event) {
+		switch($this->type) {
+			case LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER:
+				$timeStamp = $event->getTimeStamp();
+				$startTime = LoggerLoggingEvent::getStartTime();
+				return (string)(int)($timeStamp * 1000 - $startTime * 1000);
+				
+			case LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER:
+				return $event->getThreadName();
+
+			case LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER:
+				$level = $event->getLevel();
+				return $level->toString();
+
+			case LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER:
+				return $event->getNDC();
+
+			case LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER:
+				return $event->getRenderedMessage();
+				
+			default: 
+				return '';
+		}
+	}
 }
 
 /**
@@ -196,39 +196,36 @@
  * @subpackage helpers
  */
 class LoggerLiteralPatternConverter extends LoggerPatternConverter {
-    
-    /**
-     * @var string
-     */
-    var $literal;
-
-    /**
-     * Constructor
-     *
-     * @param string $value
-     */
-    function LoggerLiteralPatternConverter($value)
-    {
-        $this->literal = $value;
-    }
-
-    /**
-     * @param string &$sbuf
-     * @param LoggerLoggingEvent $event
-     */
-    function format(&$sbuf, $event)
-    {
-        $sbuf .= $this->literal;
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     */
-    function convert($event)
-    {
-      return $this->literal;
-    }
+	
+	/**
+	 * @var string
+	 */
+	var $literal;
+
+	/**
+	 * Constructor
+	 *
+	 * @param string $value
+	 */
+	function LoggerLiteralPatternConverter($value) {
+		$this->literal = $value;
+	}
+
+	/**
+	 * @param string &$sbuf
+	 * @param LoggerLoggingEvent $event
+	 */
+	function format(&$sbuf, $event) {
+		$sbuf .= $this->literal;
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 */
+	function convert($event) {
+		return $this->literal;
+	}
 }
 
 /**
@@ -237,36 +234,32 @@
  */
 class LoggerDatePatternConverter extends LoggerPatternConverter {
 
-    /**
-     * @var string
-     */
-    var $df;
-    
-    /**
-     * Constructor
-     *
-     * @param string $formattingInfo
-     * @param string $df
-     */
-    function LoggerDatePatternConverter($formattingInfo, $df)
-    {
-        $this->LoggerPatternConverter($formattingInfo);
-        $this->df = $df;
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     */
-    function convert($event)
-    {
-        $timeStamp = $event->getTimeStamp();
-        $usecs = round(($timeStamp - (int)$timeStamp) * 1000);
-        $this->df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df);
-
-        return date($this->df, $event->getTimeStamp());
-        
-    }
+	/**
+	 * @var string
+	 */
+	var $df;
+	
+	/**
+	 * Constructor
+	 *
+	 * @param string $formattingInfo
+	 * @param string $df
+	 */
+	function LoggerDatePatternConverter($formattingInfo, $df) {
+		$this->LoggerPatternConverter($formattingInfo);
+		$this->df = $df;
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 */
+	function convert($event) {
+		$timeStamp = $event->getTimeStamp();
+		$usecs = round(($timeStamp - (int)$timeStamp) * 1000);
+		$this->df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df);
+		return date($this->df, $event->getTimeStamp());
+	}
 }
 
 /**
@@ -275,31 +268,29 @@
  */
 class LoggerMDCPatternConverter extends LoggerPatternConverter {
 
-    /**
-     * @var string
-     */
-    var $key;
-
-    /**
-     * Constructor
-     *
-     * @param string $formattingInfo
-     * @param string $key
-     */
-    function LoggerMDCPatternConverter($formattingInfo, $key)
-    {
-      $this->LoggerPatternConverter($formattingInfo);
-      $this->key = $key;
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     */
-    function convert($event)
-    {
-        return $event->getMDC($this->key);
-    }
+	/**
+	 * @var string
+	 */
+	var $key;
+
+	/**
+	 * Constructor
+	 *
+	 * @param string $formattingInfo
+	 * @param string $key
+	 */
+	function LoggerMDCPatternConverter($formattingInfo, $key) {
+		$this->LoggerPatternConverter($formattingInfo);
+		$this->key = $key;
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 */
+	function convert($event) {
+		return $event->getMDC($this->key);
+	}
 }
 
 /**
@@ -307,44 +298,42 @@
  * @subpackage helpers
  */
 class LoggerLocationPatternConverter extends LoggerPatternConverter {
-    
-    /**
-     * @var integer
-     */
-    var $type;
-
-    /**
-     * Constructor
-     *
-     * @param string $formattingInfo
-     * @param integer $type
-     */
-    function LoggerLocationPatternConverter($formattingInfo, $type)
-    {
-      $this->LoggerPatternConverter($formattingInfo);
-      $this->type = $type;
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     */
-    function convert($event)
-    {
-        $locationInfo = $event->getLocationInformation();
-        switch($this->type) {
-            case LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER:
-                    return $locationInfo->getFullInfo();
-            case LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER:
-                    return $locationInfo->getMethodName();
-            case LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER:
-                    return $locationInfo->getLineNumber();
-            case LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER:
-                    return $locationInfo->getFileName();
-            default: 
-                return '';
-        }
-    }
+	
+	/**
+	 * @var integer
+	 */
+	var $type;
+
+	/**
+	 * Constructor
+	 *
+	 * @param string $formattingInfo
+	 * @param integer $type
+	 */
+	function LoggerLocationPatternConverter($formattingInfo, $type) {
+	  $this->LoggerPatternConverter($formattingInfo);
+	  $this->type = $type;
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 */
+	function convert($event) {
+		$locationInfo = $event->getLocationInformation();
+		switch($this->type) {
+			case LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER:
+				return $locationInfo->getFullInfo();
+			case LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER:
+				return $locationInfo->getMethodName();
+			case LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER:
+				return $locationInfo->getLineNumber();
+			case LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER:
+				return $locationInfo->getFileName();
+			default: 
+				return '';
+		}
+	}
 }
 
 /**
@@ -354,58 +343,55 @@
  */
 class LoggerNamedPatternConverter extends LoggerPatternConverter {
 
-    /**
-     * @var integer
-     */
-    var $precision;
-
-    /**
-     * Constructor
-     *
-     * @param string $formattingInfo
-     * @param integer $precision
-     */
-    function LoggerNamedPatternConverter($formattingInfo, $precision)
-    {
-      $this->LoggerPatternConverter($formattingInfo);
-      $this->precision =  $precision;
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     * @abstract
-     */
-    function getFullyQualifiedName($event)
-    { 
-        // abstract
-        return;
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     */
-    function convert($event)
-    {
-        $n = $this->getFullyQualifiedName($event);
-        if ($this->precision <= 0) {
-                return $n;
-        } else {
-                $len = strlen($n);
-            
-                // We substract 1 from 'len' when assigning to 'end' to avoid out of
-                // bounds exception in return r.substring(end+1, len). This can happen if
-                // precision is 1 and the category name ends with a dot.
-                $end = $len -1 ;
-                for($i = $this->precision; $i > 0; $i--) {
-                    $end = strrpos(substr($n, 0, ($end - 1)), '.');
-                    if ($end == false)
-                        return $n;
-                }
-                return substr($n, ($end + 1), $len);
-        }
-    }
+	/**
+	 * @var integer
+	 */
+	var $precision;
+
+	/**
+	 * Constructor
+	 *
+	 * @param string $formattingInfo
+	 * @param integer $precision
+	 */
+	function LoggerNamedPatternConverter($formattingInfo, $precision) {
+	  $this->LoggerPatternConverter($formattingInfo);
+	  $this->precision =  $precision;
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 * @abstract
+	 */
+	function getFullyQualifiedName($event) {
+		// abstract
+		return;
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 */
+	function convert($event) {
+		$n = $this->getFullyQualifiedName($event);
+		if($this->precision <= 0) {
+			return $n;
+		} else {
+			$len = strlen($n);
+			// We substract 1 from 'len' when assigning to 'end' to avoid out of
+			// bounds exception in return r.substring(end+1, len). This can happen if
+			// precision is 1 and the category name ends with a dot.
+			$end = $len -1 ;
+			for($i = $this->precision; $i > 0; $i--) {
+				$end = strrpos(substr($n, 0, ($end - 1)), '.');
+				if($end == false) {
+					return $n;
+				}
+			}
+			return substr($n, ($end + 1), $len);
+		}
+	}
 }
 
 /**
@@ -414,25 +400,23 @@
  */
 class LoggerClassNamePatternConverter extends LoggerNamedPatternConverter {
 
-    /**
-     * Constructor
-     *
-     * @param string $formattingInfo
-     * @param integer $precision
-     */
-    function LoggerClassNamePatternConverter($formattingInfo, $precision)
-    {
-        $this->LoggerNamedPatternConverter($formattingInfo, $precision);
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     */
-    function getFullyQualifiedName($event)
-    {
-        return $event->fqcn;
-    }
+	/**
+	 * Constructor
+	 *
+	 * @param string $formattingInfo
+	 * @param integer $precision
+	 */
+	function LoggerClassNamePatternConverter($formattingInfo, $precision) {
+		$this->LoggerNamedPatternConverter($formattingInfo, $precision);
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 */
+	function getFullyQualifiedName($event) {
+		return $event->fqcn;
+	}
 }
 
 /**
@@ -441,24 +425,21 @@
  */
 class LoggerCategoryPatternConverter extends LoggerNamedPatternConverter {
 
-    /**
-     * Constructor
-     *
-     * @param string $formattingInfo
-     * @param integer $precision
-     */
-    function LoggerCategoryPatternConverter($formattingInfo, $precision)
-    {
-        $this->LoggerNamedPatternConverter($formattingInfo, $precision);
-    }
-
-    /**
-     * @param LoggerLoggingEvent $event
-     * @return string
-     */
-    function getFullyQualifiedName($event)
-    {
-      return $event->getLoggerName();
-    }
+	/**
+	 * Constructor
+	 *
+	 * @param string $formattingInfo
+	 * @param integer $precision
+	 */
+	function LoggerCategoryPatternConverter($formattingInfo, $precision) {
+		$this->LoggerNamedPatternConverter($formattingInfo, $precision);
+	}
+
+	/**
+	 * @param LoggerLoggingEvent $event
+	 * @return string
+	 */
+	function getFullyQualifiedName($event) {
+		return $event->getLoggerName();
+	}
 }
-

Modified: incubator/log4php/trunk/src/main/php/helpers/LoggerPatternParser.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerPatternParser.php?rev=771204&r1=771203&r2=771204&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerPatternParser.php (original)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerPatternParser.php Mon May  4 06:46:25 2009
@@ -1,13 +1,13 @@
 <?php
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *	   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,30 +20,30 @@
  * @subpackage helpers
  */
 
-define('LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR',         '%');
+define('LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR', '%');
 
-define('LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE',       0);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE',     1);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_MINUS_STATE',         2);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE',           3);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE',           4);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE',           5);
-
-define('LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER',         1000);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER',       1001);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_CLASS_LOCATION_CONVERTER',        1002);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER',         1003);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER',         1004);
-
-define('LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER',         2000);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER',                2001);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER',                 2002);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER',                   2003);
-define('LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER',               2004);
-
-define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601',    'Y-m-d H:i:s,u'); 
-define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE',   'H:i:s');
-define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE',       'd M Y H:i:s,u');
+define('LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE', 0);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE', 1);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_MINUS_STATE', 2);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE', 3);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE', 4);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE', 5);
+
+define('LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER', 1000);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER', 1001);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_CLASS_LOCATION_CONVERTER', 1002);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER', 1003);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER', 1004);
+
+define('LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER', 2000);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER', 2001);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER', 2002);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER', 2003);
+define('LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER', 2004);
+
+define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601', 'Y-m-d H:i:s,u'); 
+define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE', 'H:i:s');
+define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE', 'd M Y H:i:s,u');
 
 /**
  * Most of the work of the {@link LoggerPatternLayout} class 
@@ -60,297 +60,288 @@
  */
 class LoggerPatternParser {
 
-    var $state;
-    var $currentLiteral;
-    var $patternLength;
-    var $i;
-    
-    /**
-     * @var LoggerPatternConverter
-     */
-    var $head = null;
-     
-    /**
-     * @var LoggerPatternConverter
-     */
-    var $tail = null;
-    
-    /**
-     * @var LoggerFormattingInfo
-     */
-    var $formattingInfo;
-    
-    /**
-     * @var string pattern to parse
-     */
-    var $pattern;
-
-    /**
-     * Constructor 
-     *
-     * @param string $pattern
-     */
-    function LoggerPatternParser($pattern)
-    {
-        $this->pattern = $pattern;
-        $this->patternLength =  strlen($pattern);
-        $this->formattingInfo = new LoggerFormattingInfo();
-        $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
-    }
-
-    /**
-     * @param LoggerPatternConverter $pc
-     */
-    function addToList($pc)
-    {
-        if($this->head == null) {
-            $this->head = $pc;
-            $this->tail =& $this->head;
-        } else {
-            $this->tail->next = $pc;
-            $this->tail =& $this->tail->next;
-        }
-    }
-
-    /**
-     * @return string
-     */
-    function extractOption()
-    {
-        if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) {
-            $end = strpos($this->pattern, '}' , $this->i);
-            if ($end !== false) {
-                $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
-                    $this->i= $end + 1;
-                    return $r;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * The option is expected to be in decimal and positive. In case of
-     * error, zero is returned.  
-     */
-    function extractPrecisionOption()
-    {
-        $opt = $this->extractOption();
-        $r = 0;
-        if ($opt !== null) {
-            if (is_numeric($opt)) {
-                $r = (int)$opt;
-                if($r <= 0) {
-                    $r = 0;
-                }
-            }
-        }
-        return $r;
-    }
-
-    function parse()
-    {
-        $c = '';
-        $this->i = 0;
-        $this->currentLiteral = '';
-        while ($this->i < $this->patternLength) {
-            $c = $this->pattern{$this->i++};
-//            LoggerLog::debug("LoggerPatternParser::parse() char is now '$c' and currentLiteral is '{$this->currentLiteral}'");            
-            switch($this->state) {
-                case LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE:
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE'");
-                    // In literal state, the last char is always a literal.
-                    if($this->i == $this->patternLength) {
-                        $this->currentLiteral .= $c;
-                        continue;
-                    }
-                    if($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) {
-                        // LoggerLog::debug("LoggerPatternParser::parse() char is an escape char");                    
-                        // peek at the next char.
-                        switch($this->pattern{$this->i}) {
-                            case LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR:
-                                // LoggerLog::debug("LoggerPatternParser::parse() next char is an escape char");                    
-                                $this->currentLiteral .= $c;
-                                $this->i++; // move pointer
-                                break;
-                            case 'n':
-                                // LoggerLog::debug("LoggerPatternParser::parse() next char is 'n'");                            
-                                $this->currentLiteral .= PHP_EOL;
-                                $this->i++; // move pointer
-                                break;
-                            default:
-                                if(strlen($this->currentLiteral) != 0) {
-                                    $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
-                                }
-                                $this->currentLiteral = $c;
-                                $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE;
-                                $this->formattingInfo->reset();
-                        }
-                    } else {
-                        $this->currentLiteral .= $c;
-                    }
-                    break;
-              case LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE:
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE'");              
-                        $this->currentLiteral .= $c;
-                        switch($c) {
-                        case '-':
-                            $this->formattingInfo->leftAlign = true;
-                            break;
-                        case '.':
-                            $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
-                                break;
-                        default:
-                            if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
-                                    $this->formattingInfo->min = ord($c) - ord('0');
-                                    $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE;
-                            } else {
-                                $this->finalizeConverter($c);
-                            }
-                        } // switch
-                    break;
-              case LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE:
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE'");              
-                        $this->currentLiteral .= $c;
-                    if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
-                        $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0'));
-                        } elseif ($c == '.') {
-                        $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
-                    } else {
-                        $this->finalizeConverter($c);
-                        }
-                        break;
-              case LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE:
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE'");              
-                        $this->currentLiteral .= $c;
-                    if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
-                        $this->formattingInfo->max = ord($c) - ord('0');
-                            $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE;
-                    } else {
-                          $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
-                    }
-                        break;
-              case LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE:
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE'");              
-                        $this->currentLiteral .= $c;
-                    if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
-                        $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
-                        } else {
-                          $this->finalizeConverter($c);
-                      $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
-                        }
-                        break;
-            } // switch
-        } // while
-        if(strlen($this->currentLiteral) != 0) {
-            $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
-            // LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\".");
-        }
-        return $this->head;
-    }
-
-    function finalizeConverter($c)
-    {
-        $pc = null;
-        switch($c) {
-            case 'c':
-                $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
-                $this->currentLiteral = '';
-                break;
-            case 'C':
-                $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption());
-                $this->currentLiteral = '';
-                break;
-            case 'd':
-                $dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
-                $dOpt = $this->extractOption();
-
-                if($dOpt !== null)
-                        $dateFormatStr = $dOpt;
-                    
-                if ($dateFormatStr == 'ISO8601') {
-                    $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
-                } elseif($dateFormatStr == 'ABSOLUTE') {
-                    $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE;
-                } elseif($dateFormatStr == 'DATE') {
-                    $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE;
-                } else {
-                    $df = $dateFormatStr;
-                    if ($df == null) {
-                        $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
-                    }
-                }
-                $pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
-                $this->currentLiteral = '';
-                break;
-            case 'F':
-                $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-            case 'l':
-                $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-            case 'L':
-                $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-            case 'm':
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-            case 'M':
-                $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-            case 'p':
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-            case 'r':
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-            case 't':
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-            case 'u':
-                if($this->i < $this->patternLength) {
-                        $cNext = $this->pattern{$this->i};
-                    if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) {
-                            $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0')));
-                        $this->currentLiteral = '';
-                            $this->i++;
-                        } else {
-                    }
-                }
-                break;
-            case 'x':
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER);
-                $this->currentLiteral = '';
-                break;
-
-            case 'X':
-                $xOpt = $this->extractOption();
-                $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
-                $this->currentLiteral = '';
-                break;
-            default:
-                $pc = new LoggerLiteralPatternConverter($this->currentLiteral);
-                $this->currentLiteral = '';
-        }
-        $this->addConverter($pc);
-    }
-
-    function addConverter($pc)
-    {
-        $this->currentLiteral = '';
-        // Add the pattern converter to the list.
-        $this->addToList($pc);
-        // Next pattern is assumed to be a literal.
-        $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
-        // Reset formatting info
-        $this->formattingInfo->reset();
-    }
+	var $state;
+	var $currentLiteral;
+	var $patternLength;
+	var $i;
+	
+	/**
+	 * @var LoggerPatternConverter
+	 */
+	var $head = null;
+	 
+	/**
+	 * @var LoggerPatternConverter
+	 */
+	var $tail = null;
+	
+	/**
+	 * @var LoggerFormattingInfo
+	 */
+	var $formattingInfo;
+	
+	/**
+	 * @var string pattern to parse
+	 */
+	var $pattern;
+
+	/**
+	 * Constructor 
+	 *
+	 * @param string $pattern
+	 */
+	function LoggerPatternParser($pattern) {
+		$this->pattern = $pattern;
+		$this->patternLength =	strlen($pattern);
+		$this->formattingInfo = new LoggerFormattingInfo();
+		$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
+	}
+
+	/**
+	 * @param LoggerPatternConverter $pc
+	 */
+	function addToList($pc) {
+		if($this->head == null) {
+			$this->head = $pc;
+			$this->tail =& $this->head;
+		} else {
+			$this->tail->next = $pc;
+			$this->tail =& $this->tail->next;
+		}
+	}
+
+	/**
+	 * @return string
+	 */
+	function extractOption() {
+		if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) {
+			$end = strpos($this->pattern, '}' , $this->i);
+			if($end !== false) {
+				$r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
+				$this->i= $end + 1;
+				return $r;
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * The option is expected to be in decimal and positive. In case of
+	 * error, zero is returned.	 
+	 */
+	function extractPrecisionOption() {
+		$opt = $this->extractOption();
+		$r = 0;
+		if($opt !== null) {
+			if(is_numeric($opt)) {
+				$r = (int)$opt;
+				if($r <= 0) {
+					$r = 0;
+				}
+			}
+		}
+		return $r;
+	}
+
+	function parse() {
+		$c = '';
+		$this->i = 0;
+		$this->currentLiteral = '';
+		while($this->i < $this->patternLength) {
+			$c = $this->pattern{$this->i++};
+//			  LoggerLog::debug("LoggerPatternParser::parse() char is now '$c' and currentLiteral is '{$this->currentLiteral}'");
+			switch($this->state) {
+				case LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE:
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE'");
+					// In literal state, the last char is always a literal.
+					if($this->i == $this->patternLength) {
+						$this->currentLiteral .= $c;
+						continue;
+					}
+					if($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) {
+						// LoggerLog::debug("LoggerPatternParser::parse() char is an escape char");
+						// peek at the next char.
+						switch($this->pattern{$this->i}) {
+							case LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR:
+								// LoggerLog::debug("LoggerPatternParser::parse() next char is an escape char");
+								$this->currentLiteral .= $c;
+								$this->i++; // move pointer
+								break;
+							case 'n':
+								// LoggerLog::debug("LoggerPatternParser::parse() next char is 'n'");
+								$this->currentLiteral .= PHP_EOL;
+								$this->i++; // move pointer
+								break;
+							default:
+								if(strlen($this->currentLiteral) != 0) {
+									$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
+								}
+								$this->currentLiteral = $c;
+								$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE;
+								$this->formattingInfo->reset();
+						}
+					} else {
+						$this->currentLiteral .= $c;
+					}
+					break;
+				case LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE:
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE'");
+						$this->currentLiteral .= $c;
+						switch($c) {
+						case '-':
+							$this->formattingInfo->leftAlign = true;
+							break;
+						case '.':
+							$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
+								break;
+						default:
+							if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
+								$this->formattingInfo->min = ord($c) - ord('0');
+								$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE;
+							} else {
+								$this->finalizeConverter($c);
+							}
+						} // switch
+					break;
+				case LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE:
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE'");
+					$this->currentLiteral .= $c;
+					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
+						$this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0'));
+					} else if ($c == '.') {
+						$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
+					} else {
+						$this->finalizeConverter($c);
+					}
+					break;
+				case LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE:
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE'");
+					$this->currentLiteral .= $c;
+					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
+						$this->formattingInfo->max = ord($c) - ord('0');
+						$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE;
+					} else {
+						$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
+					}
+					break;
+				case LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE:
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE'");				 
+					$this->currentLiteral .= $c;
+					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
+						$this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
+					} else {
+						$this->finalizeConverter($c);
+						$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
+					}
+					break;
+			} // switch
+		} // while
+		if(strlen($this->currentLiteral) != 0) {
+			$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
+			// LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\".");
+		}
+		return $this->head;
+	}
+
+	function finalizeConverter($c) {
+		$pc = null;
+		switch($c) {
+			case 'c':
+				$pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
+				$this->currentLiteral = '';
+				break;
+			case 'C':
+				$pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption());
+				$this->currentLiteral = '';
+				break;
+			case 'd':
+				$dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
+				$dOpt = $this->extractOption();
+
+				if($dOpt !== null)
+					$dateFormatStr = $dOpt;
+					
+				if($dateFormatStr == 'ISO8601') {
+					$df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
+				} else if($dateFormatStr == 'ABSOLUTE') {
+					$df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE;
+				} else if($dateFormatStr == 'DATE') {
+					$df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE;
+				} else {
+					$df = $dateFormatStr;
+					if($df == null) {
+						$df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
+					}
+				}
+				$pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
+				$this->currentLiteral = '';
+				break;
+			case 'F':
+				$pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 'l':
+				$pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 'L':
+				$pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 'm':
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 'M':
+				$pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 'p':
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 'r':
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 't':
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 'u':
+				if($this->i < $this->patternLength) {
+					$cNext = $this->pattern{$this->i};
+					if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) {
+						$pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0')));
+						$this->currentLiteral = '';
+						$this->i++;
+					}
+				}
+				break;
+			case 'x':
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER);
+				$this->currentLiteral = '';
+				break;
+			case 'X':
+				$xOpt = $this->extractOption();
+				$pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
+				$this->currentLiteral = '';
+				break;
+			default:
+				$pc = new LoggerLiteralPatternConverter($this->currentLiteral);
+				$this->currentLiteral = '';
+		}
+		$this->addConverter($pc);
+	}
+
+	function addConverter($pc) {
+		$this->currentLiteral = '';
+		// Add the pattern converter to the list.
+		$this->addToList($pc);
+		// Next pattern is assumed to be a literal.
+		$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
+		// Reset formatting info
+		$this->formattingInfo->reset();
+	}
 }
 

Modified: incubator/log4php/trunk/src/main/php/helpers/LoggerTransform.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerTransform.php?rev=771204&r1=771203&r2=771204&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerTransform.php (original)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerTransform.php Mon May  4 06:46:25 2009
@@ -1,13 +1,13 @@
 <?php
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *	   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,13 +20,13 @@
  * @subpackage helpers
  */
 
-define('LOG4PHP_LOGGER_TRANSFORM_CDATA_START',          '<![CDATA[');
-define('LOG4PHP_LOGGER_TRANSFORM_CDATA_END',            ']]>');
-define('LOG4PHP_LOGGER_TRANSFORM_CDATA_PSEUDO_END',     ']]&gt;');
-define('LOG4PHP_LOGGER_TRANSFORM_CDATA_EMBEDDED_END',   
-    LOG4PHP_LOGGER_TRANSFORM_CDATA_END .
-    LOG4PHP_LOGGER_TRANSFORM_CDATA_PSEUDO_END .
-    LOG4PHP_LOGGER_TRANSFORM_CDATA_START 
+define('LOG4PHP_LOGGER_TRANSFORM_CDATA_START', '<![CDATA[');
+define('LOG4PHP_LOGGER_TRANSFORM_CDATA_END', ']]>');
+define('LOG4PHP_LOGGER_TRANSFORM_CDATA_PSEUDO_END', ']]&gt;');
+define('LOG4PHP_LOGGER_TRANSFORM_CDATA_EMBEDDED_END',
+	LOG4PHP_LOGGER_TRANSFORM_CDATA_END .
+	LOG4PHP_LOGGER_TRANSFORM_CDATA_PSEUDO_END .
+	LOG4PHP_LOGGER_TRANSFORM_CDATA_START 
 );
 
 /**
@@ -38,52 +38,51 @@
  */
 class LoggerTransform {
 
-    /**
-    * This method takes a string which may contain HTML tags (ie,
-    * &lt;b&gt;, &lt;table&gt;, etc) and replaces any '&lt;' and '&gt;'
-    * characters with respective predefined entity references.
-    *
-    * @param string $input The text to be converted.
-    * @return string The input string with the characters '&lt;' and '&gt;' replaced with
-    *                &amp;lt; and &amp;gt; respectively.
-    * @static  
-    */
-    function escapeTags($input)
-    {
-        //Check if the string is null or zero length -- if so, return
-        //what was sent in.
-
-        if(empty($input))
-            return $input;
-
-        //Use a StringBuffer in lieu of String concatenation -- it is
-        //much more efficient this way.
-
-        return htmlspecialchars($input, ENT_NOQUOTES);
-    }
-
-    /**
-    * Ensures that embeded CDEnd strings (]]&gt;) are handled properly
-    * within message, NDC and throwable tag text.
-    *
-    * @param string $buf    String holding the XML data to this point.  The
-    *                       initial CDStart (<![CDATA[) and final CDEnd (]]>) 
-    *                       of the CDATA section are the responsibility of 
-    *                       the calling method.
-    * @param string &str    The String that is inserted into an existing 
-    *                       CDATA Section within buf.
-    * @static  
-    */
-    function appendEscapingCDATA(&$buf, $str)
-    {
-        if(empty($str))
-            return;
-    
-        $rStr = str_replace(
-            LOG4PHP_LOGGER_TRANSFORM_CDATA_END,
-            LOG4PHP_LOGGER_TRANSFORM_CDATA_EMBEDDED_END,
-            $str
-        );
-        $buf .= $rStr;
-    }
+	/**
+	 * This method takes a string which may contain HTML tags (ie,
+	 * &lt;b&gt;, &lt;table&gt;, etc) and replaces any '&lt;' and '&gt;'
+	 * characters with respective predefined entity references.
+	 *
+	 * @param string $input The text to be converted.
+	 * @return string The input string with the characters '&lt;' and '&gt;' replaced with
+	 * &amp;lt; and &amp;gt; respectively.
+	 * @static
+	 */
+	function escapeTags($input) {
+		//Check if the string is null or zero length -- if so, return
+		//what was sent in.
+
+		if(empty($input)) {
+			return $input;
+		}
+
+		//Use a StringBuffer in lieu of String concatenation -- it is
+		//much more efficient this way.
+		return htmlspecialchars($input, ENT_NOQUOTES);
+	}
+
+	/**
+	 * Ensures that embeded CDEnd strings (]]&gt;) are handled properly
+	 * within message, NDC and throwable tag text.
+	 *
+	 * @param string $buf	String holding the XML data to this point.	The
+	 *						initial CDStart (<![CDATA[) and final CDEnd (]]>) 
+	 *						of the CDATA section are the responsibility of 
+	 *						the calling method.
+	 * @param string &str	The String that is inserted into an existing 
+	 *						CDATA Section within buf.
+	 * @static  
+	 */
+	function appendEscapingCDATA(&$buf, $str) {
+		if(empty($str)) {
+			return;
+		}
+	
+		$rStr = str_replace(
+			LOG4PHP_LOGGER_TRANSFORM_CDATA_END,
+			LOG4PHP_LOGGER_TRANSFORM_CDATA_EMBEDDED_END,
+			$str
+		);
+		$buf .= $rStr;
+	}
 }

Modified: incubator/log4php/trunk/src/main/php/spi/LoggerLocationInfo.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/spi/LoggerLocationInfo.php?rev=771204&r1=771203&r2=771204&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/spi/LoggerLocationInfo.php (original)
+++ incubator/log4php/trunk/src/main/php/spi/LoggerLocationInfo.php Mon May  4 06:46:25 2009
@@ -1,13 +1,13 @@
 <?php
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *	   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,7 +25,7 @@
  * <i>NA</i> is returned. Current value of this string
  * constant is <b>?</b>.  
  */
-define('LOG4PHP_LOGGER_LOCATION_INFO_NA',  'NA');
+define('LOG4PHP_LOGGER_LOCATION_INFO_NA', 'NA');
 
 /**
  * The internal representation of caller location information.
@@ -37,85 +37,78 @@
  */
 class LoggerLocationInfo {
 
-    /**
-    * @var string Caller's line number.
-    */
-    protected $lineNumber = null;
-    
-    /**
-    * @var string Caller's file name.
-    */
-    protected $fileName = null;
-    
-    /**
-    * @var string Caller's fully qualified class name.
-    */
-    protected $className = null;
-    
-    /**
-    * @var string Caller's method name.
-    */
-    protected $methodName = null;
-    
-    /**
-    * @var string 
-    */
-    protected $fullInfo = null;
-
-    /**
-     * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
-     *
-     * @param array $trace
-     * @param mixed $caller
-     */
-    public function __construct($trace, $fqcn = null)
-    {
-        $this->lineNumber   = isset($trace['line']) ? $trace['line'] : null;
-        $this->fileName     = isset($trace['file']) ? $trace['file'] : null;
-        $this->className    = isset($trace['class']) ? $trace['class'] : null;
-        $this->methodName   = isset($trace['function']) ? $trace['function'] : null;
-        
-        $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . 
-                          '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
-    }
-
-    public function getClassName()
-    {
-        return ($this->className === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->className; 
-    }
-
-    /**
-     *  Return the file name of the caller.
-     *  <p>This information is not always available.
-     */
-        public function getFileName()
-    {
-        return ($this->fileName === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->fileName; 
-    }
-
-    /**
-     *  Returns the line number of the caller.
-     *  <p>This information is not always available.
-     */
-    public function getLineNumber()
-    {
-        return ($this->lineNumber === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->lineNumber; 
-    }
-
-    /**
-     *  Returns the method name of the caller.
-     */
-    public function getMethodName()
-    {
-        return ($this->methodName === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->methodName; 
-    }
-
-    /**
-     *  Returns the full information of the caller.
-     */
-    public function getFullInfo()
-    {
-        return ($this->fullInfo === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->fullInfo;
-    }
+	/**
+	* @var string Caller's line number.
+	*/
+	protected $lineNumber = null;
+	
+	/**
+	* @var string Caller's file name.
+	*/
+	protected $fileName = null;
+	
+	/**
+	* @var string Caller's fully qualified class name.
+	*/
+	protected $className = null;
+	
+	/**
+	* @var string Caller's method name.
+	*/
+	protected $methodName = null;
+	
+	/**
+	* @var string 
+	*/
+	protected $fullInfo = null;
+
+	/**
+	 * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
+	 *
+	 * @param array $trace
+	 * @param mixed $caller
+	 */
+	public function __construct($trace, $fqcn = null) {
+		$this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
+		$this->fileName = isset($trace['file']) ? $trace['file'] : null;
+		$this->className = isset($trace['class']) ? $trace['class'] : null;
+		$this->methodName = isset($trace['function']) ? $trace['function'] : null;
+		$this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . 
+			'(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
+	}
+
+	public function getClassName() {
+		return ($this->className === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->className; 
+	}
+
+	/**
+	 *	Return the file name of the caller.
+	 *	<p>This information is not always available.
+	 */
+	public function getFileName() {
+		return ($this->fileName === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->fileName; 
+	}
+
+	/**
+	 *	Returns the line number of the caller.
+	 *	<p>This information is not always available.
+	 */
+	public function getLineNumber() {
+		return ($this->lineNumber === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->lineNumber; 
+	}
+
+	/**
+	 *	Returns the method name of the caller.
+	 */
+	public function getMethodName() {
+		return ($this->methodName === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->methodName; 
+	}
+
+	/**
+	 *	Returns the full information of the caller.
+	 */
+	public function getFullInfo() {
+		return ($this->fullInfo === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->fullInfo;
+	}
 
 }

Modified: incubator/log4php/trunk/src/main/php/spi/LoggerLoggingEvent.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/spi/LoggerLoggingEvent.php?rev=771204&r1=771203&r2=771204&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/spi/LoggerLoggingEvent.php (original)
+++ incubator/log4php/trunk/src/main/php/spi/LoggerLoggingEvent.php Mon May  4 06:46:25 2009
@@ -1,13 +1,13 @@
 <?php
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *	   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,337 +29,326 @@
  */
 class LoggerLoggingEvent {
 
-        private static $startTime;
+	private static $startTime;
 
-    /** 
-    * @var string Fully Qualified Class Name of the calling category class.
-    */
-    var $fqcn;
-    
-    /**
-    * @var Logger reference
-    */
-    var $logger = null;
-    
-    /** 
-    * The category (logger) name.
-    * This field will be marked as private in future
-    * releases. Please do not access it directly. 
-    * Use the {@link getLoggerName()} method instead.
-    * @deprecated 
-    */
-    var $categoryName;
-    
-    /** 
-    * Level of logging event.
-    * <p> This field should not be accessed directly. You shoud use the
-    * {@link getLevel()} method instead.
-    *
-    * @deprecated
-    * @var LoggerLevel
-    */
-    protected $level;
-    
-    /** 
-     * @var string The nested diagnostic context (NDC) of logging event. 
-     */
-    var $ndc;
-    
-    /** 
-     * Have we tried to do an NDC lookup? If we did, there is no need
-     * to do it again.  Note that its value is always false when
-     * serialized. Thus, a receiving SocketNode will never use it's own
-     * (incorrect) NDC. See also writeObject method.
-     * @var boolean
-     */
-    var $ndcLookupRequired = true;
-    
-    /** 
-     * Have we tried to do an MDC lookup? If we did, there is no need
-     * to do it again.  Note that its value is always false when
-     * serialized. See also the getMDC and getMDCCopy methods.
-     * @var boolean  
-     */
-    var $mdcCopyLookupRequired = true;
-    
-    /** 
-     * @var mixed The application supplied message of logging event. 
-     */
-    var $message;
-    
-    /** 
-     * The application supplied message rendered through the log4php
-     * objet rendering mechanism. At present renderedMessage == message.
-     * @var string
-     */
-    var $renderedMessage = null;
-    
-    /** 
-     * The name of thread in which this logging event was generated.
-     * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} 
-     * @var mixed
-     */
-    var $threadName = null;
-    
-    /** 
-    * The number of seconds elapsed from 1/1/1970 until logging event
-    * was created plus microseconds if available.
-    * @var float
-    */
-    public $timeStamp;
-    
-    /** 
-    * @var LoggerLocationInfo Location information for the caller. 
-    */
-    var $locationInfo = null;
-    
-    /**
-    * Instantiate a LoggingEvent from the supplied parameters.
-    *
-    * <p>Except {@link $timeStamp} all the other fields of
-    * LoggerLoggingEvent are filled when actually needed.
-    *
-    * @param string $fqcn name of the caller class.
-    * @param mixed $logger The {@link Logger} category of this event or the logger name.
-    * @param LoggerLevel $priority The level of this event.
-    * @param mixed $message The message of this event.
-    * @param integer $timeStamp the timestamp of this logging event.
-    */
-    public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null)
-    {
-        $this->fqcn = $fqcn;
-        if ($logger instanceof Logger) {
-            $this->logger = $logger;
-            $this->categoryName = $logger->getName();
-        } else {
-            $this->categoryName = strval($logger);
-        }
-        $this->level = $priority;
-        $this->message = $message;
-        if ($timeStamp !== null && is_float($timeStamp)) {
-            $this->timeStamp = $timeStamp;
-        } else {
-            if (function_exists('microtime')) {
-                                // get microtime as float
-                $this->timeStamp = microtime(true);
-            } else {
-                $this->timeStamp = floatval(time());
-            }
-        }
-    }
-
-    /**
-     * Set the location information for this logging event. The collected
-     * information is cached for future use.
-     *
-     * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
-     * to collect informations about caller.</p>
-     * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
-     * @return LoggerLocationInfo
-     */
-    public function getLocationInformation()
-    {
-        if($this->locationInfo === null) {
-
-            $locationInfo = array();
-
-            if (function_exists('debug_backtrace')) {
-                $trace = debug_backtrace();
-                $prevHop = null;
-                // make a downsearch to identify the caller
-                $hop = array_pop($trace);
-                while ($hop !== null) {
-                    $className = @strtolower($hop['class']);
-                    if ( !empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
-                                @strtolower(get_parent_class($className)) == 'logger' or
-                                @strtolower(get_parent_class($className)) == 'loggercategory')) {
-                        $locationInfo['line'] = $hop['line'];
-                        $locationInfo['file'] = $hop['file'];                         
-                        break;
-                    }
-                    $prevHop = $hop;
-                    $hop = array_pop($trace);
-                }
-                $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
-                if (isset($prevHop['function']) and
-                    $prevHop['function'] !== 'include' and
-                    $prevHop['function'] !== 'include_once' and
-                    $prevHop['function'] !== 'require' and
-                    $prevHop['function'] !== 'require_once') {                                        
-    
-                    $locationInfo['function'] = $prevHop['function'];
-                } else {
-                    $locationInfo['function'] = 'main';
-                }
-            }
-                     
-            $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn);
-        }
-        return $this->locationInfo;
-    }
-
-    /**
-     * Return the level of this event. Use this form instead of directly
-     * accessing the {@link $level} field.
-     * @return LoggerLevel  
-     */
-    public function getLevel()
-    {
-        return $this->level;
-    }
-
-    /**
-     * Return the name of the logger. Use this form instead of directly
-     * accessing the {@link $categoryName} field.
-     * @return string  
-     */
-    public function getLoggerName()
-    {
-        return $this->categoryName;
-    }
-
-    /**
-     * Return the message for this logging event.
-     *
-     * <p>Before serialization, the returned object is the message
-     * passed by the user to generate the logging event. After
-     * serialization, the returned value equals the String form of the
-     * message possibly after object rendering.
-     * @return mixed
-     */
-    public function getMessage()
-    {
-        if($this->message !== null) {
-            return $this->message;
-        } else {
-            return $this->getRenderedMessage();
-        }
-    }
-
-    /**
-     * This method returns the NDC for this event. It will return the
-     * correct content even if the event was generated in a different
-     * thread or even on a different machine. The {@link LoggerNDC::get()} method
-     * should <b>never</b> be called directly.
-     * @return string  
-     */
-    public function getNDC()
-    {
-        if ($this->ndcLookupRequired) {
-            $this->ndcLookupRequired = false;
-            $this->ndc = implode(' ',LoggerNDC::get());
-        }
-        return $this->ndc;
-    }
-
-
-    /**
-     * Returns the the context corresponding to the <code>key</code>
-     * parameter.
-     * @return string
-     */
-    public function getMDC($key)
-    {
-        return LoggerMDC::get($key);
-    }
-
-    /**
-     * Render message.
-     * @return string
-     */
-    public function getRenderedMessage()
-    {
-        if($this->renderedMessage === null and $this->message !== null) {
-            if (is_string($this->message)) {
-                    $this->renderedMessage = $this->message;
-            } else {
-                if ($this->logger !== null) {
-                    $repository = $this->logger->getLoggerRepository();
-                } else {
-                    $repository = LoggerManager::getLoggerRepository();
-                }
-                if (method_exists($repository, 'getRendererMap')) {
-                    $rendererMap = $repository->getRendererMap();
-                        $this->renderedMessage= $rendererMap->findAndRender($this->message);
-                    } else {
-                        $this->renderedMessage = (string)$this->message;
-                    }
-            }
-        }
-        return $this->renderedMessage;
-    }
-
-    /**
-     * Returns the time when the application started, in seconds
-     * elapsed since 01.01.1970 plus microseconds if available.
-     *
-     * @return float
-     * @static
-     */
-    public static function getStartTime() {
-        if (!isset(self::$startTime)) {
-            if (function_exists('microtime')) {
-                // microtime as float
-                self::$startTime = microtime(true);
-            } else {
-                self::$startTime = floatval(time());
-            }
-        }
-        return self::$startTime; 
-    }
-    
-    /**
-     * @return float
-     */
-    public function getTimeStamp()
-    {
-        return $this->timeStamp;
-    }
-    
-    /**
-     * @return mixed
-     */
-    public function getThreadName()
-    {
-        if ($this->threadName === null)
-            $this->threadName = (string)getmypid();
-        return $this->threadName;
-    }
-
-    /**
-     * @return mixed null
-     */
-    public function getThrowableInformation()
-    {
-        return null;
-    }
-    
-    /**
-     * Serialize this object
-     * @return string
-     */
-    public function toString()
-    {
-        serialize($this);
-    }
-    
-    /**
-     * Avoid serialization of the {@link $logger} object
-     */
-    public function __sleep()
-    {
-        return array(
-            'fqcn','categoryName',
-            'level',
-            'ndc','ndcLookupRequired',
-            'message','renderedMessage',
-            'threadName',
-            'timeStamp',
-            'locationInfo'
-        );
-    }
+	/** 
+	* @var string Fully Qualified Class Name of the calling category class.
+	*/
+	var $fqcn;
+	
+	/**
+	* @var Logger reference
+	*/
+	var $logger = null;
+	
+	/** 
+	* The category (logger) name.
+	* This field will be marked as private in future
+	* releases. Please do not access it directly. 
+	* Use the {@link getLoggerName()} method instead.
+	* @deprecated 
+	*/
+	var $categoryName;
+	
+	/** 
+	* Level of logging event.
+	* <p> This field should not be accessed directly. You shoud use the
+	* {@link getLevel()} method instead.
+	*
+	* @deprecated
+	* @var LoggerLevel
+	*/
+	protected $level;
+	
+	/** 
+	 * @var string The nested diagnostic context (NDC) of logging event. 
+	 */
+	var $ndc;
+	
+	/** 
+	 * Have we tried to do an NDC lookup? If we did, there is no need
+	 * to do it again.	Note that its value is always false when
+	 * serialized. Thus, a receiving SocketNode will never use it's own
+	 * (incorrect) NDC. See also writeObject method.
+	 * @var boolean
+	 */
+	var $ndcLookupRequired = true;
+	
+	/** 
+	 * Have we tried to do an MDC lookup? If we did, there is no need
+	 * to do it again.	Note that its value is always false when
+	 * serialized. See also the getMDC and getMDCCopy methods.
+	 * @var boolean	 
+	 */
+	var $mdcCopyLookupRequired = true;
+	
+	/** 
+	 * @var mixed The application supplied message of logging event. 
+	 */
+	var $message;
+	
+	/** 
+	 * The application supplied message rendered through the log4php
+	 * objet rendering mechanism. At present renderedMessage == message.
+	 * @var string
+	 */
+	var $renderedMessage = null;
+	
+	/** 
+	 * The name of thread in which this logging event was generated.
+	 * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} 
+	 * @var mixed
+	 */
+	var $threadName = null;
+	
+	/** 
+	* The number of seconds elapsed from 1/1/1970 until logging event
+	* was created plus microseconds if available.
+	* @var float
+	*/
+	public $timeStamp;
+	
+	/** 
+	* @var LoggerLocationInfo Location information for the caller. 
+	*/
+	var $locationInfo = null;
+	
+	/**
+	* Instantiate a LoggingEvent from the supplied parameters.
+	*
+	* <p>Except {@link $timeStamp} all the other fields of
+	* LoggerLoggingEvent are filled when actually needed.
+	*
+	* @param string $fqcn name of the caller class.
+	* @param mixed $logger The {@link Logger} category of this event or the logger name.
+	* @param LoggerLevel $priority The level of this event.
+	* @param mixed $message The message of this event.
+	* @param integer $timeStamp the timestamp of this logging event.
+	*/
+	public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) {
+		$this->fqcn = $fqcn;
+		if($logger instanceof Logger) {
+			$this->logger = $logger;
+			$this->categoryName = $logger->getName();
+		} else {
+			$this->categoryName = strval($logger);
+		}
+		$this->level = $priority;
+		$this->message = $message;
+		if($timeStamp !== null && is_float($timeStamp)) {
+			$this->timeStamp = $timeStamp;
+		} else {
+			if(function_exists('microtime')) {
+				// get microtime as float
+				$this->timeStamp = microtime(true);
+			} else {
+				$this->timeStamp = floatval(time());
+			}
+		}
+	}
+
+	/**
+	 * Set the location information for this logging event. The collected
+	 * information is cached for future use.
+	 *
+	 * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
+	 * to collect informations about caller.</p>
+	 * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
+	 * @return LoggerLocationInfo
+	 */
+	public function getLocationInformation() {
+		if($this->locationInfo === null) {
+
+			$locationInfo = array();
+
+			if(function_exists('debug_backtrace')) {
+				$trace = debug_backtrace();
+				$prevHop = null;
+				// make a downsearch to identify the caller
+				$hop = array_pop($trace);
+				while($hop !== null) {
+					$className = @strtolower($hop['class']);
+					if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
+						@strtolower(get_parent_class($className)) == 'logger' or
+						@strtolower(get_parent_class($className)) == 'loggercategory')) {
+						$locationInfo['line'] = $hop['line'];
+						$locationInfo['file'] = $hop['file'];
+						break;
+					}
+					$prevHop = $hop;
+					$hop = array_pop($trace);
+				}
+				$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
+				if(isset($prevHop['function']) and
+					$prevHop['function'] !== 'include' and
+					$prevHop['function'] !== 'include_once' and
+					$prevHop['function'] !== 'require' and
+					$prevHop['function'] !== 'require_once') {
+	
+					$locationInfo['function'] = $prevHop['function'];
+				} else {
+					$locationInfo['function'] = 'main';
+				}
+			}
+					 
+			$this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn);
+		}
+		return $this->locationInfo;
+	}
+
+	/**
+	 * Return the level of this event. Use this form instead of directly
+	 * accessing the {@link $level} field.
+	 * @return LoggerLevel	
+	 */
+	public function getLevel() {
+		return $this->level;
+	}
+
+	/**
+	 * Return the name of the logger. Use this form instead of directly
+	 * accessing the {@link $categoryName} field.
+	 * @return string  
+	 */
+	public function getLoggerName() {
+		return $this->categoryName;
+	}
+
+	/**
+	 * Return the message for this logging event.
+	 *
+	 * <p>Before serialization, the returned object is the message
+	 * passed by the user to generate the logging event. After
+	 * serialization, the returned value equals the String form of the
+	 * message possibly after object rendering.
+	 * @return mixed
+	 */
+	public function getMessage() {
+		if($this->message !== null) {
+			return $this->message;
+		} else {
+			return $this->getRenderedMessage();
+		}
+	}
+
+	/**
+	 * This method returns the NDC for this event. It will return the
+	 * correct content even if the event was generated in a different
+	 * thread or even on a different machine. The {@link LoggerNDC::get()} method
+	 * should <b>never</b> be called directly.
+	 * @return string  
+	 */
+	public function getNDC() {
+		if($this->ndcLookupRequired) {
+			$this->ndcLookupRequired = false;
+			$this->ndc = implode(' ', LoggerNDC::get());
+		}
+		return $this->ndc;
+	}
+
+	/**
+	 * Returns the the context corresponding to the <code>key</code>
+	 * parameter.
+	 * @return string
+	 */
+	public function getMDC($key) {
+		return LoggerMDC::get($key);
+	}
+
+	/**
+	 * Render message.
+	 * @return string
+	 */
+	public function getRenderedMessage() {
+		if($this->renderedMessage === null and $this->message !== null) {
+			if(is_string($this->message)) {
+					$this->renderedMessage = $this->message;
+			} else {
+				if($this->logger !== null) {
+					$repository = $this->logger->getLoggerRepository();
+				} else {
+					$repository = LoggerManager::getLoggerRepository();
+				}
+				if(method_exists($repository, 'getRendererMap')) {
+					$rendererMap = $repository->getRendererMap();
+					$this->renderedMessage= $rendererMap->findAndRender($this->message);
+				} else {
+					$this->renderedMessage = (string)$this->message;
+				}
+			}
+		}
+		return $this->renderedMessage;
+	}
+
+	/**
+	 * Returns the time when the application started, in seconds
+	 * elapsed since 01.01.1970 plus microseconds if available.
+	 *
+	 * @return float
+	 * @static
+	 */
+	public static function getStartTime() {
+		if(!isset(self::$startTime)) {
+			if (function_exists('microtime')) {
+				// microtime as float
+				self::$startTime = microtime(true);
+			} else {
+				self::$startTime = floatval(time());
+			}
+		}
+		return self::$startTime; 
+	}
+
+	/**
+	 * @return float
+	 */
+	public function getTimeStamp() {
+		return $this->timeStamp;
+	}
+	
+	/**
+	 * @return mixed
+	 */
+	public function getThreadName() {
+		if ($this->threadName === null) {
+			$this->threadName = (string)getmypid();
+		}
+		return $this->threadName;
+	}
+
+	/**
+	 * @return mixed null
+	 */
+	public function getThrowableInformation() {
+		return null;
+	}
+	
+	/**
+	 * Serialize this object
+	 * @return string
+	 */
+	public function toString() {
+		serialize($this);
+	}
+	
+	/**
+	 * Avoid serialization of the {@link $logger} object
+	 */
+	public function __sleep() {
+		return array(
+			'fqcn',
+			'categoryName',
+			'level',
+			'ndc',
+			'ndcLookupRequired',
+			'message',
+			'renderedMessage',
+			'threadName',
+			'timeStamp',
+			'locationInfo',
+		);
+	}
 
 }
 
 LoggerLoggingEvent::getStartTime();
-

Modified: incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php?rev=771204&r1=771203&r2=771204&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php (original)
+++ incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php Mon May  4 06:46:25 2009
@@ -48,7 +48,7 @@
 	 * @var string
 	 */
 	var $stringToMatch = null;
-  
+
 	/**
 	 * @return boolean
 	 */
@@ -83,13 +83,13 @@
 	function decide($event) {
 		$msg = $event->getRenderedMessage();
 		
-		if($msg === null or	 $this->stringToMatch === null) {
+		if($msg === null or $this->stringToMatch === null) {
 			return LoggerFilter::NEUTRAL;
 		}
 		
 		if(strpos($msg, $this->stringToMatch) !== false ) {
-			return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY ; 
+			return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
 		}
-		return LoggerFilter::NEUTRAL;		 
+		return LoggerFilter::NEUTRAL;
 	}
 }