Author: grobmeier
Date: Sat May 23 22:21:28 2009
New Revision: 778046

URL: http://svn.apache.org/viewvc?rev=778046&view=rev
Log:
LOG4PHP-45: followed one class one file convention

Added:
    incubator/log4php/trunk/src/main/php/helpers/LoggerBasicPatternConverter.php
    
incubator/log4php/trunk/src/main/php/helpers/LoggerCategoryPatternConverter.php
    
incubator/log4php/trunk/src/main/php/helpers/LoggerClassNamePatternConverter.php
    incubator/log4php/trunk/src/main/php/helpers/LoggerDatePatternConverter.php
    
incubator/log4php/trunk/src/main/php/helpers/LoggerLiteralPatternConverter.php
    
incubator/log4php/trunk/src/main/php/helpers/LoggerLocationPatternConverter.php
    incubator/log4php/trunk/src/main/php/helpers/LoggerMDCPatternConverter.php
    incubator/log4php/trunk/src/main/php/helpers/LoggerNamedPatternConverter.php
Modified:
    incubator/log4php/trunk/src/main/php/LoggerManager.php
    incubator/log4php/trunk/src/main/php/helpers/LoggerPatternConverter.php

Modified: incubator/log4php/trunk/src/main/php/LoggerManager.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerManager.php?rev=778046&r1=778045&r2=778046&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerManager.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerManager.php Sat May 23 22:21:28 
2009
@@ -77,14 +77,22 @@
                'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php',
                'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php',
                'LoggerPatternConverter' => 
'/helpers/LoggerPatternConverter.php',
-               'LoggerBasicPatternConverter' => 
'/helpers/LoggerPatternConverter.php',
-               'LoggerLiteralPatternConverter' => 
'/helpers/LoggerPatternConverter.php',
-               'LoggerDatePatternConverter' => 
'/helpers/LoggerPatternConverter.php',
-               'LoggerMDCPatternConverter' => 
'/helpers/LoggerPatternConverter.php',
-               'LoggerLocationPatternConverter' => 
'/helpers/LoggerPatternConverter.php',
-               'LoggerNamedPatternConverter' => 
'/helpers/LoggerPatternConverter.php',
-               'LoggerClassNamePatternConverter' => 
'/helpers/LoggerPatternConverter.php',
-               'LoggerCategoryPatternConverter' => 
'/helpers/LoggerPatternConverter.php',
+               'LoggerBasicPatternConverter' => 
'/helpers/LoggerBasicPatternConverter.php',
+               'LoggerCategoryPatternConverter' => 
'/helpers/LoggerCategoryPatternConverter.php',
+               'LoggerClassNamePatternConverter' => 
'/helpers/LoggerClassNamePatternConverter.php',
+               'LoggerDatePatternConverter' => 
'/helpers/LoggerDatePatternConverter.php',
+               'LoggerLiteralPatternConverter' => 
'/helpers/LoggerLiteralPatternConverter.php',
+               'LoggerLocationPatternConverter' => 
'/helpers/LoggerLocationPatternConverter.php',
+               'LoggerMDCPatternConverter' => 
'/helpers/LoggerMDCPatternConverter.php',
+               'LoggerNamedPatternConverter' => 
'/helpers/LoggerNamedPatternConverter.php',
+               'LoggerBasicPatternConverter' => 
'/helpers/LoggerBasicPatternConverter.php',
+               'LoggerLiteralPatternConverter' => 
'/helpers/LoggerLiteralPatternConverter.php',
+               'LoggerDatePatternConverter' => 
'/helpers/LoggerDatePatternConverter.php',
+               'LoggerMDCPatternConverter' => 
'/helpers/LoggerMDCPatternConverter.php',
+               'LoggerLocationPatternConverter' => 
'/helpers/LoggerLocationPatternConverter.php',
+               'LoggerNamedPatternConverter' => 
'/helpers/LoggerNamedPatternConverter.php',
+               'LoggerClassNamePatternConverter' => 
'/helpers/LoggerClassNamePatternConverter.php',
+               'LoggerCategoryPatternConverter' => 
'/helpers/LoggerCategoryPatternConverter.php',
                'LoggerPatternParser' => '/helpers/LoggerPatternParser.php',
                'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php',
                'LoggerLayoutSimple' => '/layouts/LoggerLayoutSimple.php',

Added: 
incubator/log4php/trunk/src/main/php/helpers/LoggerBasicPatternConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerBasicPatternConverter.php?rev=778046&view=auto
==============================================================================
--- 
incubator/log4php/trunk/src/main/php/helpers/LoggerBasicPatternConverter.php 
(added)
+++ 
incubator/log4php/trunk/src/main/php/helpers/LoggerBasicPatternConverter.php 
Sat May 23 22:21:28 2009
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *        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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ * @subpackage helpers
+ */
+
+/**
+ * @package log4php
+ * @subpackage helpers
+ */
+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 '';
+               }
+       }
+}

