logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject [35/43] Fixed code formatting to conform to PSR-2
Date Thu, 28 Nov 2013 16:04:05 GMT
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Helpers/OptionConverter.php
----------------------------------------------------------------------
diff --git a/src/Helpers/OptionConverter.php b/src/Helpers/OptionConverter.php
index c496f02..d67b4a8 100644
--- a/src/Helpers/OptionConverter.php
+++ b/src/Helpers/OptionConverter.php
@@ -25,201 +25,210 @@ use Apache\Log4php\LoggerException;
  * A convenience class to convert property values to specific types.
  * @since 0.5
  */
-class OptionConverter {
-
-	/** String values which are converted to boolean TRUE. */
-	private static $trueValues = array('1', 'true', 'yes', 'on');
-
-	/**
-	 * String values which are converted to boolean FALSE.
-	 *
-	 * Note that an empty string must convert to false, because
-	 * parse_ini_file() which is used for parsing configuration
-	 * converts the value _false_ to an empty string.
-	 */
-	private static $falseValues = array('0', 'false', 'no', 'off', '');
-
-	/**
-	 * Read a predefined var.
-	 *
-	 * It returns a value referenced by <var>$key</var> using this search criteria:
-	 * - if <var>$key</var> is a constant then return it. Else
-	 * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
-	 * - return <var>$def</var>.
-	 *
-	 * @param string $key The key to search for.
-	 * @param string $def The default value to return.
-	 * @return string	the string value of the system property, or the default
-	 *					value if there is no property with that key.
-	 */
-	public static function getSystemProperty($key, $def) {
-		if(defined($key)) {
-			return (string)constant($key);
-		} else if(isset($_SERVER[$key])) {
-			return (string)$_SERVER[$key];
-		} else if(isset($_ENV[$key])) {
-			return (string)$_ENV[$key];
-		} else {
-			return $def;
-		}
-	}
-
-	/** Converts $value to boolean, or throws an exception if not possible. */
-	public static function toBooleanEx($value) {
-		if (isset($value)) {
-			if (is_bool($value)) {
-				return $value;
-			}
-			$value = strtolower(trim($value));
-			if (in_array($value, self::$trueValues)) {
-				return true;
-			}
-			if (in_array($value, self::$falseValues)) {
-				return false;
-			}
-		}
-
-		throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
-	}
-
-	/**
-	 * Converts $value to integer, or throws an exception if not possible.
-	 * Floats cannot be converted to integer.
-	 */
-	public static function toIntegerEx($value) {
-		if (is_integer($value)) {
-			return $value;
-		}
-		if (is_numeric($value) && ($value == (integer) $value)) {
-			return (integer) $value;
-		}
-
-		throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
-	}
-
-	/**
-	 * Converts $value to integer, or throws an exception if not possible.
-	 * Floats cannot be converted to integer.
-	 */
-	public static function toPositiveIntegerEx($value) {
-		if (is_integer($value) && $value > 0) {
-			return $value;
-		}
-		if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
-			return (integer) $value;
-		}
-
-		throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
-	}
-
-	/** Converts the value to a level. Throws an exception if not possible. */
-	public static function toLevelEx($value) {
-		if ($value instanceof Level) {
-			return $value;
-		}
-		$level = Level::toLevel($value);
-		if ($level === null) {
-			throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
-		}
-		return $level;
-	}
-
-	/**
-	 * Converts a value to a valid file size (integer).
-	 *
-	 * Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc.
-	 *
-	 * The final value will be rounded to the nearest integer.
-	 *
-	 * Examples:
-	 * - '100' => 100
-	 * - '100.12' => 100
-	 * - '100KB' => 102400
-	 * - '1.5MB' => 1572864
-	 *
-	 * @param mixed $value File size (optionally with suffix).
-	 * @return integer Parsed file size.
-	 */
-	public static function toFileSizeEx($value) {
-
-		if (empty($value)) {
-			throw new LoggerException("Empty value cannot be converted to a file size.");
-		}
-
-		if (is_numeric($value)) {
-			return (integer) $value;
-		}
-
-		if (!is_string($value)) {
-			throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
-		}
-
-		$str = strtoupper(trim($value));
-		$count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches);
-
-		if ($count > 0) {
-			$size = $matches[1];
-			$unit = $matches[2];
-
-			switch($unit) {
-				case 'KB': $size *= pow(1024, 1); break;
-				case 'MB': $size *= pow(1024, 2); break;
-				case 'GB': $size *= pow(1024, 3); break;
-			}
-
-			return (integer) $size;
-		}
-
-		throw new LoggerException("Given value [$value] cannot be converted to a file size.");
-	}
-
-	/**
-	 * Converts a value to string, or throws an exception if not possible.
-	 *
-	 * Objects can be converted to string if they implement the magic
-	 * __toString() method.
-	 *
-	 */
-	public static function toStringEx($value) {
-		if (is_string($value)) {
-			return $value;
-		}
-		if (is_numeric($value)) {
-			return (string) $value;
-		}
-		if (is_object($value) && method_exists($value, '__toString')) {
-			return (string) $value;
-		}
-
-		throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
-	}
-
-	/**
-	 * Performs value substitution for string options.
-	 *
-	 * An option can contain PHP constants delimited by '${' and '}'.
-	 *
-	 * E.g. for input string "some ${FOO} value", the method will attempt
-	 * to substitute ${FOO} with the value of constant FOO if it exists.
-	 *
-	 * Therefore, if FOO is a constant, and it has value "bar", the resulting
-	 * string will be "some bar value".
-	 *
-	 * If the constant is not defined, it will be replaced by an empty string,
-	 * and the resulting string will be "some  value".
-	 *
-	 * @param string $string String on which to perform substitution.
-	 * @return string
-	 */
-	public static function substConstants($string) {
-		preg_match_all('/\${([^}]+)}/', $string, $matches);
-
-		foreach($matches[1] as $key => $match) {
-			$match = trim($match);
-			$search = $matches[0][$key];
-			$replacement = defined($match) ? constant($match) : '';
-			$string = str_replace($search, $replacement, $string);
-		}
-		return $string;
-	}
+class OptionConverter
+{
+    /** String values which are converted to boolean TRUE. */
+    private static $trueValues = array('1', 'true', 'yes', 'on');
+
+    /**
+     * String values which are converted to boolean FALSE.
+     *
+     * Note that an empty string must convert to false, because
+     * parse_ini_file() which is used for parsing configuration
+     * converts the value _false_ to an empty string.
+     */
+    private static $falseValues = array('0', 'false', 'no', 'off', '');
+
+    /**
+     * Read a predefined var.
+     *
+     * It returns a value referenced by <var>$key</var> using this search criteria:
+     * - if <var>$key</var> is a constant then return it. Else
+     * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
+     * - return <var>$def</var>.
+     *
+     * @param  string $key The key to search for.
+     * @param  string $def The default value to return.
+     * @return string the string value of the system property, or the default
+     *					value if there is no property with that key.
+     */
+    public static function getSystemProperty($key, $def)
+    {
+        if (defined($key)) {
+            return (string) constant($key);
+        } elseif (isset($_SERVER[$key])) {
+            return (string) $_SERVER[$key];
+        } elseif (isset($_ENV[$key])) {
+            return (string) $_ENV[$key];
+        } else {
+            return $def;
+        }
+    }
+
+    /** Converts $value to boolean, or throws an exception if not possible. */
+    public static function toBooleanEx($value)
+    {
+        if (isset($value)) {
+            if (is_bool($value)) {
+                return $value;
+            }
+            $value = strtolower(trim($value));
+            if (in_array($value, self::$trueValues)) {
+                return true;
+            }
+            if (in_array($value, self::$falseValues)) {
+                return false;
+            }
+        }
+
+        throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
+    }
+
+    /**
+     * Converts $value to integer, or throws an exception if not possible.
+     * Floats cannot be converted to integer.
+     */
+    public static function toIntegerEx($value)
+    {
+        if (is_integer($value)) {
+            return $value;
+        }
+        if (is_numeric($value) && ($value == (integer) $value)) {
+            return (integer) $value;
+        }
+
+        throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
+    }
+
+    /**
+     * Converts $value to integer, or throws an exception if not possible.
+     * Floats cannot be converted to integer.
+     */
+    public static function toPositiveIntegerEx($value)
+    {
+        if (is_integer($value) && $value > 0) {
+            return $value;
+        }
+        if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
+            return (integer) $value;
+        }
+
+        throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
+    }
+
+    /** Converts the value to a level. Throws an exception if not possible. */
+    public static function toLevelEx($value)
+    {
+        if ($value instanceof Level) {
+            return $value;
+        }
+        $level = Level::toLevel($value);
+        if ($level === null) {
+            throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
+        }
+
+        return $level;
+    }
+
+    /**
+     * Converts a value to a valid file size (integer) .
+     *
+     * Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc.
+     *
+     * The final value will be rounded to the nearest integer.
+     *
+     * Examples:
+     * - '100' => 100
+     * - '100.12' => 100
+     * - '100KB' => 102400
+     * - '1.5MB' => 1572864
+     *
+     * @param  mixed   $value File size (optionally with suffix).
+     * @return integer Parsed file size.
+     */
+    public static function toFileSizeEx($value)
+    {
+        if (empty($value)) {
+            throw new LoggerException("Empty value cannot be converted to a file size.");
+        }
+
+        if (is_numeric($value)) {
+            return (integer) $value;
+        }
+
+        if (!is_string($value)) {
+            throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
+        }
+
+        $str = strtoupper(trim($value));
+        $count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches);
+
+        if ($count > 0) {
+            $size = $matches[1];
+            $unit = $matches[2];
+
+            switch ($unit) {
+                case 'KB': $size *= pow(1024, 1); break;
+                case 'MB': $size *= pow(1024, 2); break;
+                case 'GB': $size *= pow(1024, 3); break;
+            }
+
+            return (integer) $size;
+        }
+
+        throw new LoggerException("Given value [$value] cannot be converted to a file size.");
+    }
+
+    /**
+     * Converts a value to string, or throws an exception if not possible.
+     *
+     * Objects can be converted to string if they implement the magic
+     * __toString() method.
+     *
+     */
+    public static function toStringEx($value)
+    {
+        if (is_string($value)) {
+            return $value;
+        }
+        if (is_numeric($value)) {
+            return (string) $value;
+        }
+        if (is_object($value) && method_exists($value, '__toString')) {
+            return (string) $value;
+        }
+
+        throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
+    }
+
+    /**
+     * Performs value substitution for string options.
+     *
+     * An option can contain PHP constants delimited by '${' and '}'.
+     *
+     * E.g. for input string "some ${FOO} value", the method will attempt
+     * to substitute ${FOO} with the value of constant FOO if it exists.
+     *
+     * Therefore, if FOO is a constant, and it has value "bar", the resulting
+     * string will be "some bar value".
+     *
+     * If the constant is not defined, it will be replaced by an empty string,
+     * and the resulting string will be "some  value".
+     *
+     * @param  string $string String on which to perform substitution.
+     * @return string
+     */
+    public static function substConstants($string)
+    {
+        preg_match_all('/\${([^}]+)}/', $string, $matches);
+
+        foreach ($matches[1] as $key => $match) {
+            $match = trim($match);
+            $search = $matches[0][$key];
+            $replacement = defined($match) ? constant($match) : '';
+            $string = str_replace($search, $replacement, $string);
+        }
+
+        return $string;
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Helpers/PatternParser.php
----------------------------------------------------------------------
diff --git a/src/Helpers/PatternParser.php b/src/Helpers/PatternParser.php
index 7e98a55..5d22b39 100644
--- a/src/Helpers/PatternParser.php
+++ b/src/Helpers/PatternParser.php
@@ -31,215 +31,223 @@ use Apache\Log4php\Pattern\LiteralConverter;
  *
  * @since 0.3
  */
-class PatternParser {
-
-	/** Escape character for conversion words in the conversion pattern. */
-	const ESCAPE_CHAR = '%';
-
-	/** Maps conversion words to relevant converters. */
-	private $converterMap;
-
-	/** Conversion pattern used in layout. */
-	private $pattern;
-
-	/** Regex pattern used for parsing the conversion pattern. */
-	private $regex;
-
-	/**
-	 * First converter in the chain.
-	 * @var AbstractConverter
-	 */
-	private $head;
-
-	/** Last converter in the chain. */
-	private $tail;
-
-	public function __construct($pattern, $converterMap) {
-		$this->pattern = $pattern;
-		$this->converterMap = $converterMap;
-
-		// Construct the regex pattern
-		$this->regex =
-			'/' .                       // Starting regex pattern delimiter
-			self::ESCAPE_CHAR .         // Character which marks the start of the conversion pattern
-			'(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional)
-			'(?P<word>[a-zA-Z]+)' .     // The conversion word
-			'(?P<option>{[^}]*})?' .    // Conversion option in braces (optional)
-			'/';                        // Ending regex pattern delimiter
-	}
-
-	/**
-	 * Parses the conversion pattern string, converts it to a chain of pattern
-	 * converters and returns the first converter in the chain.
-	 *
-	 * @return AbstractConverter
-	 */
-	public function parse() {
-
-		// Skip parsing if the pattern is empty
-		if (empty($this->pattern)) {
-			$this->addLiteral('');
-			return $this->head;
-		}
-
-		// Find all conversion words in the conversion pattern
-		$count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE);
-		if ($count === false) {
-			$error = error_get_last();
-			throw new LoggerException("Failed parsing layotut pattern: {$error['message']}");
-		}
-
-		$prevEnd = 0;
-
-		foreach($matches[0] as $key => $item) {
-
-			// Locate where the conversion command starts and ends
-			$length = strlen($item[0]);
-			$start = $item[1];
-			$end = $item[1] + $length;
-
-			// Find any literal expressions between matched commands
-			if ($start > $prevEnd) {
-				$literal = substr($this->pattern, $prevEnd, $start - $prevEnd);
-				$this->addLiteral($literal);
-			}
-
-			// Extract the data from the matched command
-			$word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null;
-			$modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null;
-			$option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null;
-
-			// Create a converter and add it to the chain
-			$this->addConverter($word, $modifiers, $option);
-
-			$prevEnd = $end;
-		}
-
-		// Add any trailing literals
-		if ($end < strlen($this->pattern)) {
-			$literal = substr($this->pattern, $end);
-			$this->addLiteral($literal);
-		}
-
-		return $this->head;
-	}
-
-	/**
-	 * Adds a literal converter to the converter chain.
-	 * @param string $string The string for the literal converter.
-	 */
-	private function addLiteral($string) {
-		$converter = new LiteralConverter($string);
-		$this->addToChain($converter);
-	}
-
-	/**
-	 * Adds a non-literal converter to the converter chain.
-	 *
-	 * @param string $word The conversion word, used to determine which
-	 *  converter will be used.
-	 * @param string $modifiers Formatting modifiers.
-	 * @param string $option Option to pass to the converter.
-	 */
-	private function addConverter($word, $modifiers, $option) {
- 		$formattingInfo = $this->parseModifiers($modifiers);
-		$option = trim($option, "{} ");
-
-		if (isset($this->converterMap[$word])) {
-			$converter = $this->getConverter($word, $formattingInfo, $option);
-			$this->addToChain($converter);
-		} else {
-			trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING);
-		}
-	}
-
-	/**
-	 * Determines which converter to use based on the conversion word. Creates
-	 * an instance of the converter using the provided formatting info and
-	 * option and returns it.
-	 *
-	 * @param string $word The conversion word.
-	 * @param FormattingInfo $info Formatting info.
-	 * @param string $option Converter option.
-	 *
-	 * @throws LoggerException
-	 *
-	 * @return AbstractConverter
-	 */
-	private function getConverter($word, $info, $option) {
-		if (!isset($this->converterMap[$word])) {
-			throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword.");
-		}
-
-		$class = $this->converterMap[$word];
-		if (class_exists($class)) {
-			$converter = new $class($info, $option);
-		} else {
-			$nsClass = "Apache\\Log4php\\Pattern\\$class";
-			if (class_exists($nsClass)) {
-				$converter = new $nsClass($info, $option);
-			}
-		}
-
-		if (!isset($converter)) {
-			throw new LoggerException("Class '$class' does not exist.");
-		}
-
-		if(!($converter instanceof AbstractConverter)) {
-			throw new LoggerException("Class '$class' is not an instance of AbstractConverter.");
-		}
-
-		return $converter;
-	}
-
-	/** Adds a converter to the chain and updates $head and $tail pointers. */
-	private function addToChain(AbstractConverter $converter) {
-		if (!isset($this->head)) {
-			$this->head = $converter;
-			$this->tail = $this->head;
-		} else {
-			$this->tail->next = $converter;
-			$this->tail = $this->tail->next;
-		}
-	}
-
-	/**
-	 * Parses the formatting modifiers and produces the corresponding
-	 * FormattingInfo object.
-	 *
-	 * @param string $modifier
-	 * @return FormattingInfo
-	 * @throws LoggerException
-	 */
-	private function parseModifiers($modifiers) {
-		$info = new FormattingInfo();
-
-		// If no modifiers are given, return default values
-		if (empty($modifiers)) {
-			return $info;
-		}
-
-		// Validate
-		$pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
-		if (!preg_match($pattern, $modifiers)) {
-			trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
-			return $info;
-		}
-
-		$parts = explode('.', $modifiers);
-
-		if (!empty($parts[0])) {
-			$minPart = (integer) $parts[0];
-			$info->min = abs($minPart);
-			$info->padLeft = ($minPart > 0);
-		}
-
-		if (!empty($parts[1])) {
-			$maxPart = (integer) $parts[1];
-			$info->max = abs($maxPart);
-			$info->trimLeft = ($maxPart < 0);
-		}
-
-		return $info;
-	}
+class PatternParser
+{
+    /** Escape character for conversion words in the conversion pattern. */
+    const ESCAPE_CHAR = '%';
+
+    /** Maps conversion words to relevant converters. */
+    private $converterMap;
+
+    /** Conversion pattern used in layout. */
+    private $pattern;
+
+    /** Regex pattern used for parsing the conversion pattern. */
+    private $regex;
+
+    /**
+     * First converter in the chain.
+     * @var AbstractConverter
+     */
+    private $head;
+
+    /** Last converter in the chain. */
+    private $tail;
+
+    public function __construct($pattern, $converterMap)
+    {
+        $this->pattern = $pattern;
+        $this->converterMap = $converterMap;
+
+        // Construct the regex pattern
+        $this->regex =
+            '/' .                       // Starting regex pattern delimiter
+            self::ESCAPE_CHAR .         // Character which marks the start of the conversion pattern
+            '(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional)
+            '(?P<word>[a-zA-Z]+)' .     // The conversion word
+            '(?P<option>{[^}]*})?' .    // Conversion option in braces (optional)
+            '/';                        // Ending regex pattern delimiter
+    }
+
+    /**
+     * Parses the conversion pattern string, converts it to a chain of pattern
+     * converters and returns the first converter in the chain.
+     *
+     * @return AbstractConverter
+     */
+    public function parse()
+    {
+        // Skip parsing if the pattern is empty
+        if (empty($this->pattern)) {
+            $this->addLiteral('');
+
+            return $this->head;
+        }
+
+        // Find all conversion words in the conversion pattern
+        $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE);
+        if ($count === false) {
+            $error = error_get_last();
+            throw new LoggerException("Failed parsing layotut pattern: {$error['message']}");
+        }
+
+        $prevEnd = 0;
+
+        foreach ($matches[0] as $key => $item) {
+
+            // Locate where the conversion command starts and ends
+            $length = strlen($item[0]);
+            $start = $item[1];
+            $end = $item[1] + $length;
+
+            // Find any literal expressions between matched commands
+            if ($start > $prevEnd) {
+                $literal = substr($this->pattern, $prevEnd, $start - $prevEnd);
+                $this->addLiteral($literal);
+            }
+
+            // Extract the data from the matched command
+            $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null;
+            $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null;
+            $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null;
+
+            // Create a converter and add it to the chain
+            $this->addConverter($word, $modifiers, $option);
+
+            $prevEnd = $end;
+        }
+
+        // Add any trailing literals
+        if ($end < strlen($this->pattern)) {
+            $literal = substr($this->pattern, $end);
+            $this->addLiteral($literal);
+        }
+
+        return $this->head;
+    }
+
+    /**
+     * Adds a literal converter to the converter chain.
+     * @param string $string The string for the literal converter.
+     */
+    private function addLiteral($string)
+    {
+        $converter = new LiteralConverter($string);
+        $this->addToChain($converter);
+    }
+
+    /**
+     * Adds a non-literal converter to the converter chain.
+     *
+     * @param string $word The conversion word, used to determine which
+     *  converter will be used.
+     * @param string $modifiers Formatting modifiers.
+     * @param string $option    Option to pass to the converter.
+     */
+    private function addConverter($word, $modifiers, $option)
+    {
+         $formattingInfo = $this->parseModifiers($modifiers);
+        $option = trim($option, "{} ");
+
+        if (isset($this->converterMap[$word])) {
+            $converter = $this->getConverter($word, $formattingInfo, $option);
+            $this->addToChain($converter);
+        } else {
+            trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING);
+        }
+    }
+
+    /**
+     * Determines which converter to use based on the conversion word. Creates
+     * an instance of the converter using the provided formatting info and
+     * option and returns it.
+     *
+     * @param string         $word   The conversion word.
+     * @param FormattingInfo $info   Formatting info.
+     * @param string         $option Converter option.
+     *
+     * @throws LoggerException
+     *
+     * @return AbstractConverter
+     */
+    private function getConverter($word, $info, $option)
+    {
+        if (!isset($this->converterMap[$word])) {
+            throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword.");
+        }
+
+        $class = $this->converterMap[$word];
+        if (class_exists($class)) {
+            $converter = new $class($info, $option);
+        } else {
+            $nsClass = "Apache\\Log4php\\Pattern\\$class";
+            if (class_exists($nsClass)) {
+                $converter = new $nsClass($info, $option);
+            }
+        }
+
+        if (!isset($converter)) {
+            throw new LoggerException("Class '$class' does not exist.");
+        }
+
+        if (!($converter instanceof AbstractConverter)) {
+            throw new LoggerException("Class '$class' is not an instance of AbstractConverter.");
+        }
+
+        return $converter;
+    }
+
+    /** Adds a converter to the chain and updates $head and $tail pointers. */
+    private function addToChain(AbstractConverter $converter)
+    {
+        if (!isset($this->head)) {
+            $this->head = $converter;
+            $this->tail = $this->head;
+        } else {
+            $this->tail->next = $converter;
+            $this->tail = $this->tail->next;
+        }
+    }
+
+    /**
+     * Parses the formatting modifiers and produces the corresponding
+     * FormattingInfo object.
+     *
+     * @param  string          $modifier
+     * @return FormattingInfo
+     * @throws LoggerException
+     */
+    private function parseModifiers($modifiers)
+    {
+        $info = new FormattingInfo();
+
+        // If no modifiers are given, return default values
+        if (empty($modifiers)) {
+            return $info;
+        }
+
+        // Validate
+        $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
+        if (!preg_match($pattern, $modifiers)) {
+            trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
+
+            return $info;
+        }
+
+        $parts = explode('.', $modifiers);
+
+        if (!empty($parts[0])) {
+            $minPart = (integer) $parts[0];
+            $info->min = abs($minPart);
+            $info->padLeft = ($minPart > 0);
+        }
+
+        if (!empty($parts[1])) {
+            $maxPart = (integer) $parts[1];
+            $info->max = abs($maxPart);
+            $info->trimLeft = ($maxPart < 0);
+        }
+
+        return $info;
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Helpers/Utils.php
----------------------------------------------------------------------
diff --git a/src/Helpers/Utils.php b/src/Helpers/Utils.php
index 52be24d..01d5a40 100644
--- a/src/Helpers/Utils.php
+++ b/src/Helpers/Utils.php
@@ -22,99 +22,100 @@ namespace Apache\Log4php\Helpers;
  * Contains various helper methods.
  * @since 2.3
  */
-class Utils {
-
-	/**
- 	 * Splits a fully qualified class name into fragments delimited by the
- 	 * namespace separator (\).
- 	 *
- 	 * For backward compatibility, a dot (.) can be used as a delimiter as
- 	 * well.
-	 *
-	 * @param string $name
-	 *
-	 * @return array Class name split into fragments.
-	 */
-	public static function tokenizeClassName($name) {
-		$name = str_replace('.', '\\', $name);
-		$name = trim($name, ' \\');
-		$fragments = explode('\\', $name);
-
-		foreach($fragments as $key => $fragment) {
-			if (trim($fragment) === '') {
-				unset($fragments[$key]);
-			}
-		}
-
-		return $fragments;
-	}
-
-	/**
-	 * Attempts to shorten the given class name to the desired length.
-	 *
-	 * This is done by separating the class name into fragments (delimited
-	 * by \ or .) and trimming individual fragments, starting with the left,
-	 * until desired length has been reached.
-	 *
-	 * The final fragment (i.e. class name) will never be shortened so the
-	 * result may still be longer than given length.
-	 *
-	 * @param string $name The (qualified) class name.
-	 * @param integer $length The length to shorten to. If null or 0 is given,
-	 * the name will be returned without shortening.
-	 */
-	public static function shortenClassName($name, $length) {
-		if ($length === null || $length < 0) {
-			return $name;
-		}
-
-		$name = str_replace('.', '\\', $name);
-		$name = trim($name, ' \\');
-
-		// Check if any shortening is required
-		$currentLength = strlen($name);
-		if ($currentLength <= $length) {
-			return $name;
-		}
-
-		// Split name into fragments
-		$fragments = explode('\\', $name);
-
-		// If zero length is specified, return only last fragment
-		if ($length == 0) {
-			return array_pop($fragments);
-		}
-
-		// If the name splits to only one fragment, then it cannot be shortened
-		$count = count($fragments);
-		if ($count == 1) {
-			return $name;
-		}
-
-		foreach($fragments as $key => &$fragment) {
-
-			// Never shorten last fragment
-			if ($key == $count - 1) {
-				break;
-			}
-
-			// Check for empty fragments (shouldn't happen but it's possible)
-			$fragLen = strlen($fragment);
-			if ($fragLen <= 1) {
-				continue;
-			}
-
-			// Shorten fragment to one character and check if total length satisfactory
-			$fragment = substr($fragment, 0, 1);
-			$currentLength = $currentLength - $fragLen + 1;
-
-			if ($currentLength <= $length) {
-				break;
-			}
-		}
-		unset($fragment);
-
-		return implode('\\', $fragments);
-	}
+class Utils
+{
+    /**
+      * Splits a fully qualified class name into fragments delimited by the
+      * namespace separator (\).
+      *
+      * For backward compatibility, a dot (.) can be used as a delimiter as
+      * well.
+     *
+     * @param string $name
+     *
+     * @return array Class name split into fragments.
+     */
+    public static function tokenizeClassName($name)
+    {
+        $name = str_replace('.', '\\', $name);
+        $name = trim($name, ' \\');
+        $fragments = explode('\\', $name);
+
+        foreach ($fragments as $key => $fragment) {
+            if (trim($fragment) === '') {
+                unset($fragments[$key]);
+            }
+        }
+
+        return $fragments;
+    }
+
+    /**
+     * Attempts to shorten the given class name to the desired length.
+     *
+     * This is done by separating the class name into fragments (delimited
+     * by \ or .) and trimming individual fragments, starting with the left,
+     * until desired length has been reached.
+     *
+     * The final fragment (i.e. class name) will never be shortened so the
+     * result may still be longer than given length.
+     *
+     * @param string  $name   The (qualified) class name.
+     * @param integer $length The length to shorten to. If null or 0 is given,
+     * the name will be returned without shortening.
+     */
+    public static function shortenClassName($name, $length)
+    {
+        if ($length === null || $length < 0) {
+            return $name;
+        }
+
+        $name = str_replace('.', '\\', $name);
+        $name = trim($name, ' \\');
+
+        // Check if any shortening is required
+        $currentLength = strlen($name);
+        if ($currentLength <= $length) {
+            return $name;
+        }
+
+        // Split name into fragments
+        $fragments = explode('\\', $name);
+
+        // If zero length is specified, return only last fragment
+        if ($length == 0) {
+            return array_pop($fragments);
+        }
+
+        // If the name splits to only one fragment, then it cannot be shortened
+        $count = count($fragments);
+        if ($count == 1) {
+            return $name;
+        }
+
+        foreach ($fragments as $key => &$fragment) {
+
+            // Never shorten last fragment
+            if ($key == $count - 1) {
+                break;
+            }
+
+            // Check for empty fragments (shouldn't happen but it's possible)
+            $fragLen = strlen($fragment);
+            if ($fragLen <= 1) {
+                continue;
+            }
+
+            // Shorten fragment to one character and check if total length satisfactory
+            $fragment = substr($fragment, 0, 1);
+            $currentLength = $currentLength - $fragLen + 1;
+
+            if ($currentLength <= $length) {
+                break;
+            }
+        }
+        unset($fragment);
+
+        return implode('\\', $fragments);
+    }
 }
-

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Hierarchy.php
----------------------------------------------------------------------
diff --git a/src/Hierarchy.php b/src/Hierarchy.php
index 7b28a6b..384b8ee 100644
--- a/src/Hierarchy.php
+++ b/src/Hierarchy.php
@@ -46,211 +46,225 @@ use Apache\Log4php\Renderers\RendererMap;
  * to the provision node. Other descendants of the same ancestor add
  * themselves to the previously created provision node.</p>
  */
-class Hierarchy {
+class Hierarchy
+{
+    /** Array holding all Logger instances. */
+    protected $loggers = array();
 
-	/** Array holding all Logger instances. */
-	protected $loggers = array();
+    /**
+     * The root logger.
+     * @var RootLogger
+     */
+    protected $root;
 
-	/**
-	 * The root logger.
-	 * @var RootLogger
-	 */
-	protected $root;
+    /**
+     * The logger renderer map.
+     * @var RendererMap
+     */
+    protected $rendererMap;
 
-	/**
-	 * The logger renderer map.
-	 * @var RendererMap
-	 */
-	protected $rendererMap;
+    /**
+     * Main level threshold. Events with lower level will not be logged by any
+     * logger, regardless of it's configuration.
+     * @var Level
+     */
+    protected $threshold;
 
-	/**
-	 * Main level threshold. Events with lower level will not be logged by any
-	 * logger, regardless of it's configuration.
-	 * @var Level
-	 */
-	protected $threshold;
+    /**
+     * Creates a new logger hierarchy.
+     * @param RootLogger $root The root logger.
+     */
+    public function __construct(RootLogger $root)
+    {
+        $this->root = $root;
+        $this->setThreshold(Level::getLevelAll());
+        $this->rendererMap = new RendererMap();
+    }
 
-	/**
-	 * Creates a new logger hierarchy.
-	 * @param RootLogger $root The root logger.
-	 */
-	public function __construct(RootLogger $root) {
-		$this->root = $root;
-		$this->setThreshold(Level::getLevelAll());
-		$this->rendererMap = new RendererMap();
-	}
+    /**
+     * Clears all loggers.
+     */
+    public function clear()
+    {
+        $this->loggers = array();
+    }
 
-	/**
-	 * Clears all loggers.
-	 */
-	public function clear() {
-		$this->loggers = array();
-	}
+    /**
+     * Check if the named logger exists in the hierarchy.
+     * @param  string  $name
+     * @return boolean
+     */
+    public function exists($name)
+    {
+        return isset($this->loggers[$name]);
+    }
 
-	/**
-	 * Check if the named logger exists in the hierarchy.
-	 * @param string $name
-	 * @return boolean
-	 */
-	public function exists($name) {
-		return isset($this->loggers[$name]);
-	}
+    /**
+     * Returns all the currently defined loggers in this hierarchy as an array.
+     * @return array
+     */
+    public function getCurrentLoggers()
+    {
+        return array_values($this->loggers);
+    }
 
-	/**
-	 * Returns all the currently defined loggers in this hierarchy as an array.
-	 * @return array
-	 */
-	public function getCurrentLoggers() {
-		return array_values($this->loggers);
-	}
+    /**
+     * Returns a named logger instance logger. If it doesn't exist, one is created.
+     *
+     * @param  string $name Logger name
+     * @return Logger Logger instance.
+     */
+    public function getLogger($name)
+    {
+        if (!isset($this->loggers[$name])) {
+            $logger = new Logger($name);
 
-	/**
-	 * Returns a named logger instance logger. If it doesn't exist, one is created.
-	 *
-	 * @param string $name Logger name
-	 * @return Logger Logger instance.
-	 */
-	public function getLogger($name) {
-		if(!isset($this->loggers[$name])) {
-			$logger = new Logger($name);
+            $nodes = explode('.', $name);
+            $firstNode = array_shift($nodes);
 
-			$nodes = explode('.', $name);
-			$firstNode = array_shift($nodes);
+            // if name is not a first node but another first node is their
+            if ($firstNode != $name and isset($this->loggers[$firstNode])) {
+                $logger->setParent($this->loggers[$firstNode]);
+            } else {
+                // if there is no father, set root logger as father
+                $logger->setParent($this->root);
+            }
 
-			// if name is not a first node but another first node is their
-			if($firstNode != $name and isset($this->loggers[$firstNode])) {
-				$logger->setParent($this->loggers[$firstNode]);
-			} else {
-				// if there is no father, set root logger as father
-				$logger->setParent($this->root);
-			}
+            // if there are more nodes than one
+            if (count($nodes) > 0) {
+                // find parent node
+                foreach ($nodes as $node) {
+                    $parentNode = "$firstNode.$node";
+                    if (isset($this->loggers[$parentNode]) and $parentNode != $name) {
+                        $logger->setParent($this->loggers[$parentNode]);
+                    }
+                    $firstNode .= ".$node";
+                }
+            }
 
-			// if there are more nodes than one
-			if(count($nodes) > 0) {
-				// find parent node
-				foreach($nodes as $node) {
-					$parentNode = "$firstNode.$node";
-					if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
-						$logger->setParent($this->loggers[$parentNode]);
-					}
-					$firstNode .= ".$node";
-				}
-			}
+            $this->loggers[$name] = $logger;
+        }
 
-			$this->loggers[$name] = $logger;
-		}
+        return $this->loggers[$name];
+    }
 
-		return $this->loggers[$name];
-	}
+    /**
+     * Returns the logger renderer map.
+     * @return RendererMap
+     */
+    public function getRendererMap()
+    {
+        return $this->rendererMap;
+    }
 
-	/**
-	 * Returns the logger renderer map.
-	 * @return RendererMap
-	 */
-	public function getRendererMap() {
-		return $this->rendererMap;
-	}
+    /**
+     * Returns the root logger.
+     * @return RootLogger
+     */
+    public function getRootLogger()
+    {
+        return $this->root;
+    }
 
-	/**
-	 * Returns the root logger.
-	 * @return RootLogger
-	 */
-	public function getRootLogger() {
-		return $this->root;
-	}
+    /**
+     * Returns the main threshold level.
+     * @return Level
+     */
+    public function getThreshold()
+    {
+        return $this->threshold;
+    }
 
-	/**
-	 * Returns the main threshold level.
-	 * @return Level
-	 */
-	public function getThreshold() {
-		return $this->threshold;
-	}
+    /**
+     * Returns true if the hierarchy is disabled for given log level and false
+     * otherwise.
+     * @return boolean
+     */
+    public function isDisabled(Level $level)
+    {
+        return ($this->threshold->toInt() > $level->toInt());
+    }
 
-	/**
-	 * Returns true if the hierarchy is disabled for given log level and false
-	 * otherwise.
-	 * @return boolean
-	 */
-	public function isDisabled(Level $level) {
-		return ($this->threshold->toInt() > $level->toInt());
-	}
+    /**
+     * Reset all values contained in this hierarchy instance to their
+     * default.
+     *
+     * This removes all appenders from all loggers, sets
+     * the level of all non-root loggers to <i>null</i>,
+     * sets their additivity flag to <i>true</i> and sets the level
+     * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
+     *
+     * <p>Existing loggers are not removed. They are just reset.
+     *
+     * <p>This method should be used sparingly and with care as it will
+     * block all logging until it is completed.</p>
+     */
+    public function resetConfiguration()
+    {
+        $root = $this->getRootLogger();
 
-	/**
-	 * Reset all values contained in this hierarchy instance to their
-	 * default.
-	 *
-	 * This removes all appenders from all loggers, sets
-	 * the level of all non-root loggers to <i>null</i>,
-	 * sets their additivity flag to <i>true</i> and sets the level
-	 * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
-	 *
-	 * <p>Existing loggers are not removed. They are just reset.
-	 *
-	 * <p>This method should be used sparingly and with care as it will
-	 * block all logging until it is completed.</p>
-	 */
-	public function resetConfiguration() {
-		$root = $this->getRootLogger();
+        $root->setLevel(Level::getLevelDebug());
+        $this->setThreshold(Level::getLevelAll());
+        $this->shutDown();
 
-		$root->setLevel(Level::getLevelDebug());
-		$this->setThreshold(Level::getLevelAll());
-		$this->shutDown();
+        foreach ($this->loggers as $logger) {
+            $logger->setLevel(null);
+            $logger->setAdditivity(true);
+            $logger->removeAllAppenders();
+        }
 
-		foreach($this->loggers as $logger) {
-			$logger->setLevel(null);
-			$logger->setAdditivity(true);
-			$logger->removeAllAppenders();
-		}
+        $this->rendererMap->reset();
+        AppenderPool::clear();
+    }
 
-		$this->rendererMap->reset();
-		AppenderPool::clear();
-	}
+    /**
+     * Sets the main threshold level.
+     * @param Level $l
+     */
+    public function setThreshold(Level $threshold)
+    {
+        $this->threshold = $threshold;
+    }
 
-	/**
-	 * Sets the main threshold level.
-	 * @param Level $l
-	 */
-	public function setThreshold(Level $threshold) {
-		$this->threshold = $threshold;
-	}
+    /**
+     * Shutting down a hierarchy will <i>safely</i> close and remove
+     * all appenders in all loggers including the root logger.
+     *
+     * The shutdown method is careful to close nested
+     * appenders before closing regular appenders. This is allows
+     * configurations where a regular appender is attached to a logger
+     * and again to a nested appender.
+     *
+     * @todo Check if the last paragraph is correct.
+     */
+    public function shutdown()
+    {
+        $this->root->removeAllAppenders();
 
-	/**
-	 * Shutting down a hierarchy will <i>safely</i> close and remove
-	 * all appenders in all loggers including the root logger.
-	 *
-	 * The shutdown method is careful to close nested
-	 * appenders before closing regular appenders. This is allows
-	 * configurations where a regular appender is attached to a logger
-	 * and again to a nested appender.
-	 *
-	 * @todo Check if the last paragraph is correct.
-	 */
-	public function shutdown() {
-		$this->root->removeAllAppenders();
+        foreach ($this->loggers as $logger) {
+            $logger->removeAllAppenders();
+        }
+    }
 
-		foreach($this->loggers as $logger) {
-			$logger->removeAllAppenders();
-		}
-	}
+    /**
+     * Prints the current Logger hierarchy tree. Useful for debugging.
+     */
+    public function printHierarchy()
+    {
+        $this->printHierarchyInner($this->getRootLogger(), 0);
+    }
 
-	/**
-	 * 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";
 
-	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);
-			}
-		}
-	}
+        foreach ($this->loggers as $logger) {
+            if ($logger->getParent() == $current) {
+                $this->printHierarchyInner($logger, $level + 1);
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/AbstractLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/AbstractLayout.php b/src/Layouts/AbstractLayout.php
index b6a2d14..3a8e486 100644
--- a/src/Layouts/AbstractLayout.php
+++ b/src/Layouts/AbstractLayout.php
@@ -24,51 +24,58 @@ use Apache\Log4php\LoggingEvent;
 /**
  * Extend this abstract class to create your own log layout format.
  */
-abstract class AbstractLayout extends Configurable {
-	/**
-	 * Activates options for this layout.
-	 * Override this method if you have options to be activated.
-	 */
-	public function activateOptions() {
-		return true;
-	}
+abstract class AbstractLayout extends Configurable
+{
+    /**
+     * Activates options for this layout.
+     * Override this method if you have options to be activated.
+     */
+    public function activateOptions()
+    {
+        return true;
+    }
 
-	/**
-	 * Override this method to create your own layout format.
-	 *
-	 * @param LoggingEvent
-	 * @return string
-	 */
-	public function format(LoggingEvent $event) {
-		return $event->getRenderedMessage();
-	}
+    /**
+     * Override this method to create your own layout format.
+     *
+     * @param LoggingEvent
+     * @return string
+     */
+    public function format(LoggingEvent $event)
+    {
+        return $event->getRenderedMessage();
+    }
 
-	/**
-	 * Returns the content type output by this layout.
-	 * @return string
-	 */
-	public function getContentType() {
-		return "text/plain";
-	}
+    /**
+     * Returns the content type output by this layout.
+     * @return string
+     */
+    public function getContentType()
+    {
+        return "text/plain";
+    }
 
-	/**
-	 * Returns the footer for the layout format.
-	 * @return string
-	 */
-	public function getFooter() {
-		return null;
-	}
+    /**
+     * Returns the footer for the layout format.
+     * @return string
+     */
+    public function getFooter()
+    {
+        return null;
+    }
 
-	/**
-	 * Returns the header for the layout format.
-	 * @return string
-	 */
-	public function getHeader() {
-		return null;
-	}
+    /**
+     * Returns the header for the layout format.
+     * @return string
+     */
+    public function getHeader()
+    {
+        return null;
+    }
 
-	/** Triggers a warning for this layout with the given message. */
-	protected function warn($message) {
-		trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
-	}
+    /** Triggers a warning for this layout with the given message. */
+    protected function warn($message)
+    {
+        trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/HtmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/HtmlLayout.php b/src/Layouts/HtmlLayout.php
index af74e61..6a5bd50 100644
--- a/src/Layouts/HtmlLayout.php
+++ b/src/Layouts/HtmlLayout.php
@@ -29,169 +29,179 @@ use Apache\Log4php\Level;
  * - title
  * - locationInfo
  */
-class HtmlLayout extends AbstractLayout {
-	/**
-	 * The <b>LocationInfo</b> option takes a boolean value. By
-	 * default, it is set to false which means there will be no location
-	 * information output by this layout. If the the option is set to
-	 * true, then the file name and line number of the statement
-	 * at the origin of the log statement will be output.
-	 *
-	 * <p>If you are embedding this layout within a {@link MailAppender}
-	 * or a {@link MailEventAppender} then make sure to set the
-	 * <b>LocationInfo</b> option of that appender as well.
-	 * @var boolean
-	 */
-	protected $locationInfo = false;
-
-	/**
-	 * The <b>Title</b> option takes a String value. This option sets the
-	 * document title of the generated HTML document.
-	 * Defaults to 'Log4php Log Messages'.
-	 * @var string
-	 */
-	protected $title = "Log4php Log Messages";
-
-	/**
-	 * The <b>LocationInfo</b> option takes a boolean value. By
-	 * default, it is set to false which means there will be no location
-	 * information output by this layout. If the the option is set to
-	 * true, then the file name and line number of the statement
-	 * at the origin of the log statement will be output.
-	 *
-	 * <p>If you are embedding this layout within a {@link MailAppender}
-	 * or a {@link MailEventAppender} then make sure to set the
-	 * <b>LocationInfo</b> option of that appender as well.
-	 */
-	public function setLocationInfo($flag) {
-		$this->setBoolean('locationInfo', $flag);
-	}
-
-	/**
-	 * Returns the current value of the <b>LocationInfo</b> option.
-	 */
-	public function getLocationInfo() {
-		return $this->locationInfo;
-	}
-
-	/**
-	 * The <b>Title</b> option takes a String value. This option sets the
-	 * document title of the generated HTML document.
-	 * Defaults to 'Log4php Log Messages'.
-	 */
-	public function setTitle($title) {
-		$this->setString('title', $title);
-	}
-
-	/**
-	 * @return string Returns the current value of the <b>Title</b> option.
-	 */
-	public function getTitle() {
-		return $this->title;
-	}
-
-	/**
-	 * @return string Returns the content type output by this layout, i.e "text/html".
-	 */
-	public function getContentType() {
-		return "text/html";
-	}
-
-	/**
-	 * @param LoggingEvent $event
-	 * @return string
-	 */
-	public function format(LoggingEvent $event) {
-		$sbuf = PHP_EOL . "<tr>" . PHP_EOL;
-
-		$sbuf .= "<td>";
-		$sbuf .= round(1000 * $event->getRelativeTime());
-		$sbuf .= "</td>" . PHP_EOL;
-
-		$sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
-		$sbuf .= $event->getThreadName();
-		$sbuf .= "</td>" . PHP_EOL;
-
-		$sbuf .= "<td title=\"Level\">";
-
-		$level = $event->getLevel();
-
-		if ($level->equals(Level::getLevelDebug())) {
-			$sbuf .= "<font color=\"#339933\">$level</font>";
-		} else if ($level->equals(Level::getLevelWarn())) {
-			$sbuf .= "<font color=\"#993300\"><strong>$level</strong></font>";
-		} else {
-			$sbuf .= $level;
-		}
-		$sbuf .= "</td>" . PHP_EOL;
-
-		$sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
-		$sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
-		$sbuf .= "</td>" . PHP_EOL;
-
-		if ($this->locationInfo) {
-			$locInfo = $event->getLocationInformation();
-			$sbuf .= "<td>";
-			$sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES). ':' . $locInfo->getLineNumber();
-			$sbuf .= "</td>" . PHP_EOL;
-		}
-
-		$sbuf .= "<td title=\"Message\">";
-		$sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
-		$sbuf .= "</td>" . PHP_EOL;
-
-		$sbuf .= "</tr>" . PHP_EOL;
-
-		if ($event->getNDC() != null) {
-			$sbuf .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">";
-			$sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
-			$sbuf .= "</td></tr>" . PHP_EOL;
-		}
-		return $sbuf;
-	}
-
-	/**
-	 * @return string Returns appropriate HTML headers.
-	 */
-	public function getHeader() {
-		$sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
-		$sbuf .= "<html>" . PHP_EOL;
-		$sbuf .= "<head>" . PHP_EOL;
-		$sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
-		$sbuf .= "<style type=\"text/css\">" . PHP_EOL;
-		$sbuf .= "<!--" . PHP_EOL;
-		$sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
-		$sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
-		$sbuf .= "-->" . PHP_EOL;
-		$sbuf .= "</style>" . PHP_EOL;
-		$sbuf .= "</head>" . PHP_EOL;
-		$sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
-		$sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
-		$sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
-		$sbuf .= "<br>" . PHP_EOL;
-		$sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
-		$sbuf .= "<tr>" . PHP_EOL;
-		$sbuf .= "<th>Time</th>" . PHP_EOL;
-		$sbuf .= "<th>Thread</th>" . PHP_EOL;
-		$sbuf .= "<th>Level</th>" . PHP_EOL;
-		$sbuf .= "<th>Category</th>" . PHP_EOL;
-		if ($this->locationInfo) {
-			$sbuf .= "<th>File:Line</th>" . PHP_EOL;
-		}
-		$sbuf .= "<th>Message</th>" . PHP_EOL;
-		$sbuf .= "</tr>" . PHP_EOL;
-
-		return $sbuf;
-	}
-
-	/**
-	 * @return string Returns the appropriate HTML footers.
-	 */
-	public function getFooter() {
-		$sbuf = "</table>" . PHP_EOL;
-		$sbuf .= "<br>" . PHP_EOL;
-		$sbuf .= "</body></html>";
-
-		return $sbuf;
-	}
+class HtmlLayout extends AbstractLayout
+{
+    /**
+     * The <b>LocationInfo</b> option takes a boolean value. By
+     * default, it is set to false which means there will be no location
+     * information output by this layout. If the the option is set to
+     * true, then the file name and line number of the statement
+     * at the origin of the log statement will be output.
+     *
+     * <p>If you are embedding this layout within a {@link MailAppender}
+     * or a {@link MailEventAppender} then make sure to set the
+     * <b>LocationInfo</b> option of that appender as well.
+     * @var boolean
+     */
+    protected $locationInfo = false;
+
+    /**
+     * The <b>Title</b> option takes a String value. This option sets the
+     * document title of the generated HTML document.
+     * Defaults to 'Log4php Log Messages'.
+     * @var string
+     */
+    protected $title = "Log4php Log Messages";
+
+    /**
+     * The <b>LocationInfo</b> option takes a boolean value. By
+     * default, it is set to false which means there will be no location
+     * information output by this layout. If the the option is set to
+     * true, then the file name and line number of the statement
+     * at the origin of the log statement will be output.
+     *
+     * <p>If you are embedding this layout within a {@link MailAppender}
+     * or a {@link MailEventAppender} then make sure to set the
+     * <b>LocationInfo</b> option of that appender as well.
+     */
+    public function setLocationInfo($flag)
+    {
+        $this->setBoolean('locationInfo', $flag);
+    }
+
+    /**
+     * Returns the current value of the <b>LocationInfo</b> option.
+     */
+    public function getLocationInfo()
+    {
+        return $this->locationInfo;
+    }
+
+    /**
+     * The <b>Title</b> option takes a String value. This option sets the
+     * document title of the generated HTML document.
+     * Defaults to 'Log4php Log Messages'.
+     */
+    public function setTitle($title)
+    {
+        $this->setString('title', $title);
+    }
+
+    /**
+     * @return string Returns the current value of the <b>Title</b> option.
+     */
+    public function getTitle()
+    {
+        return $this->title;
+    }
+
+    /**
+     * @return string Returns the content type output by this layout, i.e "text/html".
+     */
+    public function getContentType()
+    {
+        return "text/html";
+    }
+
+    /**
+     * @param  LoggingEvent $event
+     * @return string
+     */
+    public function format(LoggingEvent $event)
+    {
+        $sbuf = PHP_EOL . "<tr>" . PHP_EOL;
+
+        $sbuf .= "<td>";
+        $sbuf .= round(1000 * $event->getRelativeTime());
+        $sbuf .= "</td>" . PHP_EOL;
+
+        $sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
+        $sbuf .= $event->getThreadName();
+        $sbuf .= "</td>" . PHP_EOL;
+
+        $sbuf .= "<td title=\"Level\">";
+
+        $level = $event->getLevel();
+
+        if ($level->equals(Level::getLevelDebug())) {
+            $sbuf .= "<font color=\"#339933\">$level</font>";
+        } elseif ($level->equals(Level::getLevelWarn())) {
+            $sbuf .= "<font color=\"#993300\"><strong>$level</strong></font>";
+        } else {
+            $sbuf .= $level;
+        }
+        $sbuf .= "</td>" . PHP_EOL;
+
+        $sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
+        $sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
+        $sbuf .= "</td>" . PHP_EOL;
+
+        if ($this->locationInfo) {
+            $locInfo = $event->getLocationInformation();
+            $sbuf .= "<td>";
+            $sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES). ':' . $locInfo->getLineNumber();
+            $sbuf .= "</td>" . PHP_EOL;
+        }
+
+        $sbuf .= "<td title=\"Message\">";
+        $sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
+        $sbuf .= "</td>" . PHP_EOL;
+
+        $sbuf .= "</tr>" . PHP_EOL;
+
+        if ($event->getNDC() != null) {
+            $sbuf .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">";
+            $sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
+            $sbuf .= "</td></tr>" . PHP_EOL;
+        }
+
+        return $sbuf;
+    }
+
+    /**
+     * @return string Returns appropriate HTML headers.
+     */
+    public function getHeader()
+    {
+        $sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
+        $sbuf .= "<html>" . PHP_EOL;
+        $sbuf .= "<head>" . PHP_EOL;
+        $sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
+        $sbuf .= "<style type=\"text/css\">" . PHP_EOL;
+        $sbuf .= "<!--" . PHP_EOL;
+        $sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
+        $sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
+        $sbuf .= "-->" . PHP_EOL;
+        $sbuf .= "</style>" . PHP_EOL;
+        $sbuf .= "</head>" . PHP_EOL;
+        $sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
+        $sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
+        $sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
+        $sbuf .= "<br>" . PHP_EOL;
+        $sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
+        $sbuf .= "<tr>" . PHP_EOL;
+        $sbuf .= "<th>Time</th>" . PHP_EOL;
+        $sbuf .= "<th>Thread</th>" . PHP_EOL;
+        $sbuf .= "<th>Level</th>" . PHP_EOL;
+        $sbuf .= "<th>Category</th>" . PHP_EOL;
+        if ($this->locationInfo) {
+            $sbuf .= "<th>File:Line</th>" . PHP_EOL;
+        }
+        $sbuf .= "<th>Message</th>" . PHP_EOL;
+        $sbuf .= "</tr>" . PHP_EOL;
+
+        return $sbuf;
+    }
+
+    /**
+     * @return string Returns the appropriate HTML footers.
+     */
+    public function getFooter()
+    {
+        $sbuf = "</table>" . PHP_EOL;
+        $sbuf .= "<br>" . PHP_EOL;
+        $sbuf .= "</body></html>";
+
+        return $sbuf;
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/PatternLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/PatternLayout.php b/src/Layouts/PatternLayout.php
index c34cbe2..58f1b50 100644
--- a/src/Layouts/PatternLayout.php
+++ b/src/Layouts/PatternLayout.php
@@ -30,142 +30,148 @@ use Apache\Log4php\LoggingEvent;
  * * converionPattern - A string which controls the formatting of logging
  *   events. See docs for full specification.
  */
-class PatternLayout extends AbstractLayout {
+class PatternLayout extends AbstractLayout
+{
+    /** Default conversion pattern */
+    const DEFAULT_CONVERSION_PATTERN = '%date %-5level %logger %message%newline';
 
-	/** Default conversion pattern */
-	const DEFAULT_CONVERSION_PATTERN = '%date %-5level %logger %message%newline';
+    /** Default conversion TTCC Pattern */
+    const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
 
-	/** Default conversion TTCC Pattern */
-	const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
+    /** The conversion pattern. */
+    protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
 
-	/** The conversion pattern. */
-	protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
+    /** Maps conversion keywords to the relevant converter (default implementation). */
+    protected static $defaultConverterMap = array(
+        'c' => 'LoggerConverter',
+        'lo' => 'LoggerConverter',
+        'logger' => 'LoggerConverter',
 
-	/** Maps conversion keywords to the relevant converter (default implementation). */
-	protected static $defaultConverterMap = array(
-		'c' => 'LoggerConverter',
-		'lo' => 'LoggerConverter',
-		'logger' => 'LoggerConverter',
-
-		'C' => 'ClassConverter',
-		'class' => 'ClassConverter',
-
-		'cookie' => 'CookieConverter',
-
-		'd' => 'DateConverter',
-		'date' => 'DateConverter',
-
-		'e' => 'EnvironmentConverter',
-		'env' => 'EnvironmentConverter',
-
-		'ex' => 'ThrowableConverter',
-		'exception' => 'ThrowableConverter',
-		'throwable' => 'ThrowableConverter',
-
-		'F' => 'FileConverter',
-		'file' => 'FileConverter',
-
-		'l' => 'LocationConverter',
-		'location' => 'LocationConverter',
-
-		'L' => 'LineConverter',
-		'line' => 'LineConverter',
-
-		'm' => 'MessageConverter',
-		'msg' => 'MessageConverter',
-		'message' => 'MessageConverter',
-
-		'M' => 'MethodConverter',
-		'method' => 'MethodConverter',
-
-		'n' => 'NewLineConverter',
-		'newline' => 'NewLineConverter',
-
-		'p' => 'LevelConverter',
-		'le' => 'LevelConverter',
-		'level' => 'LevelConverter',
-
-		'r' => 'RelativeConverter',
-		'relative' => 'RelativeConverter',
-
-		'req' => 'RequestConverter',
-		'request' => 'RequestConverter',
-
-		's' => 'ServerConverter',
-		'server' => 'ServerConverter',
-
-		'ses' => 'SessionConverter',
-		'session' => 'SessionConverter',
-
-		'sid' => 'SessionIdConverter',
-		'sessionid' => 'SessionIdConverter',
-
-		't' => 'ProcessConverter',
-		'pid' => 'ProcessConverter',
-		'process' => 'ProcessConverter',
-
-		'x' => 'NdcConverter',
-		'ndc' => 'NdcConverter',
-
-		'X' => 'MdcConverter',
-		'mdc' => 'MdcConverter',
-	);
-
-	/** Maps conversion keywords to the relevant converter. */
-	protected $converterMap = array();
-
-	/**
-	 * Head of a chain of Converters.
-	 * @var AbstractConverter
-	 */
-	private $head;
-
-	/** Returns the default converter map. */
-	public static function getDefaultConverterMap() {
-		return self::$defaultConverterMap;
-	}
-
-	/** Constructor. Initializes the converter map. */
-	public function __construct() {
-		$this->converterMap = self::$defaultConverterMap;
-	}
-
-	/**
-	 * Sets the conversionPattern option. This is the string which
-	 * controls formatting and consists of a mix of literal content and
-	 * conversion specifiers.
-	 * @param array $conversionPattern
-	 */
-	public function setConversionPattern($conversionPattern) {
-		$this->pattern = $conversionPattern;
-	}
-
-	/**
-	 * Processes the conversion pattern and creates a corresponding chain of
-	 * pattern converters which will be used to format logging events.
-	 */
-	public function activateOptions() {
-		if (!isset($this->pattern)) {
-			throw new LoggerException("Mandatory parameter 'conversionPattern' is not set.");
-		}
-
-		$parser = new PatternParser($this->pattern, $this->converterMap);
-		$this->head = $parser->parse();
-	}
-
-	/**
-	 * Produces a formatted string as specified by the conversion pattern.
-	 *
-	 * @param LoggingEvent $event
-	 * @return string
-	 */
-	public function format(LoggingEvent $event) {
-		$sbuf = '';
-		$converter = $this->head;
-		while ($converter !== null) {
-			$converter->format($sbuf, $event);
-			$converter = $converter->next;
-		}
-		return $sbuf;
-	}
-}
\ No newline at end of file
+        'C' => 'ClassConverter',
+        'class' => 'ClassConverter',
+
+        'cookie' => 'CookieConverter',
+
+        'd' => 'DateConverter',
+        'date' => 'DateConverter',
+
+        'e' => 'EnvironmentConverter',
+        'env' => 'EnvironmentConverter',
+
+        'ex' => 'ThrowableConverter',
+        'exception' => 'ThrowableConverter',
+        'throwable' => 'ThrowableConverter',
+
+        'F' => 'FileConverter',
+        'file' => 'FileConverter',
+
+        'l' => 'LocationConverter',
+        'location' => 'LocationConverter',
+
+        'L' => 'LineConverter',
+        'line' => 'LineConverter',
+
+        'm' => 'MessageConverter',
+        'msg' => 'MessageConverter',
+        'message' => 'MessageConverter',
+
+        'M' => 'MethodConverter',
+        'method' => 'MethodConverter',
+
+        'n' => 'NewLineConverter',
+        'newline' => 'NewLineConverter',
+
+        'p' => 'LevelConverter',
+        'le' => 'LevelConverter',
+        'level' => 'LevelConverter',
+
+        'r' => 'RelativeConverter',
+        'relative' => 'RelativeConverter',
+
+        'req' => 'RequestConverter',
+        'request' => 'RequestConverter',
+
+        's' => 'ServerConverter',
+        'server' => 'ServerConverter',
+
+        'ses' => 'SessionConverter',
+        'session' => 'SessionConverter',
+
+        'sid' => 'SessionIdConverter',
+        'sessionid' => 'SessionIdConverter',
+
+        't' => 'ProcessConverter',
+        'pid' => 'ProcessConverter',
+        'process' => 'ProcessConverter',
+
+        'x' => 'NdcConverter',
+        'ndc' => 'NdcConverter',
+
+        'X' => 'MdcConverter',
+        'mdc' => 'MdcConverter',
+    );
+
+    /** Maps conversion keywords to the relevant converter. */
+    protected $converterMap = array();
+
+    /**
+     * Head of a chain of Converters.
+     * @var AbstractConverter
+     */
+    private $head;
+
+    /** Returns the default converter map. */
+    public static function getDefaultConverterMap()
+    {
+        return self::$defaultConverterMap;
+    }
+
+    /** Constructor. Initializes the converter map. */
+    public function __construct()
+    {
+        $this->converterMap = self::$defaultConverterMap;
+    }
+
+    /**
+     * Sets the conversionPattern option. This is the string which
+     * controls formatting and consists of a mix of literal content and
+     * conversion specifiers.
+     * @param array $conversionPattern
+     */
+    public function setConversionPattern($conversionPattern)
+    {
+        $this->pattern = $conversionPattern;
+    }
+
+    /**
+     * Processes the conversion pattern and creates a corresponding chain of
+     * pattern converters which will be used to format logging events.
+     */
+    public function activateOptions()
+    {
+        if (!isset($this->pattern)) {
+            throw new LoggerException("Mandatory parameter 'conversionPattern' is not set.");
+        }
+
+        $parser = new PatternParser($this->pattern, $this->converterMap);
+        $this->head = $parser->parse();
+    }
+
+    /**
+     * Produces a formatted string as specified by the conversion pattern.
+     *
+     * @param  LoggingEvent $event
+     * @return string
+     */
+    public function format(LoggingEvent $event)
+    {
+        $sbuf = '';
+        $converter = $this->head;
+        while ($converter !== null) {
+            $converter->format($sbuf, $event);
+            $converter = $converter->next;
+        }
+
+        return $sbuf;
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/SerializedLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/SerializedLayout.php b/src/Layouts/SerializedLayout.php
index 5273c3b..12fb53f 100644
--- a/src/Layouts/SerializedLayout.php
+++ b/src/Layouts/SerializedLayout.php
@@ -28,26 +28,30 @@ use Apache\Log4php\LoggingEvent;
  *                  be serialized (slow, defaults to false).
  * @since 2.2
  */
-class SerializedLayout extends AbstractLayout {
+class SerializedLayout extends AbstractLayout
+{
+    /** Whether to include the event's location information (slow). */
+    protected $locationInfo = false;
 
-	/** Whether to include the event's location information (slow). */
-	protected $locationInfo = false;
+    /** Sets the location information flag. */
+    public function setLocationInfo($value)
+    {
+        $this->setBoolean('locationInfo', $value);
+    }
 
-	/** Sets the location information flag. */
-	public function setLocationInfo($value) {
-		$this->setBoolean('locationInfo', $value);
-	}
+    /** Returns the location information flag. */
+    public function getLocationInfo()
+    {
+        return $this->locationInfo;
+    }
 
-	/** Returns the location information flag. */
-	public function getLocationInfo() {
-		return $this->locationInfo;
-	}
+    public function format(LoggingEvent $event)
+    {
+        // If required, initialize the location data
+        if ($this->locationInfo) {
+            $event->getLocationInformation();
+        }
 
-	public function format(LoggingEvent $event) {
-		// If required, initialize the location data
-		if($this->locationInfo) {
-			$event->getLocationInformation();
-		}
-		return serialize($event) . PHP_EOL;
-	}
+        return serialize($event) . PHP_EOL;
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/SimpleLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/SimpleLayout.php b/src/Layouts/SimpleLayout.php
index 16645f3..5f57e0a 100644
--- a/src/Layouts/SimpleLayout.php
+++ b/src/Layouts/SimpleLayout.php
@@ -26,19 +26,22 @@ use Apache\Log4php\LoggingEvent;
  * Returns the log statement in a format consisting of the
  * <b>level</b>, followed by " - " and then the <b>message</b>.
  */
-class SimpleLayout extends AbstractLayout {
-	/**
-	 * Returns the log statement in a format consisting of the
-	 * <b>level</b>, followed by " - " and then the
-	 * <b>message</b>. For example,
-	 * <samp> INFO - "A message" </samp>
-	 *
-	 * @param LoggingEvent $event
-	 * @return string
-	 */
-	public function format(LoggingEvent $event) {
-		$level = $event->getLevel();
-		$message = $event->getRenderedMessage();
-		return "$level - $message" . PHP_EOL;
-	}
+class SimpleLayout extends AbstractLayout
+{
+    /**
+     * Returns the log statement in a format consisting of the
+     * <b>level</b>, followed by " - " and then the
+     * <b>message</b>. For example,
+     * <samp> INFO - "A message" </samp>
+     *
+     * @param  LoggingEvent $event
+     * @return string
+     */
+    public function format(LoggingEvent $event)
+    {
+        $level = $event->getLevel();
+        $message = $event->getRenderedMessage();
+
+        return "$level - $message" . PHP_EOL;
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/XmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/XmlLayout.php b/src/Layouts/XmlLayout.php
index 0ada386..f3b94b0 100644
--- a/src/Layouts/XmlLayout.php
+++ b/src/Layouts/XmlLayout.php
@@ -35,158 +35,167 @@ use Apache\Log4php\LoggingEvent;
  * a correct XML file.</p>
  *
  */
-class XmlLayout extends AbstractLayout {
-	const LOG4J_NS_PREFIX ='log4j';
-	const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
-
-	const LOG4PHP_NS_PREFIX = 'log4php';
-	const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
-
-	const CDATA_START = '<![CDATA[';
-	const CDATA_END = ']]>';
-	const CDATA_PSEUDO_END = ']]&gt;';
-	const CDATA_EMBEDDED_END = ']]>]]&gt;<![CDATA[';
-
-	/**
-	 * If set to true then the file name and line number of the origin of the
-	 * log statement will be output.
-	 * @var boolean
-	 */
-	protected $locationInfo = true;
-
-	/**
-	 * If set to true, log4j namespace will be used instead of the log4php
-	 * namespace.
-	 * @var boolean
-	 */
-	protected $log4jNamespace = false;
-
-	/** The namespace in use. */
-	protected $namespace = self::LOG4PHP_NS;
-
-	/** The namespace prefix in use */
-	protected $namespacePrefix = self::LOG4PHP_NS_PREFIX;
-
-	public function activateOptions() {
-		if ($this->getLog4jNamespace()) {
-			$this->namespace        = self::LOG4J_NS;
-			$this->namespacePrefix  = self::LOG4J_NS_PREFIX;
-		} else {
-			$this->namespace        = self::LOG4PHP_NS;
-			$this->namespacePrefix  = self::LOG4PHP_NS_PREFIX;
-		}
-	}
-
-	/**
-	 * @return string
-	 */
-	public function getHeader() {
-		return "<{$this->namespacePrefix}:eventSet ".
-			"xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
-			"version=\"0.3\" ".
-			"includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
-			">" . PHP_EOL;
-	}
-
-	/**
-	 * Formats a {@link LoggingEvent} in conformance with the log4php.dtd.
-	 *
-	 * @param LoggingEvent $event
-	 * @return string
-	 */
-	public function format(LoggingEvent $event) {
-		$ns = $this->namespacePrefix;
-
-		$loggerName = $event->getLoggerName();
-		$timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', '');
-		$thread = $event->getThreadName();
-		$level = $event->getLevel()->toString();
-
-		$buf  = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
-		$buf .= "<$ns:message>";
-		$buf .= $this->encodeCDATA($event->getRenderedMessage());
-		$buf .= "</$ns:message>".PHP_EOL;
-
-		$ndc = $event->getNDC();
-		if(!empty($ndc)) {
-			$buf .= "<$ns:NDC><![CDATA[";
-			$buf .= $this->encodeCDATA($ndc);
-			$buf .= "]]></$ns:NDC>".PHP_EOL;
-		}
-
-		$mdcMap = $event->getMDCMap();
-		if (!empty($mdcMap)) {
-			$buf .= "<$ns:properties>".PHP_EOL;
-			foreach ($mdcMap as $name=>$value) {
-				$buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL;
-			}
-			$buf .= "</$ns:properties>".PHP_EOL;
-		}
-
-		if ($this->getLocationInfo()) {
-			$locationInfo = $event->getLocationInformation();
-			$buf .= "<$ns:locationInfo ".
-					"class=\"" . $locationInfo->getClassName() . "\" ".
-					"file=\"" .  htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ".
-					"line=\"" .  $locationInfo->getLineNumber() . "\" ".
-					"method=\"" . $locationInfo->getMethodName() . "\" ";
-			$buf .= "/>".PHP_EOL;
-		}
-
-		$buf .= "</$ns:event>".PHP_EOL;
-
-		return $buf;
-	}
-
-	/**
-	 * @return string
-	 */
-	public function getFooter() {
-		return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL;
-	}
-
-
-	/**
-	 * Whether or not file name and line number will be included in the output.
-	 * @return boolean
-	 */
-	public function getLocationInfo() {
-		return $this->locationInfo;
-	}
-
-	/**
-	 * The {@link $locationInfo} option takes a boolean value. By default,
-	 * it is set to false which means there will be no location
-	 * information output by this layout. If the the option is set to
-	 * true, then the file name and line number of the statement at the
-	 * origin of the log statement will be output.
-	 */
-	public function setLocationInfo($flag) {
-		$this->setBoolean('locationInfo', $flag);
-	}
-
-	/**
-	 * @return boolean
-	 */
-	 public function getLog4jNamespace() {
-	 	return $this->log4jNamespace;
-	 }
-
-	/**
-	 * @param boolean
-	 */
-	public function setLog4jNamespace($flag) {
-		$this->setBoolean('log4jNamespace', $flag);
-	}
-
-	/**
-	 * Encases a string in CDATA tags, and escapes any existing CDATA end
-	 * tags already present in the string.
-	 * @param string $string
-	 */
-	private function encodeCDATA($string) {
-		$string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
-		return self::CDATA_START . $string . self::CDATA_END;
-	}
+class XmlLayout extends AbstractLayout
+{
+    const LOG4J_NS_PREFIX ='log4j';
+    const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
+
+    const LOG4PHP_NS_PREFIX = 'log4php';
+    const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
+
+    const CDATA_START = '<![CDATA[';
+    const CDATA_END = ']]>';
+    const CDATA_PSEUDO_END = ']]&gt;';
+    const CDATA_EMBEDDED_END = ']]>]]&gt;<![CDATA[';
+
+    /**
+     * If set to true then the file name and line number of the origin of the
+     * log statement will be output.
+     * @var boolean
+     */
+    protected $locationInfo = true;
+
+    /**
+     * If set to true, log4j namespace will be used instead of the log4php
+     * namespace.
+     * @var boolean
+     */
+    protected $log4jNamespace = false;
+
+    /** The namespace in use. */
+    protected $namespace = self::LOG4PHP_NS;
+
+    /** The namespace prefix in use */
+    protected $namespacePrefix = self::LOG4PHP_NS_PREFIX;
+
+    public function activateOptions()
+    {
+        if ($this->getLog4jNamespace()) {
+            $this->namespace        = self::LOG4J_NS;
+            $this->namespacePrefix  = self::LOG4J_NS_PREFIX;
+        } else {
+            $this->namespace        = self::LOG4PHP_NS;
+            $this->namespacePrefix  = self::LOG4PHP_NS_PREFIX;
+        }
+    }
+
+    /**
+     * @return string
+     */
+    public function getHeader()
+    {
+        return "<{$this->namespacePrefix}:eventSet ".
+            "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
+            "version=\"0.3\" ".
+            "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
+            ">" . PHP_EOL;
+    }
+
+    /**
+     * Formats a {@link LoggingEvent} in conformance with the log4php.dtd.
+     *
+     * @param  LoggingEvent $event
+     * @return string
+     */
+    public function format(LoggingEvent $event)
+    {
+        $ns = $this->namespacePrefix;
+
+        $loggerName = $event->getLoggerName();
+        $timeStamp = number_format((float) ($event->getTimeStamp() * 1000), 0, '', '');
+        $thread = $event->getThreadName();
+        $level = $event->getLevel()->toString();
+
+        $buf  = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
+        $buf .= "<$ns:message>";
+        $buf .= $this->encodeCDATA($event->getRenderedMessage());
+        $buf .= "</$ns:message>".PHP_EOL;
+
+        $ndc = $event->getNDC();
+        if (!empty($ndc)) {
+            $buf .= "<$ns:NDC><![CDATA[";
+            $buf .= $this->encodeCDATA($ndc);
+            $buf .= "]]></$ns:NDC>".PHP_EOL;
+        }
+
+        $mdcMap = $event->getMDCMap();
+        if (!empty($mdcMap)) {
+            $buf .= "<$ns:properties>".PHP_EOL;
+            foreach ($mdcMap as $name=>$value) {
+                $buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL;
+            }
+            $buf .= "</$ns:properties>".PHP_EOL;
+        }
+
+        if ($this->getLocationInfo()) {
+            $locationInfo = $event->getLocationInformation();
+            $buf .= "<$ns:locationInfo ".
+                    "class=\"" . $locationInfo->getClassName() . "\" ".
+                    "file=\"" .  htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ".
+                    "line=\"" .  $locationInfo->getLineNumber() . "\" ".
+                    "method=\"" . $locationInfo->getMethodName() . "\" ";
+            $buf .= "/>".PHP_EOL;
+        }
+
+        $buf .= "</$ns:event>".PHP_EOL;
+
+        return $buf;
+    }
+
+    /**
+     * @return string
+     */
+    public function getFooter()
+    {
+        return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL;
+    }
+
+    /**
+     * Whether or not file name and line number will be included in the output.
+     * @return boolean
+     */
+    public function getLocationInfo()
+    {
+        return $this->locationInfo;
+    }
+
+    /**
+     * The {@link $locationInfo} option takes a boolean value. By default,
+     * it is set to false which means there will be no location
+     * information output by this layout. If the the option is set to
+     * true, then the file name and line number of the statement at the
+     * origin of the log statement will be output.
+     */
+    public function setLocationInfo($flag)
+    {
+        $this->setBoolean('locationInfo', $flag);
+    }
+
+    /**
+     * @return boolean
+     */
+     public function getLog4jNamespace()
+     {
+         return $this->log4jNamespace;
+     }
+
+    /**
+     * @param boolean
+     */
+    public function setLog4jNamespace($flag)
+    {
+        $this->setBoolean('log4jNamespace', $flag);
+    }
+
+    /**
+     * Encases a string in CDATA tags, and escapes any existing CDATA end
+     * tags already present in the string.
+     * @param string $string
+     */
+    private function encodeCDATA($string)
+    {
+        $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
+
+        return self::CDATA_START . $string . self::CDATA_END;
+    }
 }
-


Mime
View raw message