Added: 
incubator/log4php/trunk/src/main/php/helpers/LoggerCategoryPatternConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerCategoryPatternConverter.php?rev=778046&view=auto
==============================================================================
--- 
incubator/log4php/trunk/src/main/php/helpers/LoggerCategoryPatternConverter.php 
(added)
+++ 
incubator/log4php/trunk/src/main/php/helpers/LoggerCategoryPatternConverter.php 
Sat May 23 22:21:28 2009
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *        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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ * @subpackage helpers
+ */
+
+/**
+ * @package log4php
+ * @subpackage helpers
+ */
+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();
+       }
+}

Added: 
incubator/log4php/trunk/src/main/php/helpers/LoggerClassNamePatternConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerClassNamePatternConverter.php?rev=778046&view=auto
==============================================================================
--- 
incubator/log4php/trunk/src/main/php/helpers/LoggerClassNamePatternConverter.php
 (added)
+++ 
incubator/log4php/trunk/src/main/php/helpers/LoggerClassNamePatternConverter.php
 Sat May 23 22:21:28 2009
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *        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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ * @subpackage helpers
+ */
+
+/**
+ * @package log4php
+ * @subpackage helpers
+ */
+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;
+       }
+}
+

Added: 
incubator/log4php/trunk/src/main/php/helpers/LoggerDatePatternConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerDatePatternConverter.php?rev=778046&view=auto
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerDatePatternConverter.php 
(added)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerDatePatternConverter.php 
Sat May 23 22:21:28 2009
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *        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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ * @subpackage helpers
+ */
+
+/**
+ * @package log4php
+ * @subpackage helpers
+ */
+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());
+       }
+}

Added: 
incubator/log4php/trunk/src/main/php/helpers/LoggerLiteralPatternConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerLiteralPatternConverter.php?rev=778046&view=auto
==============================================================================
--- 
incubator/log4php/trunk/src/main/php/helpers/LoggerLiteralPatternConverter.php 
(added)
+++ 
incubator/log4php/trunk/src/main/php/helpers/LoggerLiteralPatternConverter.php 
Sat May 23 22:21:28 2009
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *        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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ * @subpackage helpers
+ */
+
+/**
+ * @package log4php
+ * @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;
+       }
+}
+

Added: 
incubator/log4php/trunk/src/main/php/helpers/LoggerLocationPatternConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerLocationPatternConverter.php?rev=778046&view=auto
==============================================================================
--- 
incubator/log4php/trunk/src/main/php/helpers/LoggerLocationPatternConverter.php 
(added)
+++ 
incubator/log4php/trunk/src/main/php/helpers/LoggerLocationPatternConverter.php 
Sat May 23 22:21:28 2009
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *        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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ * @subpackage helpers
+ */
+
+/**
+ * @package log4php
+ * @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 '';
+               }
+       }
+}
+

Added: 
incubator/log4php/trunk/src/main/php/helpers/LoggerMDCPatternConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerMDCPatternConverter.php?rev=778046&view=auto
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerMDCPatternConverter.php 
(added)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerMDCPatternConverter.php 
Sat May 23 22:21:28 2009
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *        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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ * @subpackage helpers
+ */
+
+/**
+ * @package log4php
+ * @subpackage helpers
+ */
+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);
+       }
+}

Added: 
incubator/log4php/trunk/src/main/php/helpers/LoggerNamedPatternConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerNamedPatternConverter.php?rev=778046&view=auto
==============================================================================
--- 
incubator/log4php/trunk/src/main/php/helpers/LoggerNamedPatternConverter.php 
(added)
+++ 
incubator/log4php/trunk/src/main/php/helpers/LoggerNamedPatternConverter.php 
Sat May 23 22:21:28 2009
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *        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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ * @subpackage helpers
+ */
+
+/**
+ * @package log4php
+ * @subpackage helpers
+ * @abstract
+ */
+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);
+               }
+       }
+}

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=778046&r1=778045&r2=778046&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerPatternConverter.php 
(original)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerPatternConverter.php Sat 
May 23 22:21:28 2009
@@ -32,6 +32,7 @@
        "                ", // 16 spaces
        "                                " ); // 32 spaces
 
+
 /**
  * LoggerPatternConverter is an abstract class that provides the formatting 
  * functionality that derived classes need.
@@ -134,312 +135,3 @@
                // $sbuf = str_pad($sbuf, $length);
        }
 }
-
-// ---------------------------------------------------------------------
-//                                             PatternConverters
-// ---------------------------------------------------------------------
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-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 '';
-               }
-       }
-}
-
-/**
- * @package log4php
- * @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;
-       }
-}
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-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());
-       }
-}
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-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);
-       }
-}
-
-/**
- * @package log4php
- * @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 '';
-               }
-       }
-}
-
-/**
- * @package log4php
- * @subpackage helpers
- * @abstract
- */
-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);
-               }
-       }
-}
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-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;
-       }
-}
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-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();
-       }
-}


Reply via email to