[Vtigercrm-commits] [vtiger-commits] r5730 - /vtigercrm/trunk/log4php/
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu May 4 00:07:31 EDT 2006
Author: saraj
Date: Wed May 3 22:07:13 2006
New Revision: 5730
Log:
log4php latest version has been updated
Modified:
vtigercrm/trunk/log4php/Logger.php
vtigercrm/trunk/log4php/LoggerAppender.php
vtigercrm/trunk/log4php/LoggerAppenderSkeleton.php
vtigercrm/trunk/log4php/LoggerBasicConfigurator.php
vtigercrm/trunk/log4php/LoggerCategory.php
vtigercrm/trunk/log4php/LoggerDefaultCategoryFactory.php
vtigercrm/trunk/log4php/LoggerHierarchy.php
vtigercrm/trunk/log4php/LoggerLayout.php
vtigercrm/trunk/log4php/LoggerLevel.php
vtigercrm/trunk/log4php/LoggerLog.php
vtigercrm/trunk/log4php/LoggerMDC.php
vtigercrm/trunk/log4php/LoggerManager.php
vtigercrm/trunk/log4php/LoggerNDC.php
vtigercrm/trunk/log4php/LoggerPropertyConfigurator.php
vtigercrm/trunk/log4php/LoggerRoot.php
Modified: vtigercrm/trunk/log4php/Logger.php
==============================================================================
--- vtigercrm/trunk/log4php/Logger.php (original)
+++ vtigercrm/trunk/log4php/Logger.php Wed May 3 22:07:13 2006
@@ -1,67 +1,67 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-require_once(LOG4PHP_DIR . '/LoggerCategory.php');
-require_once(LOG4PHP_DIR . '/LoggerManager.php');
-
-/**
- * Main class for logging operations
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- */
-class Logger extends LoggerCategory {
-
- /**
- * Constructor
- * @param string $name logger name
- */
- function Logger($name)
- {
- $this->LoggerCategory($name);
- }
-
- /**
- * Get a Logger by name (Delegate to {@link LoggerManager})
- * @param string $name logger name
- * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
- * @return Logger
- * @static
- */
- function &getLogger($name, $factory = null)
- {
- return LoggerManager::getLogger($name, $factory);
- }
-
- /**
- * get the Root Logger (Delegate to {@link LoggerManager})
- * @return LoggerRoot
- * @static
- */
- function &getRootLogger()
- {
- return LoggerManager::getRootLogger();
- }
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+require_once(LOG4PHP_DIR . '/LoggerCategory.php');
+require_once(LOG4PHP_DIR . '/LoggerManager.php');
+
+/**
+ * Main class for logging operations
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.9 $
+ * @package log4php
+ */
+class Logger extends LoggerCategory {
+
+ /**
+ * Constructor
+ * @param string $name logger name
+ */
+ function Logger($name)
+ {
+ $this->LoggerCategory($name);
+ }
+
+ /**
+ * Get a Logger by name (Delegate to {@link LoggerManager})
+ * @param string $name logger name
+ * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
+ * @return Logger
+ * @static
+ */
+ function &getLogger($name, $factory = null)
+ {
+ return LoggerManager::getLogger($name, $factory);
+ }
+
+ /**
+ * get the Root Logger (Delegate to {@link LoggerManager})
+ * @return LoggerRoot
+ * @static
+ */
+ function &getRootLogger()
+ {
+ return LoggerManager::getRootLogger();
+ }
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerAppender.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerAppender.php (original)
+++ vtigercrm/trunk/log4php/LoggerAppender.php Wed May 3 22:07:13 2006
@@ -1,218 +1,218 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- * Abstract class that defines output logs strategies.
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @abstract
- */
-class LoggerAppender {
-
- /**
- * Factory
- *
- * @param string $name appender name
- * @param string $class create an instance of this appender class
- * @return LoggerAppender
- */
- function factory($name, $class)
- {
- $class = basename($class);
- if (!empty($class)) {
- if (!class_exists($class))
- @include_once(LOG4PHP_DIR . "/appenders/{$class}.php");
- if (class_exists($class))
- return new $class($name);
- }
- return null;
- }
-
- /**
- * Singleton
- *
- * @param string $name appender name
- * @param string $class create or get a reference instance of this class
- * @return LoggerAppender
- */
- function &singleton($name, $class = '')
- {
- static $instances;
-
- if (!empty($name)) {
- if (!isset($instances[$name])) {
- if (!empty($class)) {
- $appender = LoggerAppender::factory($name, $class);
- if ($appender !== null) {
- $instances[$name] = $appender;
- return $instances[$name];
- }
- }
- return null;
- }
- return $instances[$name];
- }
- return null;
- }
-
- /* --------------------------------------------------------------------------*/
- /* --------------------------------------------------------------------------*/
- /* --------------------------------------------------------------------------*/
-
- /**
- * Add a filter to the end of the filter list.
- *
- * @param LoggerFilter $newFilter add a new LoggerFilter
- * @abstract
- */
- function addFilter($newFilter)
- {
- // override
- }
-
- /**
- * Clear the list of filters by removing all the filters in it.
- * @abstract
- */
- function clearFilters()
- {
- // override
- }
-
- /**
- * Return the first filter in the filter chain for this Appender.
- * The return value may be <i>null</i> if no is filter is set.
- * @return Filter
- */
- function &getFilter()
- {
- // override
- }
-
- /**
- * Release any resources allocated.
- * Subclasses of {@link LoggerAppender} should implement
- * this method to perform proper closing procedures.
- * @abstract
- */
- function close()
- {
- //override me
- }
-
- /**
- * This method performs threshold checks and invokes filters before
- * delegating actual logging to the subclasses specific <i>append()</i> method.
- * @param LoggerLoggingEvent $event
- * @abstract
- */
- function doAppend($event)
- {
- //override me
- }
-
- /**
- * Get the name of this appender.
- * @return string
- */
- function getName()
- {
- //override me
- }
-
- /**
- * Do not use this method.
- *
- * @param object $errorHandler
- */
- function setErrorHandler($errorHandler)
- {
- // override me
- }
-
- /**
- * Do not use this method.
- * @return object Returns the ErrorHandler for this appender.
- */
- function &getErrorHandler()
- {
- return $this->errorHandler;
- }
-
- /**
- * Set the Layout for this appender.
- *
- * @param LoggerLayout $layout
- */
- function setLayout($layout)
- {
- // override me
- }
-
- /**
- * Returns this appender layout.
- * @return LoggerLayout
- */
- function &getLayout()
- {
- // override me
- }
-
- /**
- * Set the name of this appender.
- *
- * The name is used by other components to identify this appender.
- *
- * @param string $name
- */
- function setName($name)
- {
- // override me
- }
-
- /**
- * Configurators call this method to determine if the appender
- * requires a layout.
- *
- * <p>If this method returns <i>true</i>, meaning that layout is required,
- * then the configurator will configure a layout using the configuration
- * information at its disposal. If this method returns <i>false</i>,
- * meaning that a layout is not required, then layout configuration will be
- * skipped even if there is available layout configuration
- * information at the disposal of the configurator.</p>
- *
- * <p>In the rather exceptional case, where the appender
- * implementation admits a layout but can also work without it, then
- * the appender should return <i>true</i>.</p>
- *
- * @return boolean
- */
- function requiresLayout()
- {
- // override me
- }
-
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ * Abstract class that defines output logs strategies.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.14 $
+ * @package log4php
+ * @abstract
+ */
+class LoggerAppender {
+
+ /**
+ * Factory
+ *
+ * @param string $name appender name
+ * @param string $class create an instance of this appender class
+ * @return LoggerAppender
+ */
+ function factory($name, $class)
+ {
+ $class = basename($class);
+ if (!empty($class)) {
+ if (!class_exists($class))
+ @include_once(LOG4PHP_DIR . "/appenders/{$class}.php");
+ if (class_exists($class))
+ return new $class($name);
+ }
+ return null;
+ }
+
+ /**
+ * Singleton
+ *
+ * @param string $name appender name
+ * @param string $class create or get a reference instance of this class
+ * @return LoggerAppender
+ */
+ function &singleton($name, $class = '')
+ {
+ static $instances;
+
+ if (!empty($name)) {
+ if (!isset($instances[$name])) {
+ if (!empty($class)) {
+ $appender = LoggerAppender::factory($name, $class);
+ if ($appender !== null) {
+ $instances[$name] = $appender;
+ return $instances[$name];
+ }
+ }
+ return null;
+ }
+ return $instances[$name];
+ }
+ return null;
+ }
+
+ /* --------------------------------------------------------------------------*/
+ /* --------------------------------------------------------------------------*/
+ /* --------------------------------------------------------------------------*/
+
+ /**
+ * Add a filter to the end of the filter list.
+ *
+ * @param LoggerFilter $newFilter add a new LoggerFilter
+ * @abstract
+ */
+ function addFilter($newFilter)
+ {
+ // override
+ }
+
+ /**
+ * Clear the list of filters by removing all the filters in it.
+ * @abstract
+ */
+ function clearFilters()
+ {
+ // override
+ }
+
+ /**
+ * Return the first filter in the filter chain for this Appender.
+ * The return value may be <i>null</i> if no is filter is set.
+ * @return Filter
+ */
+ function &getFilter()
+ {
+ // override
+ }
+
+ /**
+ * Release any resources allocated.
+ * Subclasses of {@link LoggerAppender} should implement
+ * this method to perform proper closing procedures.
+ * @abstract
+ */
+ function close()
+ {
+ //override me
+ }
+
+ /**
+ * This method performs threshold checks and invokes filters before
+ * delegating actual logging to the subclasses specific <i>append()</i> method.
+ * @param LoggerLoggingEvent $event
+ * @abstract
+ */
+ function doAppend($event)
+ {
+ //override me
+ }
+
+ /**
+ * Get the name of this appender.
+ * @return string
+ */
+ function getName()
+ {
+ //override me
+ }
+
+ /**
+ * Do not use this method.
+ *
+ * @param object $errorHandler
+ */
+ function setErrorHandler($errorHandler)
+ {
+ // override me
+ }
+
+ /**
+ * Do not use this method.
+ * @return object Returns the ErrorHandler for this appender.
+ */
+ function &getErrorHandler()
+ {
+ return $this->errorHandler;
+ }
+
+ /**
+ * Set the Layout for this appender.
+ *
+ * @param LoggerLayout $layout
+ */
+ function setLayout($layout)
+ {
+ // override me
+ }
+
+ /**
+ * Returns this appender layout.
+ * @return LoggerLayout
+ */
+ function &getLayout()
+ {
+ // override me
+ }
+
+ /**
+ * Set the name of this appender.
+ *
+ * The name is used by other components to identify this appender.
+ *
+ * @param string $name
+ */
+ function setName($name)
+ {
+ // override me
+ }
+
+ /**
+ * Configurators call this method to determine if the appender
+ * requires a layout.
+ *
+ * <p>If this method returns <i>true</i>, meaning that layout is required,
+ * then the configurator will configure a layout using the configuration
+ * information at its disposal. If this method returns <i>false</i>,
+ * meaning that a layout is not required, then layout configuration will be
+ * skipped even if there is available layout configuration
+ * information at the disposal of the configurator.</p>
+ *
+ * <p>In the rather exceptional case, where the appender
+ * implementation admits a layout but can also work without it, then
+ * the appender should return <i>true</i>.</p>
+ *
+ * @return boolean
+ */
+ function requiresLayout()
+ {
+ // override me
+ }
+
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerAppenderSkeleton.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerAppenderSkeleton.php (original)
+++ vtigercrm/trunk/log4php/LoggerAppenderSkeleton.php Wed May 3 22:07:13 2006
@@ -1,355 +1,355 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- */
-require_once(LOG4PHP_DIR . '/LoggerAppender.php');
-require_once(LOG4PHP_DIR . '/LoggerLog.php');
-require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php');
-
-/**
- * Abstract superclass of the other appenders in the package.
- *
- * This class provides the code for common functionality, such as
- * support for threshold filtering and support for general filters.
- *
- * @author VxR <vxr at vxr.it>
- * @author Sergio Strampelli <sergio at ascia.net>
- * @version $Revision: 1.1 $
- * @package log4php
- * @abstract
- */
-class LoggerAppenderSkeleton extends LoggerAppender {
-
- /**
- * @var boolean closed appender flag
- */
- var $closed;
-
- /**
- * @var object unused
- */
- var $errorHandler;
-
- /**
- * The first filter in the filter chain
- * @var LoggerFilter
- */
- var $headFilter = null;
-
- /**
- * LoggerLayout for this appender. It can be null if appender has its own layout
- * @var LoggerLayout
- */
- var $layout = null;
-
- /**
- * @var string Appender name
- */
- var $name;
-
- /**
- * The last filter in the filter chain
- * @var LoggerFilter
- */
- var $tailFilter = null;
-
- /**
- * @var LoggerLevel There is no level threshold filtering by default.
- */
- var $threshold = null;
-
- /**
- * @var boolean needs a layout formatting ?
- */
- var $requiresLayout = false;
-
-/* --------------------------------------------------------------------------*/
-/* --------------------------------------------------------------------------*/
-/* --------------------------------------------------------------------------*/
-
- /**
- * Constructor
- *
- * @param string $name appender name
- */
- function LoggerAppenderSkeleton($name)
- {
- $this->name = $name;
- $this->clearFilters();
- }
-
- /**
- * @param LoggerFilter $newFilter add a new LoggerFilter
- * @see LoggerAppender::addFilter()
- */
- function addFilter($newFilter)
- {
- if($this->headFilter === null) {
- $this->headFilter = $newFilter;
- $this->tailFilter =& $this->headFilter;
- } else {
- $this->tailFilter->next = $newFilter;
- $this->tailFilter =& $this->tailFilter->next;
- }
- }
-
- /**
- * Derived appenders should override this method if option structure
- * requires it.
- */
- function activateOptions()
- {
-
- }
-
- /**
- * Subclasses of {@link LoggerAppenderSkeleton} should implement
- * this method to perform actual logging.
- *
- * @param LoggerLoggingEvent $event
- * @see doAppend()
- * @abstract
- */
- function append($event)
- {
- // override me
- }
-
- /**
- * @see LoggerAppender::clearFilters()
- */
- function clearFilters()
- {
- unset($this->headFilter);
- unset($this->tailFilter);
- $this->headFilter = null;
- $this->tailFilter = null;
- }
-
- /**
- * @see LoggerAppender::close()
- */
- function close()
- {
- //override me
- }
-
- /**
- * Finalize this appender by calling the derived class' <i>close()</i> method.
- */
- function finalize()
- {
- // An appender might be closed then garbage collected. There is no
- // point in closing twice.
- if ($this->closed) return;
-
- LoggerLog::debug("LoggerAppenderSkeleton::finalize():name=[{$this->name}].");
-
- $this->close();
- }
-
- /**
- * Do not use this method.
- * @see LoggerAppender::getErrorHandler()
- * @return object
- */
- function &getErrorHandler()
- {
- return $this->errorHandler;
- }
-
- /**
- * @see LoggerAppender::getFilter()
- * @return Filter
- */
- function &getFilter()
- {
- return $this->headFilter;
- }
-
- /**
- * Return the first filter in the filter chain for this Appender.
- * The return value may be <i>null</i> if no is filter is set.
- * @return Filter
- */
- function &getFirstFilter()
- {
- return $this->headFilter;
- }
-
- /**
- * @see LoggerAppender::getLayout()
- * @return LoggerLayout
- */
- function &getLayout()
- {
- return $this->layout;
- }
-
- /**
- * @see LoggerAppender::getName()
- * @return string
- */
- function getName()
- {
- return $this->name;
- }
-
- /**
- * Returns this appenders threshold level.
- * See the {@link setThreshold()} method for the meaning of this option.
- * @return LoggerLevel
- */
- function &getThreshold()
- {
- return $this->threshold;
- }
-
- /**
- * Check whether the message level is below the appender's threshold.
- *
- *
- * If there is no threshold set, then the return value is always <i>true</i>.
- * @param LoggerLevel $priority
- * @return boolean true if priority is greater or equal than threshold
- */
- function isAsSevereAsThreshold($priority)
- {
- if ($this->threshold === null)
- return true;
-
- return $priority->isGreaterOrEqual($this->getThreshold());
- }
-
- /**
- * @see LoggerAppender::doAppend()
- * @param LoggerLoggingEvent $event
- */
- function doAppend($event)
- {
- LoggerLog::debug("LoggerAppenderSkeleton::doAppend()");
-
- if ($this->closed) {
- LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}].");
- return;
- }
- if(!$this->isAsSevereAsThreshold($event->getLevel())) {
- LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold.");
- return;
- }
-
- $f = $this->getFirstFilter();
-
- while($f !== null) {
- switch ($f->decide($event)) {
- case LOG4PHP_LOGGER_FILTER_DENY: return;
- case LOG4PHP_LOGGER_FILTER_ACCEPT: return $this->append($event);
- case LOG4PHP_LOGGER_FILTER_NEUTRAL: $f = $f->next;
- }
- }
- $this->append($event);
- }
-
-
- /**
- * @see LoggerAppender::requiresLayout()
- * @return boolean
- */
- function requiresLayout()
- {
- return $this->requiresLayout;
- }
-
- /**
- * @see LoggerAppender::setErrorHandler()
- * @param object
- */
- function setErrorHandler($errorHandler)
- {
- if($errorHandler == null) {
- // We do not throw exception here since the cause is probably a
- // bad config file.
- LoggerLog::warn("You have tried to set a null error-handler.");
- } else {
- $this->errorHandler = $errorHandler;
- }
- }
-
- /**
- * @see LoggerAppender::setLayout()
- * @param LoggerLayout $layout
- */
- function setLayout($layout)
- {
- if ($this->requiresLayout())
- $this->layout = $layout;
- }
-
- /**
- * @see LoggerAppender::setName()
- * @param string $name
- */
- function setName($name)
- {
- $this->name = $name;
- }
-
- /**
- * Set the threshold level of this appender.
- *
- * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
- * @see LoggerOptionConverter::toLevel()
- */
- function setThreshold($threshold)
- {
- if (is_string($threshold)) {
- $this->threshold = LoggerOptionConverter::toLevel($threshold, null);
- }elseif (is_a($threshold, 'loggerlevel')) {
- $this->threshold = $threshold;
- }
- }
-
- /**
- * Perform actions before object serialization.
- *
- * Call {@link finalize()} to properly close the appender.
- */
- function __sleep()
- {
- $this->finalize();
- return array_keys(get_object_vars($this));
- }
-
- /**
- * Perform actions after object deserialization.
- *
- * Call {@link activateOptions()} to properly setup the appender.
- */
- function __wakeup()
- {
- $this->activateOptions();
- }
-
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ */
+require_once(LOG4PHP_DIR . '/LoggerAppender.php');
+require_once(LOG4PHP_DIR . '/LoggerLog.php');
+require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php');
+
+/**
+ * Abstract superclass of the other appenders in the package.
+ *
+ * This class provides the code for common functionality, such as
+ * support for threshold filtering and support for general filters.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @author Sergio Strampelli <sergio at ascia.net>
+ * @version $Revision: 1.15 $
+ * @package log4php
+ * @abstract
+ */
+class LoggerAppenderSkeleton extends LoggerAppender {
+
+ /**
+ * @var boolean closed appender flag
+ */
+ var $closed;
+
+ /**
+ * @var object unused
+ */
+ var $errorHandler;
+
+ /**
+ * The first filter in the filter chain
+ * @var LoggerFilter
+ */
+ var $headFilter = null;
+
+ /**
+ * LoggerLayout for this appender. It can be null if appender has its own layout
+ * @var LoggerLayout
+ */
+ var $layout = null;
+
+ /**
+ * @var string Appender name
+ */
+ var $name;
+
+ /**
+ * The last filter in the filter chain
+ * @var LoggerFilter
+ */
+ var $tailFilter = null;
+
+ /**
+ * @var LoggerLevel There is no level threshold filtering by default.
+ */
+ var $threshold = null;
+
+ /**
+ * @var boolean needs a layout formatting ?
+ */
+ var $requiresLayout = false;
+
+/* --------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------------*/
+
+ /**
+ * Constructor
+ *
+ * @param string $name appender name
+ */
+ function LoggerAppenderSkeleton($name)
+ {
+ $this->name = $name;
+ $this->clearFilters();
+ }
+
+ /**
+ * @param LoggerFilter $newFilter add a new LoggerFilter
+ * @see LoggerAppender::addFilter()
+ */
+ function addFilter($newFilter)
+ {
+ if($this->headFilter === null) {
+ $this->headFilter = $newFilter;
+ $this->tailFilter =& $this->headFilter;
+ } else {
+ $this->tailFilter->next = $newFilter;
+ $this->tailFilter =& $this->tailFilter->next;
+ }
+ }
+
+ /**
+ * Derived appenders should override this method if option structure
+ * requires it.
+ */
+ function activateOptions()
+ {
+
+ }
+
+ /**
+ * Subclasses of {@link LoggerAppenderSkeleton} should implement
+ * this method to perform actual logging.
+ *
+ * @param LoggerLoggingEvent $event
+ * @see doAppend()
+ * @abstract
+ */
+ function append($event)
+ {
+ // override me
+ }
+
+ /**
+ * @see LoggerAppender::clearFilters()
+ */
+ function clearFilters()
+ {
+ unset($this->headFilter);
+ unset($this->tailFilter);
+ $this->headFilter = null;
+ $this->tailFilter = null;
+ }
+
+ /**
+ * @see LoggerAppender::close()
+ */
+ function close()
+ {
+ //override me
+ }
+
+ /**
+ * Finalize this appender by calling the derived class' <i>close()</i> method.
+ */
+ function finalize()
+ {
+ // An appender might be closed then garbage collected. There is no
+ // point in closing twice.
+ if ($this->closed) return;
+
+ LoggerLog::debug("LoggerAppenderSkeleton::finalize():name=[{$this->name}].");
+
+ $this->close();
+ }
+
+ /**
+ * Do not use this method.
+ * @see LoggerAppender::getErrorHandler()
+ * @return object
+ */
+ function &getErrorHandler()
+ {
+ return $this->errorHandler;
+ }
+
+ /**
+ * @see LoggerAppender::getFilter()
+ * @return Filter
+ */
+ function &getFilter()
+ {
+ return $this->headFilter;
+ }
+
+ /**
+ * Return the first filter in the filter chain for this Appender.
+ * The return value may be <i>null</i> if no is filter is set.
+ * @return Filter
+ */
+ function &getFirstFilter()
+ {
+ return $this->headFilter;
+ }
+
+ /**
+ * @see LoggerAppender::getLayout()
+ * @return LoggerLayout
+ */
+ function &getLayout()
+ {
+ return $this->layout;
+ }
+
+ /**
+ * @see LoggerAppender::getName()
+ * @return string
+ */
+ function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Returns this appenders threshold level.
+ * See the {@link setThreshold()} method for the meaning of this option.
+ * @return LoggerLevel
+ */
+ function &getThreshold()
+ {
+ return $this->threshold;
+ }
+
+ /**
+ * Check whether the message level is below the appender's threshold.
+ *
+ *
+ * If there is no threshold set, then the return value is always <i>true</i>.
+ * @param LoggerLevel $priority
+ * @return boolean true if priority is greater or equal than threshold
+ */
+ function isAsSevereAsThreshold($priority)
+ {
+ if ($this->threshold === null)
+ return true;
+
+ return $priority->isGreaterOrEqual($this->getThreshold());
+ }
+
+ /**
+ * @see LoggerAppender::doAppend()
+ * @param LoggerLoggingEvent $event
+ */
+ function doAppend($event)
+ {
+ LoggerLog::debug("LoggerAppenderSkeleton::doAppend()");
+
+ if ($this->closed) {
+ LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}].");
+ return;
+ }
+ if(!$this->isAsSevereAsThreshold($event->getLevel())) {
+ LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold.");
+ return;
+ }
+
+ $f = $this->getFirstFilter();
+
+ while($f !== null) {
+ switch ($f->decide($event)) {
+ case LOG4PHP_LOGGER_FILTER_DENY: return;
+ case LOG4PHP_LOGGER_FILTER_ACCEPT: return $this->append($event);
+ case LOG4PHP_LOGGER_FILTER_NEUTRAL: $f = $f->next;
+ }
+ }
+ $this->append($event);
+ }
+
+
+ /**
+ * @see LoggerAppender::requiresLayout()
+ * @return boolean
+ */
+ function requiresLayout()
+ {
+ return $this->requiresLayout;
+ }
+
+ /**
+ * @see LoggerAppender::setErrorHandler()
+ * @param object
+ */
+ function setErrorHandler($errorHandler)
+ {
+ if($errorHandler == null) {
+ // We do not throw exception here since the cause is probably a
+ // bad config file.
+ LoggerLog::warn("You have tried to set a null error-handler.");
+ } else {
+ $this->errorHandler = $errorHandler;
+ }
+ }
+
+ /**
+ * @see LoggerAppender::setLayout()
+ * @param LoggerLayout $layout
+ */
+ function setLayout($layout)
+ {
+ if ($this->requiresLayout())
+ $this->layout = $layout;
+ }
+
+ /**
+ * @see LoggerAppender::setName()
+ * @param string $name
+ */
+ function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Set the threshold level of this appender.
+ *
+ * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
+ * @see LoggerOptionConverter::toLevel()
+ */
+ function setThreshold($threshold)
+ {
+ if (is_string($threshold)) {
+ $this->threshold = LoggerOptionConverter::toLevel($threshold, null);
+ }elseif (is_a($threshold, 'loggerlevel')) {
+ $this->threshold = $threshold;
+ }
+ }
+
+ /**
+ * Perform actions before object serialization.
+ *
+ * Call {@link finalize()} to properly close the appender.
+ */
+ function __sleep()
+ {
+ $this->finalize();
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Perform actions after object deserialization.
+ *
+ * Call {@link activateOptions()} to properly setup the appender.
+ */
+ function __wakeup()
+ {
+ $this->activateOptions();
+ }
+
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerBasicConfigurator.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerBasicConfigurator.php (original)
+++ vtigercrm/trunk/log4php/LoggerBasicConfigurator.php Wed May 3 22:07:13 2006
@@ -1,80 +1,80 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-require_once(LOG4PHP_DIR . '/spi/LoggerConfigurator.php');
-require_once(LOG4PHP_DIR . '/LoggerLayout.php');
-require_once(LOG4PHP_DIR . '/LoggerAppender.php');
-require_once(LOG4PHP_DIR . '/LoggerManager.php');
-
-/**
- * Use this class to quickly configure the package.
- *
- * <p>For file based configuration see {@link LoggerPropertyConfigurator}.
- * <p>For XML based configuration see {@link LoggerDOMConfigurator}.
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @since 0.5
- */
-class LoggerBasicConfigurator extends LoggerConfigurator {
-
- function LoggerBasicConfigurator()
- {
- return;
- }
-
- /**
- * Add a {@link LoggerAppenderConsole} that uses
- * the {@link LoggerLayoutTTCC} to the root category.
- *
- * @param string $url not used here
- * @static
- */
- function configure($url = null)
- {
- $root =& LoggerManager::getRootLogger();
-
- $appender =& LoggerAppender::singleton('A1', 'LoggerAppenderConsole');
- $layout = LoggerLayout::factory('LoggerLayoutTTCC');
- $appender->setLayout($layout);
-
- $root->addAppender($appender);
- }
-
- /**
- * Reset the default hierarchy to its defaut.
- * It is equivalent to
- * <code>
- * LoggerManager::resetConfiguration();
- * </code>
- *
- * @see LoggerHierarchy::resetConfiguration()
- * @static
- */
- function resetConfiguration()
- {
- LoggerManager::resetConfiguration();
- }
-}
-?>
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+require_once(LOG4PHP_DIR . '/spi/LoggerConfigurator.php');
+require_once(LOG4PHP_DIR . '/LoggerLayout.php');
+require_once(LOG4PHP_DIR . '/LoggerAppender.php');
+require_once(LOG4PHP_DIR . '/LoggerManager.php');
+
+/**
+ * Use this class to quickly configure the package.
+ *
+ * <p>For file based configuration see {@link LoggerPropertyConfigurator}.
+ * <p>For XML based configuration see {@link LoggerDOMConfigurator}.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.2 $
+ * @package log4php
+ * @since 0.5
+ */
+class LoggerBasicConfigurator extends LoggerConfigurator {
+
+ function LoggerBasicConfigurator()
+ {
+ return;
+ }
+
+ /**
+ * Add a {@link LoggerAppenderConsole} that uses
+ * the {@link LoggerLayoutTTCC} to the root category.
+ *
+ * @param string $url not used here
+ * @static
+ */
+ function configure($url = null)
+ {
+ $root =& LoggerManager::getRootLogger();
+
+ $appender =& LoggerAppender::singleton('A1', 'LoggerAppenderConsole');
+ $layout = LoggerLayout::factory('LoggerLayoutTTCC');
+ $appender->setLayout($layout);
+
+ $root->addAppender($appender));
+ }
+
+ /**
+ * Reset the default hierarchy to its defaut.
+ * It is equivalent to
+ * <code>
+ * LoggerManager::resetConfiguration();
+ * </code>
+ *
+ * @see LoggerHierarchy::resetConfiguration()
+ * @static
+ */
+ function resetConfiguration()
+ {
+ LoggerManager::resetConfiguration();
+ }
+}
+?>
Modified: vtigercrm/trunk/log4php/LoggerCategory.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerCategory.php (original)
+++ vtigercrm/trunk/log4php/LoggerCategory.php Wed May 3 22:07:13 2006
@@ -1,572 +1,572 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- */
-require_once(LOG4PHP_DIR . '/LoggerLevel.php');
-require_once(LOG4PHP_DIR . '/spi/LoggerLoggingEvent.php');
-
-/**
- * This class has been deprecated and replaced by the Logger subclass.
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @see Logger
- */
-class LoggerCategory {
-
- /**
- * Additivity is set to true by default, that is children inherit the
- * appenders of their ancestors by default.
- * @var boolean
- */
- var $additive = true;
-
- /**
- * @var string fully qualified class name
- */
- var $fqcn = 'LoggerCategory';
-
- /**
- * @var LoggerLevel The assigned level of this category.
- */
- var $level = null;
-
- /**
- * @var string name of this category.
- */
- var $name = '';
-
- /**
- * @var Logger The parent of this category.
- */
- var $parent = null;
-
- /**
- * @var LoggerHierarchy the object repository
- */
- var $repository = null;
-
- /**
- * @var array collection of appenders
- * @see LoggerAppender
- */
- var $aai = array();
-
-/* --------------------------------------------------------------------------*/
-/* --------------------------------------------------------------------------*/
-/* --------------------------------------------------------------------------*/
-
- /**
- * Constructor.
- *
- * @param string $name Category name
- */
- function LoggerCategory($name)
- {
- $this->name = $name;
- }
-
- /**
- * Add a new Appender to the list of appenders of this Category instance.
- *
- * @param LoggerAppender $newAppender
- */
- function addAppender(&$newAppender)
- {
- $appenderName = $newAppender->getName();
- $this->aai[$appenderName] =& $newAppender;
- }
-
- /**
- * If assertion parameter is false, then logs msg as an error statement.
- *
- * @param bool $assertion
- * @param string $msg message to log
- */
- function assertLog($assertion = true, $msg = '')
- {
- if ($assertion == false) {
- $this->error($msg);
- }
- }
-
- /**
- * Call the appenders in the hierarchy starting at this.
- *
- * @param LoggerLoggingEvent $event
- */
- function callAppenders($event)
- {
- if (sizeof($this->aai) > 0) {
- foreach (array_keys($this->aai) as $appenderName) {
- $this->aai[$appenderName]->doAppend($event);
- }
- }
- if ($this->parent != null and $this->getAdditivity()) {
- $this->parent->callAppenders($event);
- }
- }
-
- /**
- * Log a message object with the DEBUG level including the caller.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- function debug($message, $caller = null)
- {
- $debugLevel = LoggerLevel::getLevelDebug();
- if ($this->repository->isDisabled($debugLevel)) {
- return;
- }
- if ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $debugLevel, $message);
- }
- }
-
- /**
- * Log a message object with the ERROR level including the caller.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- function error($message, $caller = null)
- {
- $errorLevel = LoggerLevel::getLevelError();
- if ($this->repository->isDisabled($errorLevel)) {
- return;
- }
- if ($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $errorLevel, $message);
- }
- }
-
- /**
- * Deprecated. Please use LoggerManager::exists() instead.
- *
- * @param string $name
- * @see LoggerManager::exists()
- * @deprecated
- */
- function exists($name)
- {
- return LoggerManager::exists($name);
- }
-
- /**
- * Log a message object with the FATAL level including the caller.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- function fatal($message, $caller = null)
- {
- $fatalLevel = LoggerLevel::getLevelFatal();
- if ($this->repository->isDisabled($fatalLevel)) {
- return;
- }
- if ($fatalLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $fatalLevel, $message);
- }
- }
-
- /**
- * This method creates a new logging event and logs the event without further checks.
- *
- * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()},
- * {@link error()} and {@link fatal()} wrappers.
- *
- * @param string $fqcn Fully Qualified Class Name of the Logger
- * @param mixed $caller caller object or caller string id
- * @param LoggerLevel $level log level
- * @param mixed $message message
- * @see LoggerLoggingEvent
- */
- function forcedLog($fqcn, $caller, $level, $message)
- {
- // $fqcn = is_object($caller) ? get_class($caller) : (string)$caller;
- $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message));
- }
-
- /**
- * Get the additivity flag for this Category instance.
- * @return boolean
- */
- function getAdditivity()
- {
- return $this->additive;
- }
-
- /**
- * Get the appenders contained in this category as an array.
- * @return array collection of appenders
- */
- function &getAllAppenders()
- {
- $appenders = array();
- $appenderNames = array_keys($this->aai);
- $enumAppenders = sizeof($appenderNames);
- for ($i = 0; $i < $enumAppenders; $i++) {
- $appenderName = $appenderNames[$i];
- $appenders[] =& $this->aai[$appenderName];
- }
- return $appenders;
- }
-
- /**
- * Look for the appender named as name.
- * @return LoggerAppender
- */
- function &getAppender($name)
- {
- return $this->aai[$name];
- }
-
- /**
- * Please use the {@link getEffectiveLevel()} method instead.
- * @deprecated
- */
- function getChainedPriority()
- {
- return $this->getEffectiveLevel();
- }
-
- /**
- * Please use {@link LoggerManager::getCurrentLoggers()} instead.
- * @deprecated
- */
- function getCurrentCategories()
- {
- return LoggerManager::getCurrentLoggers();
- }
-
- /**
- * Please use {@link LoggerManager::getLoggerRepository()} instead.
- * @deprecated
- */
- function &getDefaultHierarchy()
- {
- return LoggerManager::getLoggerRepository();
- }
-
- /**
- * @deprecated Use {@link getLoggerRepository()}
- * @return LoggerHierarchy
- */
- function &getHierarchy()
- {
- return $this->getLoggerRepository();
- }
-
- /**
- * Starting from this category, search the category hierarchy for a non-null level and return it.
- * @see LoggerLevel
- * @return LoggerLevel or null
- */
- function getEffectiveLevel()
- {
- for($c = $this; $c != null; $c = $c->parent) {
- if($c->level !== null)
- return $c->level;
- }
- return null;
- }
-
- /**
- * Retrieve a category with named as the name parameter.
- * @return Logger
- */
- function &getInstance($name)
- {
- return LoggerManager::getLogger($name);
- }
-
- /**
- * Returns the assigned Level, if any, for this Category.
- * @return LoggerLevel or null
- */
- function getLevel()
- {
- return $this->level;
- }
-
- /**
- * Return the the repository where this Category is attached.
- * @return LoggerHierarchy
- */
- function &getLoggerRepository()
- {
- return $this->repository;
- }
-
- /**
- * Return the category name.
- * @return string
- */
- function getName()
- {
- return $this->name;
- }
-
- /**
- * Returns the parent of this category.
- * @return Logger
- */
- function &getParent()
- {
- return $this->parent;
- }
-
- /**
- * Please use getLevel() instead.
- * @deprecated
- */
- function getPriority()
- {
- return $this->getLevel();
- }
-
- /**
- * Return the inherited ResourceBundle for this category.
- */
- function getResourceBundle()
- {
- return;
- }
-
- /**
- * Returns the string resource coresponding to key in this category's inherited resource bundle.
- */
- function getResourceBundleString($key)
- {
- return;
- }
-
- /**
- * Return the root of the default category hierrachy.
- * @return LoggerRoot
- */
- function &getRoot()
- {
- return LoggerManager::getRootLogger();
- }
-
- /**
- * Log a message object with the INFO Level.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- function info($message, $caller = null)
- {
- $infoLevel = LoggerLevel::getLevelInfo();
- if ($this->repository->isDisabled($infoLevel)) {
- return;
- }
- if ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $infoLevel, $message);
- }
- }
-
- /**
- * Is the appender passed as parameter attached to this category?
- *
- * @param LoggerAppender $appender
- */
- function isAttached($appender)
- {
- return in_array($appender->getName(), array_keys($this->aai));
- }
-
- /**
- * Check whether this category is enabled for the DEBUG Level.
- * @return boolean
- */
- function isDebugEnabled()
- {
- $debugLevel = LoggerLevel::getLevelDebug();
- if ($this->repository->isDisabled($debugLevel)) {
- return false;
- }
- return ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel()));
- }
-
- /**
- * Check whether this category is enabled for a given Level passed as parameter.
- *
- * @param LoggerLevel level
- * @return boolean
- */
- function isEnabledFor($level)
- {
- if ($this->repository->isDisabled($level)) {
- return false;
- }
- return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel()));
- }
-
- /**
- * Check whether this category is enabled for the info Level.
- * @return boolean
- * @see LoggerLevel
- */
- function isInfoEnabled()
- {
- $infoLevel = LoggerLevel::getLevelInfo();
- if ($this->repository->isDisabled($infoLevel)) {
- return false;
- }
- return ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel()));
- }
-
- /**
- * Log a localized and parameterized message.
- */
- function l7dlog($priority, $key, $params, $t)
- {
- return;
- }
-
- /**
- * This generic form is intended to be used by wrappers.
- *
- * @param LoggerLevel $priority a valid level
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- function log($priority, $message, $caller = null)
- {
- if ($this->repository->isDisabled($priority)) {
- return;
- }
- if ($priority->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $priority, $message);
- }
- }
-
- /**
- * Remove all previously added appenders from this Category instance.
- */
- function removeAllAppenders()
- {
- $appenderNames = array_keys($this->aai);
- $enumAppenders = sizeof($appenderNames);
- for ($i = 0; $i < $enumAppenders; $i++) {
- $this->removeAppender($appenderNames[$i]);
- }
- }
-
- /**
- * Remove the appender passed as parameter form the list of appenders.
- *
- * @param mixed $appender can be an appender name or a {@link LoggerAppender} object
- */
- function removeAppender($appender)
- {
- if (is_a($appender, 'loggerappender')) {
- $appender->close();
- unset($this->aai[$appender->getName()]);
- } elseif (is_string($appender) and isset($this->aai[$appender])) {
- $this->aai[$appender]->close();
- unset($this->aai[$appender]);
- }
- }
-
- /**
- * Set the additivity flag for this Category instance.
- *
- * @param boolean $additive
- */
- function setAdditivity($additive)
- {
- $this->additive = (bool)$additive;
- }
-
- /**
- * @deprecated Please use {@link setLevel()} instead.
- * @see setLevel()
- */
- function setPriority($priority)
- {
- $this->setLevel($priority);
- }
-
- /**
- * Only the Hiearchy class can set the hiearchy of a
- * category.
- *
- * @param LoggerHierarchy &$repository
- */
- function setHierarchy(&$repository)
- {
- $this->repository =& $repository;
- }
-
- /**
- * Set the level of this Category.
- *
- * @param LoggerLevel $level a level string or a level costant
- */
- function setLevel($level)
- {
- $this->level = $level;
- }
-
- /**
- * Set the resource bundle to be used with localized logging methods
- */
- function setResourceBundle($bundle)
- {
- return;
- }
-
- /**
- * @deprecated use {@link LoggerManager::shutdown()} instead.
- * @see LoggerManager::shutdown()
- */
- function shutdown()
- {
- LoggerManager::shutdown();
- }
-
- /**
- * Log a message with the WARN level.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- function warn($message, $caller = null)
- {
- $warnLevel = LoggerLevel::getLevelWarn();
- if ($this->repository->isDisabled($warnLevel)) {
- return;
- }
- if ($warnLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $warnLevel, $message);
- }
- }
-
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ */
+require_once(LOG4PHP_DIR . '/LoggerLevel.php');
+require_once(LOG4PHP_DIR . '/spi/LoggerLoggingEvent.php');
+
+/**
+ * This class has been deprecated and replaced by the Logger subclass.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.17 $
+ * @package log4php
+ * @see Logger
+ */
+class LoggerCategory {
+
+ /**
+ * Additivity is set to true by default, that is children inherit the
+ * appenders of their ancestors by default.
+ * @var boolean
+ */
+ var $additive = true;
+
+ /**
+ * @var string fully qualified class name
+ */
+ var $fqcn = 'LoggerCategory';
+
+ /**
+ * @var LoggerLevel The assigned level of this category.
+ */
+ var $level = null;
+
+ /**
+ * @var string name of this category.
+ */
+ var $name = '';
+
+ /**
+ * @var Logger The parent of this category.
+ */
+ var $parent = null;
+
+ /**
+ * @var LoggerHierarchy the object repository
+ */
+ var $repository = null;
+
+ /**
+ * @var array collection of appenders
+ * @see LoggerAppender
+ */
+ var $aai = array();
+
+/* --------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------------*/
+
+ /**
+ * Constructor.
+ *
+ * @param string $name Category name
+ */
+ function LoggerCategory($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Add a new Appender to the list of appenders of this Category instance.
+ *
+ * @param LoggerAppender $newAppender
+ */
+ function addAppender(&$newAppender)
+ {
+ $appenderName = $newAppender->getName();
+ $this->aai[$appenderName] =& $newAppender;
+ }
+
+ /**
+ * If assertion parameter is false, then logs msg as an error statement.
+ *
+ * @param bool $assertion
+ * @param string $msg message to log
+ */
+ function assertLog($assertion = true, $msg = '')
+ {
+ if ($assertion == false) {
+ $this->error($msg);
+ }
+ }
+
+ /**
+ * Call the appenders in the hierarchy starting at this.
+ *
+ * @param LoggerLoggingEvent $event
+ */
+ function callAppenders($event)
+ {
+ if (sizeof($this->aai) > 0) {
+ foreach (array_keys($this->aai) as $appenderName) {
+ $this->aai[$appenderName]->doAppend($event);
+ }
+ }
+ if ($this->parent != null and $this->getAdditivity()) {
+ $this->parent->callAppenders($event);
+ }
+ }
+
+ /**
+ * Log a message object with the DEBUG level including the caller.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ function debug($message, $caller = null)
+ {
+ $debugLevel = LoggerLevel::getLevelDebug();
+ if ($this->repository->isDisabled($debugLevel)) {
+ return;
+ }
+ if ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $debugLevel, $message);
+ }
+ }
+
+ /**
+ * Log a message object with the ERROR level including the caller.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ function error($message, $caller = null)
+ {
+ $errorLevel = LoggerLevel::getLevelError();
+ if ($this->repository->isDisabled($errorLevel)) {
+ return;
+ }
+ if ($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $errorLevel, $message);
+ }
+ }
+
+ /**
+ * Deprecated. Please use LoggerManager::exists() instead.
+ *
+ * @param string $name
+ * @see LoggerManager::exists()
+ * @deprecated
+ */
+ function exists($name)
+ {
+ return LoggerManager::exists($name);
+ }
+
+ /**
+ * Log a message object with the FATAL level including the caller.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ function fatal($message, $caller = null)
+ {
+ $fatalLevel = LoggerLevel::getLevelFatal();
+ if ($this->repository->isDisabled($fatalLevel)) {
+ return;
+ }
+ if ($fatalLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $fatalLevel, $message);
+ }
+ }
+
+ /**
+ * This method creates a new logging event and logs the event without further checks.
+ *
+ * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()},
+ * {@link error()} and {@link fatal()} wrappers.
+ *
+ * @param string $fqcn Fully Qualified Class Name of the Logger
+ * @param mixed $caller caller object or caller string id
+ * @param LoggerLevel $level log level
+ * @param mixed $message message
+ * @see LoggerLoggingEvent
+ */
+ function forcedLog($fqcn, $caller, $level, $message)
+ {
+ // $fqcn = is_object($caller) ? get_class($caller) : (string)$caller;
+ $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message));
+ }
+
+ /**
+ * Get the additivity flag for this Category instance.
+ * @return boolean
+ */
+ function getAdditivity()
+ {
+ return $this->additive;
+ }
+
+ /**
+ * Get the appenders contained in this category as an array.
+ * @return array collection of appenders
+ */
+ function &getAllAppenders()
+ {
+ $appenders = array();
+ $appenderNames = array_keys($this->aai);
+ $enumAppenders = sizeof($appenderNames);
+ for ($i = 0; $i < $enumAppenders; $i++) {
+ $appenderName = $appenderNames[$i];
+ $appenders[] =& $this->aai[$appenderName];
+ }
+ return $appenders;
+ }
+
+ /**
+ * Look for the appender named as name.
+ * @return LoggerAppender
+ */
+ function &getAppender($name)
+ {
+ return $this->aai[$name];
+ }
+
+ /**
+ * Please use the {@link getEffectiveLevel()} method instead.
+ * @deprecated
+ */
+ function getChainedPriority()
+ {
+ return $this->getEffectiveLevel();
+ }
+
+ /**
+ * Please use {@link LoggerManager::getCurrentLoggers()} instead.
+ * @deprecated
+ */
+ function getCurrentCategories()
+ {
+ return LoggerManager::getCurrentLoggers();
+ }
+
+ /**
+ * Please use {@link LoggerManager::getLoggerRepository()} instead.
+ * @deprecated
+ */
+ function &getDefaultHierarchy()
+ {
+ return LoggerManager::getLoggerRepository();
+ }
+
+ /**
+ * @deprecated Use {@link getLoggerRepository()}
+ * @return LoggerHierarchy
+ */
+ function &getHierarchy()
+ {
+ return $this->getLoggerRepository();
+ }
+
+ /**
+ * Starting from this category, search the category hierarchy for a non-null level and return it.
+ * @see LoggerLevel
+ * @return LoggerLevel or null
+ */
+ function getEffectiveLevel()
+ {
+ for($c = $this; $c != null; $c = $c->parent) {
+ if($c->level !== null)
+ return $c->level;
+ }
+ return null;
+ }
+
+ /**
+ * Retrieve a category with named as the name parameter.
+ * @return Logger
+ */
+ function &getInstance($name)
+ {
+ return LoggerManager::getLogger($name);
+ }
+
+ /**
+ * Returns the assigned Level, if any, for this Category.
+ * @return LoggerLevel or null
+ */
+ function getLevel()
+ {
+ return $this->level;
+ }
+
+ /**
+ * Return the the repository where this Category is attached.
+ * @return LoggerHierarchy
+ */
+ function &getLoggerRepository()
+ {
+ return $this->repository;
+ }
+
+ /**
+ * Return the category name.
+ * @return string
+ */
+ function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Returns the parent of this category.
+ * @return Logger
+ */
+ function &getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Please use getLevel() instead.
+ * @deprecated
+ */
+ function getPriority()
+ {
+ return $this->getLevel();
+ }
+
+ /**
+ * Return the inherited ResourceBundle for this category.
+ */
+ function getResourceBundle()
+ {
+ return;
+ }
+
+ /**
+ * Returns the string resource coresponding to key in this category's inherited resource bundle.
+ */
+ function getResourceBundleString($key)
+ {
+ return;
+ }
+
+ /**
+ * Return the root of the default category hierrachy.
+ * @return LoggerRoot
+ */
+ function &getRoot()
+ {
+ return LoggerManager::getRootLogger();
+ }
+
+ /**
+ * Log a message object with the INFO Level.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ function info($message, $caller = null)
+ {
+ $infoLevel = LoggerLevel::getLevelInfo();
+ if ($this->repository->isDisabled($infoLevel)) {
+ return;
+ }
+ if ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $infoLevel, $message);
+ }
+ }
+
+ /**
+ * Is the appender passed as parameter attached to this category?
+ *
+ * @param LoggerAppender $appender
+ */
+ function isAttached($appender)
+ {
+ return in_array($appender->getName(), array_keys($this->aai));
+ }
+
+ /**
+ * Check whether this category is enabled for the DEBUG Level.
+ * @return boolean
+ */
+ function isDebugEnabled()
+ {
+ $debugLevel = LoggerLevel::getLevelDebug();
+ if ($this->repository->isDisabled($debugLevel)) {
+ return false;
+ }
+ return ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel()));
+ }
+
+ /**
+ * Check whether this category is enabled for a given Level passed as parameter.
+ *
+ * @param LoggerLevel level
+ * @return boolean
+ */
+ function isEnabledFor($level)
+ {
+ if ($this->repository->isDisabled($level)) {
+ return false;
+ }
+ return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel()));
+ }
+
+ /**
+ * Check whether this category is enabled for the info Level.
+ * @return boolean
+ * @see LoggerLevel
+ */
+ function isInfoEnabled()
+ {
+ $infoLevel = LoggerLevel::getLevelInfo();
+ if ($this->repository->isDisabled($infoLevel)) {
+ return false;
+ }
+ return ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel()));
+ }
+
+ /**
+ * Log a localized and parameterized message.
+ */
+ function l7dlog($priority, $key, $params, $t)
+ {
+ return;
+ }
+
+ /**
+ * This generic form is intended to be used by wrappers.
+ *
+ * @param LoggerLevel $priority a valid level
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ function log($priority, $message, $caller = null)
+ {
+ if ($this->repository->isDisabled($priority)) {
+ return;
+ }
+ if ($priority->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $priority, $message);
+ }
+ }
+
+ /**
+ * Remove all previously added appenders from this Category instance.
+ */
+ function removeAllAppenders()
+ {
+ $appenderNames = array_keys($this->aai);
+ $enumAppenders = sizeof($appenderNames);
+ for ($i = 0; $i < $enumAppenders; $i++) {
+ $this->removeAppender($appenderNames[$i]);
+ }
+ }
+
+ /**
+ * Remove the appender passed as parameter form the list of appenders.
+ *
+ * @param mixed $appender can be an appender name or a {@link LoggerAppender} object
+ */
+ function removeAppender($appender)
+ {
+ if (is_a($appender, 'loggerappender')) {
+ $appender->close();
+ unset($this->aai[$appender->getName()]);
+ } elseif (is_string($appender) and isset($this->aai[$appender])) {
+ $this->aai[$appender]->close();
+ unset($this->aai[$appender]);
+ }
+ }
+
+ /**
+ * Set the additivity flag for this Category instance.
+ *
+ * @param boolean $additive
+ */
+ function setAdditivity($additive)
+ {
+ $this->additive = (bool)$additive;
+ }
+
+ /**
+ * @deprecated Please use {@link setLevel()} instead.
+ * @see setLevel()
+ */
+ function setPriority($priority)
+ {
+ $this->setLevel($priority);
+ }
+
+ /**
+ * Only the Hiearchy class can set the hiearchy of a
+ * category.
+ *
+ * @param LoggerHierarchy &$repository
+ */
+ function setHierarchy(&$repository)
+ {
+ $this->repository =& $repository;
+ }
+
+ /**
+ * Set the level of this Category.
+ *
+ * @param LoggerLevel $level a level string or a level costant
+ */
+ function setLevel($level)
+ {
+ $this->level = $level;
+ }
+
+ /**
+ * Set the resource bundle to be used with localized logging methods
+ */
+ function setResourceBundle($bundle)
+ {
+ return;
+ }
+
+ /**
+ * @deprecated use {@link LoggerManager::shutdown()} instead.
+ * @see LoggerManager::shutdown()
+ */
+ function shutdown()
+ {
+ LoggerManager::shutdown();
+ }
+
+ /**
+ * Log a message with the WARN level.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ function warn($message, $caller = null)
+ {
+ $warnLevel = LoggerLevel::getLevelWarn();
+ if ($this->repository->isDisabled($warnLevel)) {
+ return;
+ }
+ if ($warnLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $warnLevel, $message);
+ }
+ }
+
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerDefaultCategoryFactory.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerDefaultCategoryFactory.php (original)
+++ vtigercrm/trunk/log4php/LoggerDefaultCategoryFactory.php Wed May 3 22:07:13 2006
@@ -1,52 +1,52 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-require_once(LOG4PHP_DIR . '/spi/LoggerFactory.php');
-require_once(LOG4PHP_DIR . '/Logger.php');
-
-/**
- * Creates instances of {@link Logger} with a given name.
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @since 0.5
- */
-class LoggerDefaultCategoryFactory extends LoggerFactory {
-
- function LoggerDefaultCategoryFactory()
- {
- return;
- }
-
- /**
- * @param string $name
- * @return Logger
- */
- function makeNewLoggerInstance($name)
- {
- return new Logger($name);
- }
-}
-
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+require_once(LOG4PHP_DIR . '/spi/LoggerFactory.php');
+require_once(LOG4PHP_DIR . '/Logger.php');
+
+/**
+ * Creates instances of {@link Logger} with a given name.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.2 $
+ * @package log4php
+ * @since 0.5
+ */
+class LoggerDefaultCategoryFactory extends LoggerFactory {
+
+ function LoggerDefaultCategoryFactory()
+ {
+ return;
+ }
+
+ /**
+ * @param string $name
+ * @return Logger
+ */
+ function makeNewLoggerInstance($name)
+ {
+ return new Logger($name);
+ }
+}
+
?>
Modified: vtigercrm/trunk/log4php/LoggerHierarchy.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerHierarchy.php (original)
+++ vtigercrm/trunk/log4php/LoggerHierarchy.php Wed May 3 22:07:13 2006
@@ -1,388 +1,388 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- */
-require_once(LOG4PHP_DIR . '/LoggerLog.php');
-require_once(LOG4PHP_DIR . '/LoggerLevel.php');
-require_once(LOG4PHP_DIR . '/LoggerRoot.php');
-require_once(LOG4PHP_DIR . '/or/LoggerRendererMap.php');
-require_once(LOG4PHP_DIR . '/LoggerDefaultCategoryFactory.php');
-
-/**
- * This class is specialized in retrieving loggers by name and also maintaining
- * the logger hierarchy.
- *
- * <p>The casual user does not have to deal with this class directly.</p>
- *
- * <p>The structure of the logger hierarchy is maintained by the
- * getLogger method. The hierarchy is such that children link
- * to their parent but parents do not have any pointers to their
- * children. Moreover, loggers can be instantiated in any order, in
- * particular descendant before ancestor.</p>
- *
- * <p>In case a descendant is created before a particular ancestor,
- * then it creates a provision node for the ancestor and adds itself
- * to the provision node. Other descendants of the same ancestor add
- * themselves to the previously created provision node.</p>
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- */
-class LoggerHierarchy {
-
- /**
- * @var object currently unused
- */
- var $defaultFactory;
-
- /**
- * @var boolean activate internal logging
- * @see LoggerLog
- */
- var $debug = false;
-
- /**
- * @var array hierarchy tree. saves here all loggers
- */
- var $ht = array();
-
- /**
- * @var LoggerRoot
- */
- var $root = null;
-
- /**
- * @var LoggerRendererMap
- */
- var $rendererMap;
-
- /**
- * @var LoggerLevel main level threshold
- */
- var $threshold;
-
- /**
- * @var boolean currently unused
- */
- var $emittedNoAppenderWarning = false;
-
- /**
- * @var boolean currently unused
- */
- var $emittedNoResourceBundleWarning = false;
-
-
-/* --------------------------------------------------------------------------*/
-/* --------------------------------------------------------------------------*/
-/* --------------------------------------------------------------------------*/
-
- function &singleton()
- {
- static $instance;
-
- if (!isset($instance))
- $instance = new LoggerHierarchy(new LoggerRoot());
- return $instance;
- }
-
- /**
- * Create a new logger hierarchy.
- * @param object $root the root logger
- */
- function LoggerHierarchy($root)
- {
- $this->root =& $root;
- // Enable all level levels by default.
- $this->setThreshold(LoggerLevel::getLevelAll());
- $this->root->setHierarchy($this);
- $this->rendererMap = new LoggerRendererMap();
- $this->defaultFactory = new LoggerDefaultCategoryFactory();
- }
-
- /**
- * Add a HierarchyEventListener event to the repository.
- * Not Yet Impl.
- */
- function addHierarchyEventListener($listener)
- {
- return;
- }
-
- /**
- * Add an object renderer for a specific class.
- * Not Yet Impl.
- */
- function addRenderer($classToRender, $or)
- {
- $this->rendererMap->put($classToRender, $or);
- }
-
- /**
- * This call will clear all logger definitions from the internal hashtable.
- */
- function clear()
- {
- $this->ht = array();
- }
-
- function emitNoAppenderWarning($cat)
- {
- return;
- }
-
- /**
- * Check if the named logger exists in the hierarchy.
- * @param string $name
- * @return boolean
- */
- function exists($name)
- {
- return in_array($name, array_keys($this->ht));
- }
-
- function fireAddAppenderEvent($logger, $appender)
- {
- return;
- }
-
- /**
- * @deprecated Please use {@link getCurrentLoggers()} instead.
- */
- function &getCurrentCategories()
- {
- return $this->getCurrentLoggers();
- }
-
- /**
- * Returns all the currently defined categories in this hierarchy as an array.
- * @return array
- */
- function &getCurrentLoggers()
- {
- $loggers = array();
- $loggerNames = array_keys($this->ht);
- $enumLoggers = sizeof($loggerNames);
- for ($i = 0; $i < $enumLoggers; $i++) {
- $loggerName = $loggerNames[$i];
- $loggers[] =& $this->ht[$loggerName];
- }
- return $loggers;
- }
-
- /**
- * Return a new logger instance named as the first parameter using the default factory.
- *
- * @param string $name logger name
- * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
- * @return Logger
- */
- function &getLogger($name, $factory = null)
- {
- if ($factory === null) {
- return $this->getLoggerByFactory($name, $this->defaultFactory);
- } else {
- return $this->getLoggerByFactory($name, $factory);
- }
- }
-
- /**
- * Return a new logger instance named as the first parameter using the default factory.
- *
- * @param string $name logger name
- * @return Logger
- * @todo merge with {@link getLogger()}
- */
- function &getLoggerByFactory($name, $factory)
- {
- if (!isset($this->ht[$name])) {
- LoggerLog::debug("LoggerHierarchy::getLoggerByFactory():name=[$name]:factory=[".get_class($factory)."] creating a new logger...");
- $this->ht[$name] = $factory->makeNewLoggerInstance($name);
- $this->ht[$name]->setHierarchy($this);
- $nodes = explode('.', $name);
- $firstNode = array_shift($nodes);
- if ( $firstNode != $name and isset($this->ht[$firstNode])) {
- LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [$firstNode]");
- $this->ht[$name]->parent =& $this->ht[$firstNode];
- } else {
- LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [root]");
- $this->ht[$name]->parent =& $this->root;
- }
- if (sizeof($nodes) > 0) {
- // find parent node
- foreach ($nodes as $node) {
- $parentNode = "$firstNode.$node";
- if (isset($this->ht[$parentNode]) and $parentNode != $name) {
- LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [$parentNode]");
- $this->ht[$name]->parent =& $this->ht[$parentNode];
- }
- $firstNode .= ".$node";
- }
- }
- // update children
- /*
- $children = array();
- foreach (array_keys($this->ht) as $nodeName) {
- if ($nodeName != $name and substr($nodeName, 0, strlen($name)) == $name) {
- $children[] = $nodeName;
- }
- }
- */
- }
- return $this->ht[$name];
- }
-
- /**
- * @return LoggerRendererMap Get the renderer map for this hierarchy.
- */
- function &getRendererMap()
- {
- return $this->rendererMap;
- }
-
- /**
- * @return LoggerRoot Get the root of this hierarchy.
- */
- function &getRootLogger()
- {
- if (!isset($this->root) or $this->root == null)
- $this->root = new LoggerRoot();
- return $this->root;
- }
-
- /**
- * @return LoggerLevel Returns the threshold Level.
- */
- function getThreshold()
- {
- return $this->threshold;
- }
-
- /**
- * This method will return true if this repository is disabled
- * for level object passed as parameter and false otherwise.
- * @return boolean
- */
- function isDisabled($level)
- {
- return ($this->threshold->level > $level->level);
- }
-
- /**
- * @deprecated Deprecated with no replacement.
- */
- function overrideAsNeeded($override)
- {
- return;
- }
-
- /**
- * Reset all values contained in this hierarchy instance to their
- * default.
- *
- * This removes all appenders from all categories, sets
- * the level of all non-root categories 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}. Moreover,
- * message disabling is set its default "off" value.
- *
- * <p>Existing categories 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>
- */
- function resetConfiguration()
- {
- $root =& $this->getRootLogger();
-
- $root->setLevel(LoggerLevel::getLevelDebug());
- $this->setThreshold(LoggerLevel::getLevelAll());
- $this->shutDown();
- $loggers =& $this->getCurrentLoggers();
- $enumLoggers = sizeof($loggers);
- for ($i = 0; $i < $enumLoggers; $i++) {
- $loggers[$i]->setLevel(null);
- $loggers[$i]->setAdditivity(true);
- $loggers[$i]->setResourceBundle(null);
- }
- $this->rendererMap->clear();
- }
-
- /**
- * @deprecated Deprecated with no replacement.
- */
- function setDisableOverride($override)
- {
- return;
- }
-
- /**
- * Used by subclasses to add a renderer to the hierarchy passed as parameter.
- * @param string $renderedClass a LoggerRenderer class name
- * @param LoggerRenderer $renderer
- *
- */
- function setRenderer($renderedClass, $renderer)
- {
- $this->rendererMap->put($renderedClass, $renderer);
- }
-
- /**
- * set a new threshold level
- *
- * @param LoggerLevel $l
- */
- function setThreshold($l)
- {
- if ($l !== null)
- $this->threshold = $l;
- }
-
- /**
- * Shutting down a hierarchy will <i>safely</i> close and remove
- * all appenders in all categories including the root logger.
- *
- * <p>Some appenders such as {@link LoggerSocketAppender}
- * need to be closed before the
- * application exists. Otherwise, pending logging events might be
- * lost.
- *
- * <p>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.
- */
- function shutdown()
- {
- $this->root->removeAllAppenders();
- $cats =& $this->getCurrentLoggers();
- $enumCats = sizeof($cats);
- if ($enumCats > 0) {
- for ($i = 0; $i < $enumCats; $i++) {
- $cats[$i]->removeAllAppenders();
- }
- }
- }
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ */
+require_once(LOG4PHP_DIR . '/LoggerLog.php');
+require_once(LOG4PHP_DIR . '/LoggerLevel.php');
+require_once(LOG4PHP_DIR . '/LoggerRoot.php');
+require_once(LOG4PHP_DIR . '/or/LoggerRendererMap.php');
+require_once(LOG4PHP_DIR . '/LoggerDefaultCategoryFactory.php');
+
+/**
+ * This class is specialized in retrieving loggers by name and also maintaining
+ * the logger hierarchy.
+ *
+ * <p>The casual user does not have to deal with this class directly.</p>
+ *
+ * <p>The structure of the logger hierarchy is maintained by the
+ * getLogger method. The hierarchy is such that children link
+ * to their parent but parents do not have any pointers to their
+ * children. Moreover, loggers can be instantiated in any order, in
+ * particular descendant before ancestor.</p>
+ *
+ * <p>In case a descendant is created before a particular ancestor,
+ * then it creates a provision node for the ancestor and adds itself
+ * to the provision node. Other descendants of the same ancestor add
+ * themselves to the previously created provision node.</p>
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.20 $
+ * @package log4php
+ */
+class LoggerHierarchy {
+
+ /**
+ * @var object currently unused
+ */
+ var $defaultFactory;
+
+ /**
+ * @var boolean activate internal logging
+ * @see LoggerLog
+ */
+ var $debug = false;
+
+ /**
+ * @var array hierarchy tree. saves here all loggers
+ */
+ var $ht = array();
+
+ /**
+ * @var LoggerRoot
+ */
+ var $root = null;
+
+ /**
+ * @var LoggerRendererMap
+ */
+ var $rendererMap;
+
+ /**
+ * @var LoggerLevel main level threshold
+ */
+ var $threshold;
+
+ /**
+ * @var boolean currently unused
+ */
+ var $emittedNoAppenderWarning = false;
+
+ /**
+ * @var boolean currently unused
+ */
+ var $emittedNoResourceBundleWarning = false;
+
+
+/* --------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------------*/
+
+ function &singleton()
+ {
+ static $instance;
+
+ if (!isset($instance))
+ $instance = new LoggerHierarchy(new LoggerRoot());
+ return $instance;
+ }
+
+ /**
+ * Create a new logger hierarchy.
+ * @param object $root the root logger
+ */
+ function LoggerHierarchy($root)
+ {
+ $this->root =& $root;
+ // Enable all level levels by default.
+ $this->setThreshold(LoggerLevel::getLevelAll());
+ $this->root->setHierarchy($this);
+ $this->rendererMap = new LoggerRendererMap();
+ $this->defaultFactory = new LoggerDefaultCategoryFactory();
+ }
+
+ /**
+ * Add a HierarchyEventListener event to the repository.
+ * Not Yet Impl.
+ */
+ function addHierarchyEventListener($listener)
+ {
+ return;
+ }
+
+ /**
+ * Add an object renderer for a specific class.
+ * Not Yet Impl.
+ */
+ function addRenderer($classToRender, $or)
+ {
+ $this->rendererMap->put($classToRender, $or);
+ }
+
+ /**
+ * This call will clear all logger definitions from the internal hashtable.
+ */
+ function clear()
+ {
+ $this->ht = array();
+ }
+
+ function emitNoAppenderWarning($cat)
+ {
+ return;
+ }
+
+ /**
+ * Check if the named logger exists in the hierarchy.
+ * @param string $name
+ * @return boolean
+ */
+ function exists($name)
+ {
+ return in_array($name, array_keys($this->ht));
+ }
+
+ function fireAddAppenderEvent($logger, $appender)
+ {
+ return;
+ }
+
+ /**
+ * @deprecated Please use {@link getCurrentLoggers()} instead.
+ */
+ function &getCurrentCategories()
+ {
+ return $this->getCurrentLoggers();
+ }
+
+ /**
+ * Returns all the currently defined categories in this hierarchy as an array.
+ * @return array
+ */
+ function &getCurrentLoggers()
+ {
+ $loggers = array();
+ $loggerNames = array_keys($this->ht);
+ $enumLoggers = sizeof($loggerNames);
+ for ($i = 0; $i < $enumLoggers; $i++) {
+ $loggerName = $loggerNames[$i];
+ $loggers[] =& $this->ht[$loggerName];
+ }
+ return $loggers;
+ }
+
+ /**
+ * Return a new logger instance named as the first parameter using the default factory.
+ *
+ * @param string $name logger name
+ * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
+ * @return Logger
+ */
+ function &getLogger($name, $factory = null)
+ {
+ if ($factory === null) {
+ return $this->getLoggerByFactory($name, $this->defaultFactory);
+ } else {
+ return $this->getLoggerByFactory($name, $factory);
+ }
+ }
+
+ /**
+ * Return a new logger instance named as the first parameter using the default factory.
+ *
+ * @param string $name logger name
+ * @return Logger
+ * @todo merge with {@link getLogger()}
+ */
+ function &getLoggerByFactory($name, $factory)
+ {
+ if (!isset($this->ht[$name])) {
+ LoggerLog::debug("LoggerHierarchy::getLoggerByFactory():name=[$name]:factory=[".get_class($factory)."] creating a new logger...");
+ $this->ht[$name] = $factory->makeNewLoggerInstance($name);
+ $this->ht[$name]->setHierarchy($this);
+ $nodes = explode('.', $name);
+ $firstNode = array_shift($nodes);
+ if ( $firstNode != $name and isset($this->ht[$firstNode])) {
+ LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [$firstNode]");
+ $this->ht[$name]->parent =& $this->ht[$firstNode];
+ } else {
+ LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [root]");
+ $this->ht[$name]->parent =& $this->root;
+ }
+ if (sizeof($nodes) > 0) {
+ // find parent node
+ foreach ($nodes as $node) {
+ $parentNode = "$firstNode.$node";
+ if (isset($this->ht[$parentNode]) and $parentNode != $name) {
+ LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [$parentNode]");
+ $this->ht[$name]->parent =& $this->ht[$parentNode];
+ }
+ $firstNode .= ".$node";
+ }
+ }
+ // update children
+ /*
+ $children = array();
+ foreach (array_keys($this->ht) as $nodeName) {
+ if ($nodeName != $name and substr($nodeName, 0, strlen($name)) == $name) {
+ $children[] = $nodeName;
+ }
+ }
+ */
+ }
+ return $this->ht[$name];
+ }
+
+ /**
+ * @return LoggerRendererMap Get the renderer map for this hierarchy.
+ */
+ function &getRendererMap()
+ {
+ return $this->rendererMap;
+ }
+
+ /**
+ * @return LoggerRoot Get the root of this hierarchy.
+ */
+ function &getRootLogger()
+ {
+ if (!isset($this->root) or $this->root == null)
+ $this->root = new LoggerRoot();
+ return $this->root;
+ }
+
+ /**
+ * @return LoggerLevel Returns the threshold Level.
+ */
+ function getThreshold()
+ {
+ return $this->threshold;
+ }
+
+ /**
+ * This method will return true if this repository is disabled
+ * for level object passed as parameter and false otherwise.
+ * @return boolean
+ */
+ function isDisabled($level)
+ {
+ return ($this->threshold->level > $level->level);
+ }
+
+ /**
+ * @deprecated Deprecated with no replacement.
+ */
+ function overrideAsNeeded($override)
+ {
+ return;
+ }
+
+ /**
+ * Reset all values contained in this hierarchy instance to their
+ * default.
+ *
+ * This removes all appenders from all categories, sets
+ * the level of all non-root categories 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}. Moreover,
+ * message disabling is set its default "off" value.
+ *
+ * <p>Existing categories 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>
+ */
+ function resetConfiguration()
+ {
+ $root =& $this->getRootLogger();
+
+ $root->setLevel(LoggerLevel::getLevelDebug());
+ $this->setThreshold(LoggerLevel::getLevelAll());
+ $this->shutDown();
+ $loggers =& $this->getCurrentLoggers();
+ $enumLoggers = sizeof($loggers);
+ for ($i = 0; $i < $enumLoggers; $i++) {
+ $loggers[$i]->setLevel(null);
+ $loggers[$i]->setAdditivity(true);
+ $loggers[$i]->setResourceBundle(null);
+ }
+ $this->rendererMap->clear();
+ }
+
+ /**
+ * @deprecated Deprecated with no replacement.
+ */
+ function setDisableOverride($override)
+ {
+ return;
+ }
+
+ /**
+ * Used by subclasses to add a renderer to the hierarchy passed as parameter.
+ * @param string $renderedClass a LoggerRenderer class name
+ * @param LoggerRenderer $renderer
+ *
+ */
+ function setRenderer($renderedClass, $renderer)
+ {
+ $this->rendererMap->put($renderedClass, $renderer);
+ }
+
+ /**
+ * set a new threshold level
+ *
+ * @param LoggerLevel $l
+ */
+ function setThreshold($l)
+ {
+ if ($l !== null)
+ $this->threshold = $l;
+ }
+
+ /**
+ * Shutting down a hierarchy will <i>safely</i> close and remove
+ * all appenders in all categories including the root logger.
+ *
+ * <p>Some appenders such as {@link LoggerSocketAppender}
+ * need to be closed before the
+ * application exists. Otherwise, pending logging events might be
+ * lost.
+ *
+ * <p>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.
+ */
+ function shutdown()
+ {
+ $this->root->removeAllAppenders();
+ $cats =& $this->getCurrentLoggers();
+ $enumCats = sizeof($cats);
+ if ($enumCats > 0) {
+ for ($i = 0; $i < $enumCats; $i++) {
+ $cats[$i]->removeAllAppenders();
+ }
+ }
+ }
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerLayout.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerLayout.php (original)
+++ vtigercrm/trunk/log4php/LoggerLayout.php Wed May 3 22:07:13 2006
@@ -1,98 +1,98 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- * Extend this abstract class to create your own log layout format.
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @abstract
- */
-class LoggerLayout {
-
- /**
- * Creates LoggerLayout instances with the given class name.
- *
- * @param string $class
- * @return LoggerLayout
- */
- function factory($class)
- {
- if (!empty($class)) {
- $class = basename($class);
- if (!class_exists($class))
- @include_once(LOG4PHP_DIR . "/layouts/{$class}.php");
- if (class_exists($class))
- return new $class();
- }
- return null;
- }
-
- /**
- * Override this method
- */
- function activateOptions()
- {
- // override;
- }
-
- /**
- * Override this method to create your own layout format.
- *
- * @param LoggerLoggingEvent
- * @return string
- */
- function format($event)
- {
- return $event->getRenderedMessage();
- }
-
- /**
- * Returns the content type output by this layout.
- * @return string
- */
- function getContentType()
- {
- return "text/plain";
- }
-
- /**
- * Returns the footer for the layout format.
- * @return string
- */
- function getFooter()
- {
- return null;
- }
-
- /**
- * Returns the header for the layout format.
- * @return string
- */
- function getHeader()
- {
- return null;
- }
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ * Extend this abstract class to create your own log layout format.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.10 $
+ * @package log4php
+ * @abstract
+ */
+class LoggerLayout {
+
+ /**
+ * Creates LoggerLayout instances with the given class name.
+ *
+ * @param string $class
+ * @return LoggerLayout
+ */
+ function factory($class)
+ {
+ if (!empty($class)) {
+ $class = basename($class);
+ if (!class_exists($class))
+ @include_once(LOG4PHP_DIR . "/layouts/{$class}.php");
+ if (class_exists($class))
+ return new $class();
+ }
+ return null;
+ }
+
+ /**
+ * Override this method
+ */
+ function activateOptions()
+ {
+ // override;
+ }
+
+ /**
+ * Override this method to create your own layout format.
+ *
+ * @param LoggerLoggingEvent
+ * @return string
+ */
+ function format($event)
+ {
+ return $event->getRenderedMessage();
+ }
+
+ /**
+ * Returns the content type output by this layout.
+ * @return string
+ */
+ function getContentType()
+ {
+ return "text/plain";
+ }
+
+ /**
+ * Returns the footer for the layout format.
+ * @return string
+ */
+ function getFooter()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the header for the layout format.
+ * @return string
+ */
+ function getHeader()
+ {
+ return null;
+ }
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerLevel.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerLevel.php (original)
+++ vtigercrm/trunk/log4php/LoggerLevel.php Wed May 3 22:07:13 2006
@@ -1,264 +1,264 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- */
-require_once(LOG4PHP_DIR . '/LoggerLog.php');
-
-define('LOG4PHP_LEVEL_OFF_INT', 2147483647);
-define('LOG4PHP_LEVEL_FATAL_INT', 50000);
-define('LOG4PHP_LEVEL_ERROR_INT', 40000);
-define('LOG4PHP_LEVEL_WARN_INT', 30000);
-define('LOG4PHP_LEVEL_INFO_INT', 20000);
-define('LOG4PHP_LEVEL_DEBUG_INT', 10000);
-define('LOG4PHP_LEVEL_ALL_INT', -2147483648);
-
-/**
- * Defines the minimum set of levels recognized by the system, that is
- * <i>OFF</i>, <i>FATAL</i>, <i>ERROR</i>,
- * <i>WARN</i>, <i>INFO</i, <i>DEBUG</i> and
- * <i>ALL</i>.
- *
- * <p>The <i>LoggerLevel</i> class may be subclassed to define a larger
- * level set.</p>
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @since 0.5
- */
-class LoggerLevel {
-
- /**
- * @var integer
- */
- var $level;
-
- /**
- * @var string
- */
- var $levelStr;
-
- /**
- * @var integer
- */
- var $syslogEquivalent;
-
- /**
- * Constructor
- *
- * @param integer $level
- * @param string $levelStr
- * @param integer $syslogEquivalent
- */
- function LoggerLevel($level, $levelStr, $syslogEquivalent)
- {
- $this->level = $level;
- $this->levelStr = $levelStr;
- $this->syslogEquivalent = $syslogEquivalent;
- }
-
- /**
- * Two priorities are equal if their level fields are equal.
- *
- * @param object $o
- * @return boolean
- */
- function equals($o)
- {
- if (is_a($o, 'loggerlevel')) {
- return ($this->level == $o->level);
- } else {
- return false;
- }
- }
-
- /**
- * Returns an Off Level
- * @static
- * @return LoggerLevel
- */
- function &getLevelOff()
- {
- static $level;
- if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_OFF_INT, 'OFF', 0);
- return $level;
- }
-
- /**
- * Returns a Fatal Level
- * @static
- * @return LoggerLevel
- */
- function &getLevelFatal()
- {
- static $level;
- if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_FATAL_INT, 'FATAL', 0);
- return $level;
- }
-
- /**
- * Returns an Error Level
- * @static
- * @return LoggerLevel
- */
- function &getLevelError()
- {
- static $level;
- if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_ERROR_INT, 'ERROR', 3);
- return $level;
- }
-
- /**
- * Returns a Warn Level
- * @static
- * @return LoggerLevel
- */
- function &getLevelWarn()
- {
- static $level;
- if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_WARN_INT, 'WARN', 4);
- return $level;
- }
-
- /**
- * Returns an Info Level
- * @static
- * @return LoggerLevel
- */
- function &getLevelInfo()
- {
- static $level;
- if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_INFO_INT, 'INFO', 6);
- return $level;
- }
-
- /**
- * Returns a Debug Level
- * @static
- * @return LoggerLevel
- */
- function &getLevelDebug()
- {
- static $level;
- if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_DEBUG_INT, 'DEBUG', 7);
- return $level;
- }
-
- /**
- * Returns an All Level
- * @static
- * @return LoggerLevel
- */
- function &getLevelAll()
- {
- static $level;
- if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_ALL_INT, 'ALL', 7);
- return $level;
- }
-
- /**
- * Return the syslog equivalent of this priority as an integer.
- * @final
- * @return integer
- */
- function getSyslogEquivalent()
- {
- return $this->syslogEquivalent;
- }
-
- /**
- * Returns <i>true</i> if this level has a higher or equal
- * level than the level passed as argument, <i>false</i>
- * otherwise.
- *
- * <p>You should think twice before overriding the default
- * implementation of <i>isGreaterOrEqual</i> method.
- *
- * @param LoggerLevel $r
- * @return boolean
- */
- function isGreaterOrEqual($r)
- {
- return $this->level >= $r->level;
- }
-
- /**
- * Returns the string representation of this priority.
- * @return string
- * @final
- */
- function toString()
- {
- return $this->levelStr;
- }
-
- /**
- * Returns the integer representation of this level.
- * @return integer
- */
- function toInt()
- {
- return $this->level;
- }
-
- /**
- * Convert the string passed as argument to a level. If the
- * conversion fails, then this method returns a DEBUG Level.
- *
- * @param mixed $arg
- * @param LoggerLevel $default
- * @static
- */
- function &toLevel($arg, $defaultLevel = null)
- {
- if ($defaultLevel === null) {
- return LoggerLevel::toLevel($arg, LoggerLevel::getLevelDebug());
- } else {
- if (is_int($arg)) {
- switch($arg) {
- case LOG4PHP_LEVEL_ALL_INT: return LoggerLevel::getLevelAll();
- case LOG4PHP_LEVEL_DEBUG_INT: return LoggerLevel::getLevelDebug();
- case LOG4PHP_LEVEL_INFO_INT: return LoggerLevel::getLevelInfo();
- case LOG4PHP_LEVEL_WARN_INT: return LoggerLevel::getLevelWarn();
- case LOG4PHP_LEVEL_ERROR_INT: return LoggerLevel::getLevelError();
- case LOG4PHP_LEVEL_FATAL_INT: return LoggerLevel::getLevelFatal();
- case LOG4PHP_LEVEL_OFF_INT: return LoggerLevel::getLevelOff();
- default: return $defaultLevel;
- }
- } else {
- switch(strtoupper($arg)) {
- case 'ALL': return LoggerLevel::getLevelAll();
- case 'DEBUG': return LoggerLevel::getLevelDebug();
- case 'INFO': return LoggerLevel::getLevelInfo();
- case 'WARN': return LoggerLevel::getLevelWarn();
- case 'ERROR': return LoggerLevel::getLevelError();
- case 'FATAL': return LoggerLevel::getLevelFatal();
- case 'OFF': return LoggerLevel::getLevelOff();
- default: return $defaultLevel;
- }
- }
- }
- }
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ */
+require_once(LOG4PHP_DIR . '/LoggerLog.php');
+
+define('LOG4PHP_LEVEL_OFF_INT', 2147483647);
+define('LOG4PHP_LEVEL_FATAL_INT', 50000);
+define('LOG4PHP_LEVEL_ERROR_INT', 40000);
+define('LOG4PHP_LEVEL_WARN_INT', 30000);
+define('LOG4PHP_LEVEL_INFO_INT', 20000);
+define('LOG4PHP_LEVEL_DEBUG_INT', 10000);
+define('LOG4PHP_LEVEL_ALL_INT', -2147483648);
+
+/**
+ * Defines the minimum set of levels recognized by the system, that is
+ * <i>OFF</i>, <i>FATAL</i>, <i>ERROR</i>,
+ * <i>WARN</i>, <i>INFO</i, <i>DEBUG</i> and
+ * <i>ALL</i>.
+ *
+ * <p>The <i>LoggerLevel</i> class may be subclassed to define a larger
+ * level set.</p>
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.11 $
+ * @package log4php
+ * @since 0.5
+ */
+class LoggerLevel {
+
+ /**
+ * @var integer
+ */
+ var $level;
+
+ /**
+ * @var string
+ */
+ var $levelStr;
+
+ /**
+ * @var integer
+ */
+ var $syslogEquivalent;
+
+ /**
+ * Constructor
+ *
+ * @param integer $level
+ * @param string $levelStr
+ * @param integer $syslogEquivalent
+ */
+ function LoggerLevel($level, $levelStr, $syslogEquivalent)
+ {
+ $this->level = $level;
+ $this->levelStr = $levelStr;
+ $this->syslogEquivalent = $syslogEquivalent;
+ }
+
+ /**
+ * Two priorities are equal if their level fields are equal.
+ *
+ * @param object $o
+ * @return boolean
+ */
+ function equals($o)
+ {
+ if (is_a($o, 'loggerlevel')) {
+ return ($this->level == $o->level);
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns an Off Level
+ * @static
+ * @return LoggerLevel
+ */
+ function &getLevelOff()
+ {
+ static $level;
+ if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_OFF_INT, 'OFF', 0);
+ return $level;
+ }
+
+ /**
+ * Returns a Fatal Level
+ * @static
+ * @return LoggerLevel
+ */
+ function &getLevelFatal()
+ {
+ static $level;
+ if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_FATAL_INT, 'FATAL', 0);
+ return $level;
+ }
+
+ /**
+ * Returns an Error Level
+ * @static
+ * @return LoggerLevel
+ */
+ function &getLevelError()
+ {
+ static $level;
+ if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_ERROR_INT, 'ERROR', 3);
+ return $level;
+ }
+
+ /**
+ * Returns a Warn Level
+ * @static
+ * @return LoggerLevel
+ */
+ function &getLevelWarn()
+ {
+ static $level;
+ if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_WARN_INT, 'WARN', 4);
+ return $level;
+ }
+
+ /**
+ * Returns an Info Level
+ * @static
+ * @return LoggerLevel
+ */
+ function &getLevelInfo()
+ {
+ static $level;
+ if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_INFO_INT, 'INFO', 6);
+ return $level;
+ }
+
+ /**
+ * Returns a Debug Level
+ * @static
+ * @return LoggerLevel
+ */
+ function &getLevelDebug()
+ {
+ static $level;
+ if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_DEBUG_INT, 'DEBUG', 7);
+ return $level;
+ }
+
+ /**
+ * Returns an All Level
+ * @static
+ * @return LoggerLevel
+ */
+ function &getLevelAll()
+ {
+ static $level;
+ if (!isset($level)) $level = new LoggerLevel(LOG4PHP_LEVEL_ALL_INT, 'ALL', 7);
+ return $level;
+ }
+
+ /**
+ * Return the syslog equivalent of this priority as an integer.
+ * @final
+ * @return integer
+ */
+ function getSyslogEquivalent()
+ {
+ return $this->syslogEquivalent;
+ }
+
+ /**
+ * Returns <i>true</i> if this level has a higher or equal
+ * level than the level passed as argument, <i>false</i>
+ * otherwise.
+ *
+ * <p>You should think twice before overriding the default
+ * implementation of <i>isGreaterOrEqual</i> method.
+ *
+ * @param LoggerLevel $r
+ * @return boolean
+ */
+ function isGreaterOrEqual($r)
+ {
+ return $this->level >= $r->level;
+ }
+
+ /**
+ * Returns the string representation of this priority.
+ * @return string
+ * @final
+ */
+ function toString()
+ {
+ return $this->levelStr;
+ }
+
+ /**
+ * Returns the integer representation of this level.
+ * @return integer
+ */
+ function toInt()
+ {
+ return $this->level;
+ }
+
+ /**
+ * Convert the string passed as argument to a level. If the
+ * conversion fails, then this method returns a DEBUG Level.
+ *
+ * @param mixed $arg
+ * @param LoggerLevel $default
+ * @static
+ */
+ function &toLevel($arg, $defaultLevel = null)
+ {
+ if ($defaultLevel === null) {
+ return LoggerLevel::toLevel($arg, LoggerLevel::getLevelDebug());
+ } else {
+ if (is_int($arg)) {
+ switch($arg) {
+ case LOG4PHP_LEVEL_ALL_INT: return LoggerLevel::getLevelAll();
+ case LOG4PHP_LEVEL_DEBUG_INT: return LoggerLevel::getLevelDebug();
+ case LOG4PHP_LEVEL_INFO_INT: return LoggerLevel::getLevelInfo();
+ case LOG4PHP_LEVEL_WARN_INT: return LoggerLevel::getLevelWarn();
+ case LOG4PHP_LEVEL_ERROR_INT: return LoggerLevel::getLevelError();
+ case LOG4PHP_LEVEL_FATAL_INT: return LoggerLevel::getLevelFatal();
+ case LOG4PHP_LEVEL_OFF_INT: return LoggerLevel::getLevelOff();
+ default: return $defaultLevel;
+ }
+ } else {
+ switch(strtoupper($arg)) {
+ case 'ALL': return LoggerLevel::getLevelAll();
+ case 'DEBUG': return LoggerLevel::getLevelDebug();
+ case 'INFO': return LoggerLevel::getLevelInfo();
+ case 'WARN': return LoggerLevel::getLevelWarn();
+ case 'ERROR': return LoggerLevel::getLevelError();
+ case 'FATAL': return LoggerLevel::getLevelFatal();
+ case 'OFF': return LoggerLevel::getLevelOff();
+ default: return $defaultLevel;
+ }
+ }
+ }
+ }
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerLog.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerLog.php (original)
+++ vtigercrm/trunk/log4php/LoggerLog.php Wed May 3 22:07:13 2006
@@ -1,99 +1,99 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- * Helper class for internal logging
- *
- * <p>It uses php {@link PHP_MANUAL#trigger_error trigger_error()} function
- * to output messages.</p>
- * <p>You need to recode methods to output messages in a different way.</p>
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- */
-class LoggerLog {
-
- /**
- * Log if debug is enabled.
- *
- * Log using php {@link PHP_MANUAL#trigger_error trigger_error()} function
- * with E_USER_NOTICE level by default.
- *
- * @param string $message log message
- * @param integer $errLevel level to log
- * @static
- */
- function log($message, $errLevel = E_USER_NOTICE)
- {
- if (LoggerLog::internalDebugging())
- trigger_error($message, $errLevel);
- }
-
- function internalDebugging($value = null)
- {
- static $debug = false;
-
- if (is_bool($value))
- $debug = $value;
- return $debug;
- }
-
- /**
- * Report a debug message.
- *
- * @param string $message log message
- * @static
- * @since 0.3
- */
- function debug($message)
- {
- LoggerLog::log($message, E_USER_NOTICE);
- }
-
- /**
- * Report an error message.
- *
- * @param string $message log message
- * @static
- * @since 0.3
- */
- function error($message)
- {
- trigger_error($message, E_USER_ERROR);
- }
-
- /**
- * Report a warning message.
- *
- * @param string $message log message
- * @static
- * @since 0.3
- */
- function warn($message)
- {
- trigger_error($message, E_USER_WARNING);
- }
-
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ * Helper class for internal logging
+ *
+ * <p>It uses php {@link PHP_MANUAL#trigger_error trigger_error()} function
+ * to output messages.</p>
+ * <p>You need to recode methods to output messages in a different way.</p>
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.9 $
+ * @package log4php
+ */
+class LoggerLog {
+
+ /**
+ * Log if debug is enabled.
+ *
+ * Log using php {@link PHP_MANUAL#trigger_error trigger_error()} function
+ * with E_USER_NOTICE level by default.
+ *
+ * @param string $message log message
+ * @param integer $errLevel level to log
+ * @static
+ */
+ function log($message, $errLevel = E_USER_NOTICE)
+ {
+ if (LoggerLog::internalDebugging())
+ trigger_error($message, $errLevel);
+ }
+
+ function internalDebugging($value = null)
+ {
+ static $debug = false;
+
+ if (is_bool($value))
+ $debug = $value;
+ return $debug;
+ }
+
+ /**
+ * Report a debug message.
+ *
+ * @param string $message log message
+ * @static
+ * @since 0.3
+ */
+ function debug($message)
+ {
+ LoggerLog::log($message, E_USER_NOTICE);
+ }
+
+ /**
+ * Report an error message.
+ *
+ * @param string $message log message
+ * @static
+ * @since 0.3
+ */
+ function error($message)
+ {
+ trigger_error($message, E_USER_ERROR);
+ }
+
+ /**
+ * Report a warning message.
+ *
+ * @param string $message log message
+ * @static
+ * @since 0.3
+ */
+ function warn($message)
+ {
+ trigger_error($message, E_USER_WARNING);
+ }
+
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerMDC.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerMDC.php (original)
+++ vtigercrm/trunk/log4php/LoggerMDC.php Wed May 3 22:07:13 2006
@@ -1,129 +1,129 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- */
-require_once(LOG4PHP_DIR . '/LoggerLog.php');
-
-
-define('LOGGER_MDC_HT_SIZE', 7);
-
-/**
- * This is the global repository of user mappings
- */
-$GLOBALS['log4php.LoggerMDC.ht'] = array();
-
-/**
- * The LoggerMDC class is similar to the {@link LoggerNDC} class except that it is
- * based on a map instead of a stack. It provides <i>mapped diagnostic contexts</i>.
- *
- * A <i>Mapped Diagnostic Context</i>, or
- * MDC in short, is an instrument for distinguishing interleaved log
- * output from different sources. Log output is typically interleaved
- * when a server handles multiple clients near-simultaneously.
- *
- * <p><b><i>The MDC is managed on a per thread basis</i></b>.
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @since 0.3
- * @package log4php
- */
-class LoggerMDC {
-
- /**
- * Put a context value as identified with the key parameter into the current thread's
- * context map.
- *
- * <p>If the current thread does not have a context map it is
- * created as a side effect.</p>
- *
- * <p>Note that you cannot put more than {@link LOGGER_MDC_HT_SIZE} keys.</p>
- *
- * @param string $key the key
- * @param string $value the value
- * @static
- */
- function put($key, $value)
- {
- if ( sizeof($GLOBALS['log4php.LoggerMDC.ht']) < LOGGER_MDC_HT_SIZE )
- $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value;
- }
-
- /**
- * Get the context identified by the key parameter.
- *
- * <p>You can use special key identifiers to map values in
- * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.'
- * followed by the var name you want to refer.</p>
- *
- * <p>This method has no side effects.</p>
- *
- * @param string $key
- * @return string
- * @static
- */
- function get($key)
- {
- LoggerLog::debug("LoggerMDC::get() key='$key'");
-
- if (!empty($key)) {
- if (strpos($key, 'server.') === 0) {
- $varName = substr($key, 7);
-
- LoggerLog::debug("LoggerMDC::get() a _SERVER[$varName] is requested.");
-
- return $_SERVER[$varName];
- } elseif (strpos($key, 'env.') === 0) {
-
- $varName = substr($key, 4);
-
- LoggerLog::debug("LoggerMDC::get() a _ENV[$varName] is requested.");
-
- return $_ENV[$varName];
- } elseif (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) {
-
- LoggerLog::debug("LoggerMDC::get() a user key is requested.");
-
- return $GLOBALS['log4php.LoggerMDC.ht'][$key];
- }
- }
- return '';
- }
-
- /**
- * Remove the the context identified by the key parameter.
- *
- * It only affects user mappings.
- *
- * @param string $key
- * @return string
- * @static
- */
- function remove($key)
- {
- unset($GLOBALS['log4php.LoggerMDC.ht'][$key]);
- }
-
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ */
+require_once(LOG4PHP_DIR . '/LoggerLog.php');
+
+
+define('LOGGER_MDC_HT_SIZE', 7);
+
+/**
+ * This is the global repository of user mappings
+ */
+$GLOBALS['log4php.LoggerMDC.ht'] = array();
+
+/**
+ * The LoggerMDC class is similar to the {@link LoggerNDC} class except that it is
+ * based on a map instead of a stack. It provides <i>mapped diagnostic contexts</i>.
+ *
+ * A <i>Mapped Diagnostic Context</i>, or
+ * MDC in short, is an instrument for distinguishing interleaved log
+ * output from different sources. Log output is typically interleaved
+ * when a server handles multiple clients near-simultaneously.
+ *
+ * <p><b><i>The MDC is managed on a per thread basis</i></b>.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.4 $
+ * @since 0.3
+ * @package log4php
+ */
+class LoggerMDC {
+
+ /**
+ * Put a context value as identified with the key parameter into the current thread's
+ * context map.
+ *
+ * <p>If the current thread does not have a context map it is
+ * created as a side effect.</p>
+ *
+ * <p>Note that you cannot put more than {@link LOGGER_MDC_HT_SIZE} keys.</p>
+ *
+ * @param string $key the key
+ * @param string $value the value
+ * @static
+ */
+ function put($key, $value)
+ {
+ if ( sizeof($GLOBALS['log4php.LoggerMDC.ht']) < LOGGER_MDC_HT_SIZE )
+ $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value;
+ }
+
+ /**
+ * Get the context identified by the key parameter.
+ *
+ * <p>You can use special key identifiers to map values in
+ * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.'
+ * followed by the var name you want to refer.</p>
+ *
+ * <p>This method has no side effects.</p>
+ *
+ * @param string $key
+ * @return string
+ * @static
+ */
+ function get($key)
+ {
+ LoggerLog::debug("LoggerMDC::get() key='$key'");
+
+ if (!empty($key)) {
+ if (strpos($key, 'server.') === 0) {
+ $varName = substr($key, 7);
+
+ LoggerLog::debug("LoggerMDC::get() a _SERVER[$varName] is requested.");
+
+ return $_SERVER[$varName];
+ } elseif (strpos($key, 'env.') === 0) {
+
+ $varName = substr($key, 4);
+
+ LoggerLog::debug("LoggerMDC::get() a _ENV[$varName] is requested.");
+
+ return $_ENV[$varName];
+ } elseif (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) {
+
+ LoggerLog::debug("LoggerMDC::get() a user key is requested.");
+
+ return $GLOBALS['log4php.LoggerMDC.ht'][$key];
+ }
+ }
+ return '';
+ }
+
+ /**
+ * Remove the the context identified by the key parameter.
+ *
+ * It only affects user mappings.
+ *
+ * @param string $key
+ * @return string
+ * @static
+ */
+ function remove($key)
+ {
+ unset($GLOBALS['log4php.LoggerMDC.ht'][$key]);
+ }
+
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerManager.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerManager.php (original)
+++ vtigercrm/trunk/log4php/LoggerManager.php Wed May 3 22:07:13 2006
@@ -1,262 +1,262 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * LOG4PHP_DIR points to the log4php root directory.
- *
- * If not defined it will be set automatically when the first package classfile
- * is included
- *
- * @var string
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-require_once(LOG4PHP_DIR . '/LoggerHierarchy.php');
-
-/**
- * Use the LoggerManager to get Logger instances.
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @see Logger
- * @todo create a configurator selector
- */
-class LoggerManager {
-
- /**
- * check if a given logger exists.
- *
- * @param string $name logger name
- * @static
- * @return boolean
- */
- function exists($name)
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->exists($name);
- }
-
- /**
- * Returns an array this whole Logger instances.
- *
- * @static
- * @see Logger
- * @return array
- */
- function getCurrentLoggers()
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->getCurrentLoggers();
- }
-
- /**
- * Returns the root logger.
- *
- * @static
- * @return object
- * @see LoggerRoot
- */
- function &getRootLogger()
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->getRootLogger();
- }
-
- /**
- * Returns the specified Logger.
- *
- * @param string $name logger name
- * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
- * @static
- * @return Logger
- */
- function &getLogger($name, $factory = null)
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->getLogger($name, $factory);
- }
-
- /**
- * Returns the LoggerHierarchy.
- *
- * @static
- * @return LoggerHierarchy
- */
- function &getLoggerRepository()
- {
- return LoggerHierarchy::singleton();
- }
-
-
- /**
- * Destroy loggers object tree.
- *
- * @static
- * @return boolean
- */
- function resetConfiguration()
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->resetConfiguration();
- }
-
- /**
- * Does nothing.
- * @static
- */
- function setRepositorySelector($selector, $guard)
- {
- return;
- }
-
- /**
- * Safely close all appenders.
- * @static
- */
- function shutdown()
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->shutdown();
- }
-}
-
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-
-if (!defined('LOG4PHP_DEFAULT_INIT_OVERRIDE')) {
- if (isset($_ENV['log4php.defaultInitOverride'])) {
- /**
- * @ignore
- */
- define('LOG4PHP_DEFAULT_INIT_OVERRIDE',
- LoggerOptionConverter::toBoolean($_ENV['log4php.defaultInitOverride'], false)
- );
- } elseif (isset($GLOBALS['log4php.defaultInitOverride'])) {
- /**
- * @ignore
- */
- define('LOG4PHP_DEFAULT_INIT_OVERRIDE',
- LoggerOptionConverter::toBoolean($GLOBALS['log4php.defaultInitOverride'], false)
- );
- } else {
- /**
- * Controls init execution
- *
- * With this constant users can skip the default init procedure that is
- * called when this file is included.
- *
- * <p>If it is not user defined, log4php tries to autoconfigure using (in order):</p>
- *
- * - the <code>$_ENV['log4php.defaultInitOverride']</code> variable.
- * - the <code>$GLOBALS['log4php.defaultInitOverride']</code> global variable.
- * - defaults to <i>false</i>
- *
- * @var boolean
- */
- define('LOG4PHP_DEFAULT_INIT_OVERRIDE', false);
- }
-}
-
-if (!defined('LOG4PHP_CONFIGURATION')) {
- if (isset($_ENV['log4php.configuration'])) {
- /**
- * @ignore
- */
- define('LOG4PHP_CONFIGURATION', trim($_ENV['log4php.configuration']));
- } else {
- /**
- * Configuration file.
- *
- * <p>This constant tells configurator classes where the configuration
- * file is located.</p>
- * <p>If not set by user, log4php tries to set it automatically using
- * (in order):</p>
- *
- * - the <code>$_ENV['log4php.configuration']</code> enviroment variable.
- * - defaults to 'log4php.properties'.
- *
- * @var string
- */
- define('LOG4PHP_CONFIGURATION', 'log4php.properties');
- }
-}
-
-if (!defined('LOG4PHP_CONFIGURATOR_CLASS')) {
- if ( strtolower(substr( LOG4PHP_CONFIGURATION, -4 )) == '.xml') {
- /**
- * @ignore
- */
- define('LOG4PHP_CONFIGURATOR_CLASS', LOG4PHP_DIR . '/xml/LoggerDOMConfigurator');
- } else {
- /**
- * Holds the configurator class name.
- *
- * <p>This constant is set with the fullname (path included but non the
- * .php extension) of the configurator class that init procedure will use.</p>
- * <p>If not set by user, log4php tries to set it automatically.</p>
- * <p>If {@link LOG4PHP_CONFIGURATION} has '.xml' extension set the
- * constants to '{@link LOG4PHP_DIR}/xml/{@link LoggerDOMConfigurator}'.</p>
- * <p>Otherwise set the constants to
- * '{@link LOG4PHP_DIR}/{@link LoggerPropertyConfigurator}'.</p>
- *
- * <p><b>Security Note</b>: classfile pointed by this constant will be brutally
- * included with a:
- * <code>@include_once(LOG4PHP_CONFIGURATOR_CLASS . ".php");</code></p>
- *
- * @var string
- */
- define('LOG4PHP_CONFIGURATOR_CLASS', LOG4PHP_DIR . '/LoggerPropertyConfigurator');
- }
-}
-
-if (!LOG4PHP_DEFAULT_INIT_OVERRIDE) {
- if (!LoggerManagerDefaultInit())
- LoggerLog::warn("LOG4PHP main() Default Init failed.");
-}
-
-/**
- * Default init procedure.
- *
- * <p>This procedure tries to configure the {@link LoggerHierarchy} using the
- * configurator class defined via {@link LOG4PHP_CONFIGURATOR_CLASS} that tries
- * to load the configurator file defined in {@link LOG4PHP_CONFIGURATION}.
- * If something goes wrong a warn is raised.</p>
- * <p>Users can skip this procedure using {@link LOG4PHP_DEFAULT_INIT_OVERRIDE}
- * constant.</p>
- *
- * @return boolean
- */
-function LoggerManagerDefaultInit()
-{
- $configuratorClass = basename(LOG4PHP_CONFIGURATOR_CLASS);
- if (!class_exists($configuratorClass)) {
- @include_once(LOG4PHP_CONFIGURATOR_CLASS . ".php");
- }
- if (class_exists($configuratorClass)) {
-
- return call_user_func(array($configuratorClass, 'configure'), LOG4PHP_CONFIGURATION);
-
- } else {
- LoggerLog::warn("LoggerManagerDefaultInit() Configurator '{$configuratorClass}' doesnt exists");
- return false;
- }
-}
-
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * LOG4PHP_DIR points to the log4php root directory.
+ *
+ * If not defined it will be set automatically when the first package classfile
+ * is included
+ *
+ * @var string
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+require_once(LOG4PHP_DIR . '/LoggerHierarchy.php');
+
+/**
+ * Use the LoggerManager to get Logger instances.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.18 $
+ * @package log4php
+ * @see Logger
+ * @todo create a configurator selector
+ */
+class LoggerManager {
+
+ /**
+ * check if a given logger exists.
+ *
+ * @param string $name logger name
+ * @static
+ * @return boolean
+ */
+ function exists($name)
+ {
+ $repository =& LoggerManager::getLoggerRepository();
+ return $repository->exists($name);
+ }
+
+ /**
+ * Returns an array this whole Logger instances.
+ *
+ * @static
+ * @see Logger
+ * @return array
+ */
+ function getCurrentLoggers()
+ {
+ $repository =& LoggerManager::getLoggerRepository();
+ return $repository->getCurrentLoggers();
+ }
+
+ /**
+ * Returns the root logger.
+ *
+ * @static
+ * @return object
+ * @see LoggerRoot
+ */
+ function &getRootLogger()
+ {
+ $repository =& LoggerManager::getLoggerRepository();
+ return $repository->getRootLogger();
+ }
+
+ /**
+ * Returns the specified Logger.
+ *
+ * @param string $name logger name
+ * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
+ * @static
+ * @return Logger
+ */
+ function &getLogger($name, $factory = null)
+ {
+ $repository =& LoggerManager::getLoggerRepository();
+ return $repository->getLogger($name, $factory);
+ }
+
+ /**
+ * Returns the LoggerHierarchy.
+ *
+ * @static
+ * @return LoggerHierarchy
+ */
+ function &getLoggerRepository()
+ {
+ return LoggerHierarchy::singleton();
+ }
+
+
+ /**
+ * Destroy loggers object tree.
+ *
+ * @static
+ * @return boolean
+ */
+ function resetConfiguration()
+ {
+ $repository =& LoggerManager::getLoggerRepository();
+ return $repository->resetConfiguration();
+ }
+
+ /**
+ * Does nothing.
+ * @static
+ */
+ function setRepositorySelector($selector, $guard)
+ {
+ return;
+ }
+
+ /**
+ * Safely close all appenders.
+ * @static
+ */
+ function shutdown()
+ {
+ $repository =& LoggerManager::getLoggerRepository();
+ return $repository->shutdown();
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+
+if (!defined('LOG4PHP_DEFAULT_INIT_OVERRIDE')) {
+ if (isset($_ENV['log4php.defaultInitOverride'])) {
+ /**
+ * @ignore
+ */
+ define('LOG4PHP_DEFAULT_INIT_OVERRIDE',
+ LoggerOptionConverter::toBoolean($_ENV['log4php.defaultInitOverride'], false)
+ );
+ } elseif (isset($GLOBALS['log4php.defaultInitOverride'])) {
+ /**
+ * @ignore
+ */
+ define('LOG4PHP_DEFAULT_INIT_OVERRIDE',
+ LoggerOptionConverter::toBoolean($GLOBALS['log4php.defaultInitOverride'], false)
+ );
+ } else {
+ /**
+ * Controls init execution
+ *
+ * With this constant users can skip the default init procedure that is
+ * called when this file is included.
+ *
+ * <p>If it is not user defined, log4php tries to autoconfigure using (in order):</p>
+ *
+ * - the <code>$_ENV['log4php.defaultInitOverride']</code> variable.
+ * - the <code>$GLOBALS['log4php.defaultInitOverride']</code> global variable.
+ * - defaults to <i>false</i>
+ *
+ * @var boolean
+ */
+ define('LOG4PHP_DEFAULT_INIT_OVERRIDE', false);
+ }
+}
+
+if (!defined('LOG4PHP_CONFIGURATION')) {
+ if (isset($_ENV['log4php.configuration'])) {
+ /**
+ * @ignore
+ */
+ define('LOG4PHP_CONFIGURATION', trim($_ENV['log4php.configuration']));
+ } else {
+ /**
+ * Configuration file.
+ *
+ * <p>This constant tells configurator classes where the configuration
+ * file is located.</p>
+ * <p>If not set by user, log4php tries to set it automatically using
+ * (in order):</p>
+ *
+ * - the <code>$_ENV['log4php.configuration']</code> enviroment variable.
+ * - defaults to 'log4php.properties'.
+ *
+ * @var string
+ */
+ define('LOG4PHP_CONFIGURATION', 'log4php.properties');
+ }
+}
+
+if (!defined('LOG4PHP_CONFIGURATOR_CLASS')) {
+ if ( strtolower(substr( LOG4PHP_CONFIGURATION, -4 )) == '.xml') {
+ /**
+ * @ignore
+ */
+ define('LOG4PHP_CONFIGURATOR_CLASS', LOG4PHP_DIR . '/xml/LoggerDOMConfigurator');
+ } else {
+ /**
+ * Holds the configurator class name.
+ *
+ * <p>This constant is set with the fullname (path included but non the
+ * .php extension) of the configurator class that init procedure will use.</p>
+ * <p>If not set by user, log4php tries to set it automatically.</p>
+ * <p>If {@link LOG4PHP_CONFIGURATION} has '.xml' extension set the
+ * constants to '{@link LOG4PHP_DIR}/xml/{@link LoggerDOMConfigurator}'.</p>
+ * <p>Otherwise set the constants to
+ * '{@link LOG4PHP_DIR}/{@link LoggerPropertyConfigurator}'.</p>
+ *
+ * <p><b>Security Note</b>: classfile pointed by this constant will be brutally
+ * included with a:
+ * <code>@include_once(LOG4PHP_CONFIGURATOR_CLASS . ".php");</code></p>
+ *
+ * @var string
+ */
+ define('LOG4PHP_CONFIGURATOR_CLASS', LOG4PHP_DIR . '/LoggerPropertyConfigurator');
+ }
+}
+
+if (!LOG4PHP_DEFAULT_INIT_OVERRIDE) {
+ if (!LoggerManagerDefaultInit())
+ LoggerLog::warn("LOG4PHP main() Default Init failed.");
+}
+
+/**
+ * Default init procedure.
+ *
+ * <p>This procedure tries to configure the {@link LoggerHierarchy} using the
+ * configurator class defined via {@link LOG4PHP_CONFIGURATOR_CLASS} that tries
+ * to load the configurator file defined in {@link LOG4PHP_CONFIGURATION}.
+ * If something goes wrong a warn is raised.</p>
+ * <p>Users can skip this procedure using {@link LOG4PHP_DEFAULT_INIT_OVERRIDE}
+ * constant.</p>
+ *
+ * @return boolean
+ */
+function LoggerManagerDefaultInit()
+{
+ $configuratorClass = basename(LOG4PHP_CONFIGURATOR_CLASS);
+ if (!class_exists($configuratorClass)) {
+ @include_once(LOG4PHP_CONFIGURATOR_CLASS . ".php");
+ }
+ if (class_exists($configuratorClass)) {
+
+ return call_user_func(array($configuratorClass, 'configure'), LOG4PHP_CONFIGURATION);
+
+ } else {
+ LoggerLog::warn("LoggerManagerDefaultInit() Configurator '{$configuratorClass}' doesnt exists");
+ return false;
+ }
+}
+
?>
Modified: vtigercrm/trunk/log4php/LoggerNDC.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerNDC.php (original)
+++ vtigercrm/trunk/log4php/LoggerNDC.php Wed May 3 22:07:13 2006
@@ -1,240 +1,240 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- */
-require_once(LOG4PHP_DIR . '/LoggerLog.php');
-
-define('LOGGER_NDC_HT_SIZE', 7);
-
-/**
- * This is the global repository of NDC stack
- */
-$GLOBALS['log4php.LoggerNDC.ht'] = array();
-
-/**
- * This is the max depth of NDC stack
- */
-$GLOBALS['log4php.LoggerNDC.maxDepth'] = LOGGER_NDC_HT_SIZE;
-
-
-/**
- * The NDC class implements <i>nested diagnostic contexts</i> as
- * defined by Neil Harrison in the article "Patterns for Logging
- * Diagnostic Messages" part of the book "<i>Pattern Languages of
- * Program Design 3</i>" edited by Martin et al.
- *
- * <p>A Nested Diagnostic Context, or NDC in short, is an instrument
- * to distinguish interleaved log output from different sources. Log
- * output is typically interleaved when a server handles multiple
- * clients near-simultaneously.
- *
- * <p>Interleaved log output can still be meaningful if each log entry
- * from different contexts had a distinctive stamp. This is where NDCs
- * come into play.
- *
- * <p><i><b>Note that NDCs are managed on a per thread
- * basis</b></i>. NDC operations such as {@link push()}, {@link pop()},
- * {@link clear()}, {@link getDepth()} and {@link setMaxDepth()}
- * affect the NDC of the <i>current</i> thread only. NDCs of other
- * threads remain unaffected.
- *
- * <p>For example, a servlet can build a per client request NDC
- * consisting the clients host name and other information contained in
- * the the request. <i>Cookies</i> are another source of distinctive
- * information. To build an NDC one uses the {@link push()}
- * operation.</p>
- *
- * Simply put,
- *
- * - Contexts can be nested.
- * - When entering a context, call
- * <code>LoggerNDC::push()</code>
- * As a side effect, if there is no nested diagnostic context for the
- * current thread, this method will create it.
- * - When leaving a context, call
- * <code>LoggerNDC::pop()</code>
- * - <b>When exiting a thread make sure to call {@link remove()}</b>
- *
- * <p>There is no penalty for forgetting to match each
- * <code>push</code> operation with a corresponding <code>pop</code>,
- * except the obvious mismatch between the real application context
- * and the context set in the NDC.</p>
- *
- * <p>If configured to do so, {@link LoggerPatternLayout} and {@link LoggerLayoutTTCC}
- * instances automatically retrieve the nested diagnostic
- * context for the current thread without any user intervention.
- * Hence, even if a servlet is serving multiple clients
- * simultaneously, the logs emanating from the same code (belonging to
- * the same category) can still be distinguished because each client
- * request will have a different NDC tag.</p>
- *
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @since 0.3
- */
-class LoggerNDC {
-
- /**
- * Clear any nested diagnostic information if any. This method is
- * useful in cases where the same thread can be potentially used
- * over and over in different unrelated contexts.
- *
- * <p>This method is equivalent to calling the {@link setMaxDepth()}
- * method with a zero <var>maxDepth</var> argument.
- *
- * @static
- */
- function clear()
- {
- LoggerLog::debug("LoggerNDC::clear()");
-
- $GLOBALS['log4php.LoggerNDC.ht'] = array();
- }
-
- /**
- * Never use this method directly, use the {@link LoggerLoggingEvent::getNDC()} method instead.
- * @static
- * @return array
- */
- function get()
- {
- LoggerLog::debug("LoggerNDC::get()");
-
- return $GLOBALS['log4php.LoggerNDC.ht'];
- }
-
- /**
- * Get the current nesting depth of this diagnostic context.
- *
- * @see setMaxDepth()
- * @return integer
- * @static
- */
- function getDepth()
- {
- LoggerLog::debug("LoggerNDC::getDepth()");
-
- return sizeof($GLOBALS['log4php.LoggerNDC.ht']);
- }
-
- /**
- * Clients should call this method before leaving a diagnostic
- * context.
- *
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.</p>
- *
- * @return string The innermost diagnostic context.
- * @static
- */
- function pop()
- {
- LoggerLog::debug("LoggerNDC::pop()");
-
- if (sizeof($GLOBALS['log4php.LoggerNDC.ht']) > 0) {
- return array_pop($GLOBALS['log4php.LoggerNDC.ht']);
- } else {
- return '';
- }
- }
-
- /**
- * Looks at the last diagnostic context at the top of this NDC
- * without removing it.
- *
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.</p>
- * @return string The innermost diagnostic context.
- * @static
- */
- function peek()
- {
- LoggerLog::debug("LoggerNDC::peek()");
-
- if (sizeof($GLOBALS['log4php.LoggerNDC.ht']) > 0) {
- return end($GLOBALS['log4php.LoggerNDC.ht']);
- } else {
- return '';
- }
- }
-
- /**
- * Push new diagnostic context information for the current thread.
- *
- * <p>The contents of the <var>message</var> parameter is
- * determined solely by the client.
- *
- * @param string $message The new diagnostic context information.
- * @static
- */
- function push($message)
- {
- LoggerLog::debug("LoggerNDC::push()");
-
- array_push($GLOBALS['log4php.LoggerNDC.ht'], (string)$message);
- }
-
- /**
- * Remove the diagnostic context for this thread.
- * @static
- */
- function remove()
- {
- LoggerLog::debug("LoggerNDC::remove()");
-
- LoggerNDC::clear();
- }
-
- /**
- * Set maximum depth of this diagnostic context. If the current
- * depth is smaller or equal to <var>maxDepth</var>, then no
- * action is taken.
- *
- * <p>This method is a convenient alternative to multiple
- * {@link pop()} calls. Moreover, it is often the case that at
- * the end of complex call sequences, the depth of the NDC is
- * unpredictable. The {@link setMaxDepth()} method circumvents
- * this problem.
- *
- * @param integer $maxDepth
- * @see getDepth()
- * @static
- */
- function setMaxDepth($maxDepth)
- {
- LoggerLog::debug("LoggerNDC::setMaxDepth() maxDepth='$maxDepth'");
-
- $maxDepth = (int)$maxDepth;
- if ($maxDepth <= LOGGER_NDC_HT_SIZE) {
- if (LoggerNDC::getDepth() > $maxDepth) {
- $GLOBALS['log4php.LoggerNDC.ht'] = array_slice($GLOBALS['log4php.LoggerNDC.ht'], $maxDepth);
- }
- $GLOBALS['log4php.LoggerNDC.maxDepth'] = $maxDepth;
- }
- }
-
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ */
+require_once(LOG4PHP_DIR . '/LoggerLog.php');
+
+define('LOGGER_NDC_HT_SIZE', 7);
+
+/**
+ * This is the global repository of NDC stack
+ */
+$GLOBALS['log4php.LoggerNDC.ht'] = array();
+
+/**
+ * This is the max depth of NDC stack
+ */
+$GLOBALS['log4php.LoggerNDC.maxDepth'] = LOGGER_NDC_HT_SIZE;
+
+
+/**
+ * The NDC class implements <i>nested diagnostic contexts</i> as
+ * defined by Neil Harrison in the article "Patterns for Logging
+ * Diagnostic Messages" part of the book "<i>Pattern Languages of
+ * Program Design 3</i>" edited by Martin et al.
+ *
+ * <p>A Nested Diagnostic Context, or NDC in short, is an instrument
+ * to distinguish interleaved log output from different sources. Log
+ * output is typically interleaved when a server handles multiple
+ * clients near-simultaneously.
+ *
+ * <p>Interleaved log output can still be meaningful if each log entry
+ * from different contexts had a distinctive stamp. This is where NDCs
+ * come into play.
+ *
+ * <p><i><b>Note that NDCs are managed on a per thread
+ * basis</b></i>. NDC operations such as {@link push()}, {@link pop()},
+ * {@link clear()}, {@link getDepth()} and {@link setMaxDepth()}
+ * affect the NDC of the <i>current</i> thread only. NDCs of other
+ * threads remain unaffected.
+ *
+ * <p>For example, a servlet can build a per client request NDC
+ * consisting the clients host name and other information contained in
+ * the the request. <i>Cookies</i> are another source of distinctive
+ * information. To build an NDC one uses the {@link push()}
+ * operation.</p>
+ *
+ * Simply put,
+ *
+ * - Contexts can be nested.
+ * - When entering a context, call
+ * <code>LoggerNDC::push()</code>
+ * As a side effect, if there is no nested diagnostic context for the
+ * current thread, this method will create it.
+ * - When leaving a context, call
+ * <code>LoggerNDC::pop()</code>
+ * - <b>When exiting a thread make sure to call {@link remove()}</b>
+ *
+ * <p>There is no penalty for forgetting to match each
+ * <code>push</code> operation with a corresponding <code>pop</code>,
+ * except the obvious mismatch between the real application context
+ * and the context set in the NDC.</p>
+ *
+ * <p>If configured to do so, {@link LoggerPatternLayout} and {@link LoggerLayoutTTCC}
+ * instances automatically retrieve the nested diagnostic
+ * context for the current thread without any user intervention.
+ * Hence, even if a servlet is serving multiple clients
+ * simultaneously, the logs emanating from the same code (belonging to
+ * the same category) can still be distinguished because each client
+ * request will have a different NDC tag.</p>
+ *
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.5 $
+ * @package log4php
+ * @since 0.3
+ */
+class LoggerNDC {
+
+ /**
+ * Clear any nested diagnostic information if any. This method is
+ * useful in cases where the same thread can be potentially used
+ * over and over in different unrelated contexts.
+ *
+ * <p>This method is equivalent to calling the {@link setMaxDepth()}
+ * method with a zero <var>maxDepth</var> argument.
+ *
+ * @static
+ */
+ function clear()
+ {
+ LoggerLog::debug("LoggerNDC::clear()");
+
+ $GLOBALS['log4php.LoggerNDC.ht'] = array();
+ }
+
+ /**
+ * Never use this method directly, use the {@link LoggerLoggingEvent::getNDC()} method instead.
+ * @static
+ * @return array
+ */
+ function get()
+ {
+ LoggerLog::debug("LoggerNDC::get()");
+
+ return $GLOBALS['log4php.LoggerNDC.ht'];
+ }
+
+ /**
+ * Get the current nesting depth of this diagnostic context.
+ *
+ * @see setMaxDepth()
+ * @return integer
+ * @static
+ */
+ function getDepth()
+ {
+ LoggerLog::debug("LoggerNDC::getDepth()");
+
+ return sizeof($GLOBALS['log4php.LoggerNDC.ht']);
+ }
+
+ /**
+ * Clients should call this method before leaving a diagnostic
+ * context.
+ *
+ * <p>The returned value is the value that was pushed last. If no
+ * context is available, then the empty string "" is returned.</p>
+ *
+ * @return string The innermost diagnostic context.
+ * @static
+ */
+ function pop()
+ {
+ LoggerLog::debug("LoggerNDC::pop()");
+
+ if (sizeof($GLOBALS['log4php.LoggerNDC.ht']) > 0) {
+ return array_pop($GLOBALS['log4php.LoggerNDC.ht']);
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Looks at the last diagnostic context at the top of this NDC
+ * without removing it.
+ *
+ * <p>The returned value is the value that was pushed last. If no
+ * context is available, then the empty string "" is returned.</p>
+ * @return string The innermost diagnostic context.
+ * @static
+ */
+ function peek()
+ {
+ LoggerLog::debug("LoggerNDC::peek()");
+
+ if (sizeof($GLOBALS['log4php.LoggerNDC.ht']) > 0) {
+ return end($GLOBALS['log4php.LoggerNDC.ht']);
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Push new diagnostic context information for the current thread.
+ *
+ * <p>The contents of the <var>message</var> parameter is
+ * determined solely by the client.
+ *
+ * @param string $message The new diagnostic context information.
+ * @static
+ */
+ function push($message)
+ {
+ LoggerLog::debug("LoggerNDC::push()");
+
+ array_push($GLOBALS['log4php.LoggerNDC.ht'], (string)$message);
+ }
+
+ /**
+ * Remove the diagnostic context for this thread.
+ * @static
+ */
+ function remove()
+ {
+ LoggerLog::debug("LoggerNDC::remove()");
+
+ LoggerNDC::clear();
+ }
+
+ /**
+ * Set maximum depth of this diagnostic context. If the current
+ * depth is smaller or equal to <var>maxDepth</var>, then no
+ * action is taken.
+ *
+ * <p>This method is a convenient alternative to multiple
+ * {@link pop()} calls. Moreover, it is often the case that at
+ * the end of complex call sequences, the depth of the NDC is
+ * unpredictable. The {@link setMaxDepth()} method circumvents
+ * this problem.
+ *
+ * @param integer $maxDepth
+ * @see getDepth()
+ * @static
+ */
+ function setMaxDepth($maxDepth)
+ {
+ LoggerLog::debug("LoggerNDC::setMaxDepth() maxDepth='$maxDepth'");
+
+ $maxDepth = (int)$maxDepth;
+ if ($maxDepth <= LOGGER_NDC_HT_SIZE) {
+ if (LoggerNDC::getDepth() > $maxDepth) {
+ $GLOBALS['log4php.LoggerNDC.ht'] = array_slice($GLOBALS['log4php.LoggerNDC.ht'], $maxDepth);
+ }
+ $GLOBALS['log4php.LoggerNDC.maxDepth'] = $maxDepth;
+ }
+ }
+
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerPropertyConfigurator.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerPropertyConfigurator.php (original)
+++ vtigercrm/trunk/log4php/LoggerPropertyConfigurator.php Wed May 3 22:07:13 2006
@@ -1,654 +1,650 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-require_once(LOG4PHP_DIR . '/config/LoggerPropertySetter.php');
-require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php');
-require_once(LOG4PHP_DIR . '/or/LoggerObjectRenderer.php');
-require_once(LOG4PHP_DIR . '/or/LoggerRendererMap.php');
-require_once(LOG4PHP_DIR . '/spi/LoggerConfigurator.php');
-require_once(LOG4PHP_DIR . '/spi/LoggerFilter.php');
-require_once(LOG4PHP_DIR . '/LoggerAppender.php');
-require_once(LOG4PHP_DIR . '/LoggerDefaultCategoryFactory.php');
-require_once(LOG4PHP_DIR . '/LoggerLayout.php');
-require_once(LOG4PHP_DIR . '/LoggerLevel.php');
-require_once(LOG4PHP_DIR . '/LoggerManager.php');
-
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX', "log4php.category.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX', "log4php.logger.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_FACTORY_PREFIX', "log4php.factory");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX', "log4php.additivity.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX', "log4php.rootCategory");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX', "log4php.rootLogger");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX', "log4php.appender.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX', "log4php.renderer.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX', "log4php.threshold");
-
-/**
- * Key for specifying the {@link LoggerFactory}.
- */
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY', "log4php.loggerFactory");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY', "log4php.debug");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME', "root");
-
-
-
-/**
- * Allows the configuration of log4php from an external file.
- *
- * See {@link doConfigure()} for the expected format.
- *
- * <p>It is sometimes useful to see how log4php is reading configuration
- * files. You can enable log4php internal logging by defining the
- * <b>log4php.debug</b> variable.</p>
- *
- * <p>The <i>LoggerPropertyConfigurator</i> does not handle the
- * advanced configuration features supported by the {@link LoggerDOMConfigurator}
- * such as support for {@link LoggerFilter},
- custom {@link LoggerErrorHandlers}, nested appenders such as the
- {@link Logger AsyncAppender},
- * etc.
- *
- * <p>All option <i>values</i> admit variable substitution. The
- * syntax of variable substitution is similar to that of Unix
- * shells. The string between an opening <b>"${"</b> and
- * closing <b>"}"</b> is interpreted as a key. The value of
- * the substituted variable can be defined as a system property or in
- * the configuration file itself. The value of the key is first
- * searched in the defined constants, in the enviroments variables
- * and if not found there, it is
- * then searched in the configuration file being parsed. The
- * corresponding value replaces the ${variableName} sequence.</p>
- * <p>For example, if <b>$_ENV['home']</b> env var is set to
- * <b>/home/xyz</b>, then every occurrence of the sequence
- * <b>${home}</b> will be interpreted as
- * <b>/home/xyz</b>. See {@link LoggerOptionConverter::getSystemProperty()}
- * for details.</p>
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @since 0.5
- */
-class LoggerPropertyConfigurator extends LoggerConfigurator {
-
- /**
- * @var LoggerFactory
- */
- var $loggerFactory = null;
-
- /**
- * Constructor
- */
- function LoggerPropertyConfigurator()
- {
- $this->loggerFactory = new LoggerDefaultCategoryFactory();
- }
-
- /**
- * Configure the default repository using the resource pointed by <b>url</b>.
- * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function.
- * Note that the resource will be search with <i>use_include_path</i> parameter
- * set to "1".
- *
- * @param string $url
- * @return boolean configuration result
- * @static
- */
- function configure($url = '')
- {
- $configurator = new LoggerPropertyConfigurator();
- $repository =& LoggerManager::getLoggerRepository();
- return $configurator->doConfigure($url, $repository);
- }
-
- /**
- * Read configuration from a file.
- *
- * <p>The function {@link PHP_MANUAL#parse_ini_file} is used to read the
- * file.</p>
- *
- * <b>The existing configuration is not cleared nor reset.</b>
- * If you require a different behavior, then call
- * {@link LoggerManager::resetConfiguration()}
- * method before calling {@link doConfigure()}.
- *
- * <p>The configuration file consists of statements in the format
- * <b>key=value</b>. The syntax of different configuration
- * elements are discussed below.
- *
- * <p><b>Repository-wide threshold</b></p>
- *
- * <p>The repository-wide threshold filters logging requests by level
- * regardless of logger. The syntax is:
- *
- * <pre>
- * log4php.threshold=[level]
- * </pre>
- *
- * <p>The level value can consist of the string values OFF, FATAL,
- * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A
- * custom level value can be specified in the form
- * <samp>level#classname</samp>. By default the repository-wide threshold is set
- * to the lowest possible value, namely the level <b>ALL</b>.
- * </p>
- *
- *
- * <p><b>Appender configuration</b></p>
- *
- * <p>Appender configuration syntax is:</p>
- * <pre>
- * ; For appender named <i>appenderName</i>, set its class.
- * ; Note: The appender name can contain dots.
- * log4php.appender.appenderName=name_of_appender_class
- *
- * ; Set appender specific options.
- *
- * log4php.appender.appenderName.option1=value1
- * log4php.appender.appenderName.optionN=valueN
- * </pre>
- *
- * For each named appender you can configure its {@link LoggerLayout}. The
- * syntax for configuring an appender's layout is:
- * <pre>
- * log4php.appender.appenderName.layout=name_of_layout_class
- * log4php.appender.appenderName.layout.option1=value1
- * ....
- * log4php.appender.appenderName.layout.optionN=valueN
- * </pre>
- *
- * <p><b>Configuring loggers</b></p>
- *
- * <p>The syntax for configuring the root logger is:
- * <pre>
- * log4php.rootLogger=[level], appenderName, appenderName, ...
- * </pre>
- *
- * <p>This syntax means that an optional <i>level</i> can be
- * supplied followed by appender names separated by commas.
- *
- * <p>The level value can consist of the string values OFF, FATAL,
- * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A
- * custom level value can be specified in the form</p>
- *
- * <pre>level#classname</pre>
- *
- * <p>If a level value is specified, then the root level is set
- * to the corresponding level. If no level value is specified,
- * then the root level remains untouched.
- *
- * <p>The root logger can be assigned multiple appenders.
- *
- * <p>Each <i>appenderName</i> (separated by commas) will be added to
- * the root logger. The named appender is defined using the
- * appender syntax defined above.
- *
- * <p>For non-root categories the syntax is almost the same:
- * <pre>
- * log4php.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ...
- * </pre>
- *
- * <p>The meaning of the optional level value is discussed above
- * in relation to the root logger. In addition however, the value
- * INHERITED can be specified meaning that the named logger should
- * inherit its level from the logger hierarchy.</p>
- *
- * <p>If no level value is supplied, then the level of the
- * named logger remains untouched.</p>
- *
- * <p>By default categories inherit their level from the
- * hierarchy. However, if you set the level of a logger and later
- * decide that that logger should inherit its level, then you should
- * specify INHERITED as the value for the level value. NULL is a
- * synonym for INHERITED.</p>
- *
- * <p>Similar to the root logger syntax, each <i>appenderName</i>
- * (separated by commas) will be attached to the named logger.</p>
- *
- * <p>See the <i>appender additivity rule</i> in the user manual for
- * the meaning of the <b>additivity</b> flag.
- *
- * <p><b>ObjectRenderers</b></p>
- *
- * <p>You can customize the way message objects of a given type are
- * converted to String before being logged. This is done by
- * specifying a {@link LoggerObjectRenderer}
- * for the object type would like to customize.</p>
- *
- * <p>The syntax is:
- *
- * <pre>
- * log4php.renderer.name_of_rendered_class=name_of_rendering.class
- * </pre>
- *
- * As in,
- * <pre>
- * log4php.renderer.myFruit=myFruitRenderer
- * </pre>
- *
- * <p><b>Logger Factories</b></p>
- *
- * The usage of custom logger factories is discouraged and no longer
- * documented.
- *
- * <p><b>Example</b></p>
- *
- * <p>An example configuration is given below. Other configuration
- * file examples are given in the <b>tests</b> folder.
- *
- * <pre>
- * ; Set options for appender named "A1".
- * ; Appender "A1" will be a SyslogAppender
- * log4php.appender.A1=SyslogAppender
- *
- * ; The syslog daemon resides on www.abc.net
- * log4php.appender.A1.SyslogHost=www.abc.net
- *
- * ; A1's layout is a LoggerPatternLayout, using the conversion pattern
- * ; <b>%r %-5p %c{2} %M.%L %x - %m%n</b>. Thus, the log output will
- * ; include the relative time since the start of the application in
- * ; milliseconds, followed by the level of the log request,
- * ; followed by the two rightmost components of the logger name,
- * ; followed by the callers method name, followed by the line number,
- * ; the nested disgnostic context and finally the message itself.
- * ; Refer to the documentation of LoggerPatternLayout} for further information
- * ; on the syntax of the ConversionPattern key.
- * log4php.appender.A1.layout=LoggerPatternLayout
- * log4php.appender.A1.layout.ConversionPattern="%-4r %-5p %c{2} %M.%L %x - %m%n"
- *
- * ; Set options for appender named "A2"
- * ; A2 should be a LoggerAppenderRollingFile, with maximum file size of 10 MB
- * ; using at most one backup file. A2's layout is TTCC, using the
- * ; ISO8061 date format with context printing enabled.
- * log4php.appender.A2=LoggerAppenderRollingFile
- * log4php.appender.A2.MaxFileSize=10MB
- * log4php.appender.A2.MaxBackupIndex=1
- * log4php.appender.A2.layout=LoggerLayoutTTCC
- * log4php.appender.A2.layout.ContextPrinting="true"
- * log4php.appender.A2.layout.DateFormat="%c"
- *
- * ; Root logger set to DEBUG using the A2 appender defined above.
- * log4php.rootLogger=DEBUG, A2
- *
- * ; Logger definitions:
- * ; The SECURITY logger inherits is level from root. However, it's output
- * ; will go to A1 appender defined above. It's additivity is non-cumulative.
- * log4php.logger.SECURITY=INHERIT, A1
- * log4php.additivity.SECURITY=false
- *
- * ; Only warnings or above will be logged for the logger "SECURITY.access".
- * ; Output will go to A1.
- * log4php.logger.SECURITY.access=WARN
- *
- *
- * ; The logger "class.of.the.day" inherits its level from the
- * ; logger hierarchy. Output will go to the appender's of the root
- * ; logger, A2 in this case.
- * log4php.logger.class.of.the.day=INHERIT
- * </pre>
- *
- * <p>Refer to the <b>setOption</b> method in each Appender and
- * Layout for class specific options.</p>
- *
- * <p>Use the <b>";"</b> character at the
- * beginning of a line for comments.</p>
- *
- * @param string $url The name of the configuration file where the
- * configuration information is stored.
- * @param LoggerHierarchy &$repository the repository to apply the configuration
- */
- function doConfigure($url, &$repository)
- {
- $properties = @parse_ini_file($url);
- if ($properties === false) {
- LoggerLog::warn("LoggerPropertyConfigurator::doConfigure() cannot load '$url' configuration.");
- return false;
- }
- return $this->doConfigureProperties($properties, $repository);
- }
-
-
- /**
- * Read configuration options from <b>properties</b>.
- *
- * @see doConfigure().
- * @param array $properties
- * @param LoggerHierarchy &$hierarchy
- */
- function doConfigureProperties($properties, &$hierarchy)
- {
- if(array_key_exists(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY, $properties))
- $value = @$properties[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY];
-
- if (!empty($value)) {
- LoggerLog::internalDebugging(LoggerOptionConverter::toBoolean($value, LoggerLog::internalDebugging()));
- }
-
- $thresholdStr = null;
- if(array_key_exists(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX, $properties))
- $thresholdStr = @$properties[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX];
- $hierarchy->setThreshold(LoggerOptionConverter::toLevel($thresholdStr, LoggerLevel::getLevelAll()));
-
- $this->configureRootCategory($properties, $hierarchy);
- $this->configureLoggerFactory($properties);
- $this->parseCatsAndRenderers($properties, $hierarchy);
-
- LoggerLog::debug("LoggerPropertyConfigurator::doConfigureProperties() Finished configuring.");
-
- return true;
- }
-
- // --------------------------------------------------------------------------
- // Internal stuff
- // --------------------------------------------------------------------------
-
- /**
- * Check the provided <b>Properties</b> object for a
- * {@link LoggerFactory} entry specified by
- * {@link LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY}.
- *
- * If such an entry exists, an attempt is made to create an instance using
- * the default constructor.
- * This instance is used for subsequent Category creations
- * within this configurator.
- *
- * @see parseCatsAndRenderers()
- * @param array $props array of properties
- */
- function configureLoggerFactory($props)
- {
- if(array_key_exists(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY, $props))
- $factoryFqcn = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY];
- if(!empty($factoryFqcn)) {
- $factoryClassName = basename($factoryFqcn);
- LoggerLog::debug(
- "LoggerPropertyConfigurator::configureLoggerFactory() Trying to load factory [" .
- $factoryClassName .
- "]."
- );
-
- if (!class_exists($factoryClassName))
- @include_once("{$factoryFqcn}.php");
- if (class_exists($factoryClassName)) {
- $loggerFactory = new $factoryClassName();
- } else {
- LoggerLog::debug(
- "LoggerPropertyConfigurator::configureLoggerFactory() Unable to load factory [" .
- $factoryClassName .
- "]. Using default."
- );
- $loggerFactory = $this->loggerFactory;
- }
-
- LoggerLog::debug(
- "LoggerPropertyConfigurator::configureLoggerFactory() ".
- "Setting properties for category factory [" . get_class($loggerFactory) . "]."
- );
-
- LoggerPropertySetter::setPropertiesByObject($loggerFactory, $props, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_FACTORY_PREFIX . ".");
- }
- }
-
- /**
- * @param array $props array of properties
- * @param LoggerHierarchy &$hierarchy
- */
- function configureRootCategory($props, &$hierarchy)
- {
- $effectivePrefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX;
- $value = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX];
-
- if(empty($value)) {
- $value = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX];
- $effectivePrefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX;
- }
-
- if (empty($value)) {
- LoggerLog::debug(
- "LoggerPropertyConfigurator::configureRootCategory() ".
- "Could not find root logger information. Is this OK?"
- );
- } else {
- $root =& $hierarchy->getRootLogger();
- // synchronized(root) {
- $this->parseCategory(
- $props,
- $root,
- $effectivePrefix,
- LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME,
- $value
- );
- // }
- }
- }
-
- /**
- * Parse non-root elements, such non-root categories and renderers.
- *
- * @param array $props array of properties
- * @param LoggerHierarchy &$hierarchy
- */
- function parseCatsAndRenderers($props, &$hierarchy)
- {
- while(list($key,$value) = each($props)) {
- if( strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0 or
- strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) {
- if(strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0) {
- $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX));
- } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) {
- $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX));
- }
- $logger =& $hierarchy->getLogger($loggerName, $this->loggerFactory);
- // synchronized(logger) {
- $this->parseCategory($props, $logger, $key, $loggerName, $value);
- $this->parseAdditivityForLogger($props, $logger, $loggerName);
- // }
- } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX) === 0) {
- $renderedClass = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX));
- $renderingClass = $value;
- if (method_exists($hierarchy, 'addrenderer')) {
- LoggerRendererMap::addRenderer($hierarchy, $renderedClass, $renderingClass);
- }
- }
- }
- }
-
- /**
- * Parse the additivity option for a non-root category.
- *
- * @param array $props array of properties
- * @param Logger &$cat
- * @param string $loggerName
- */
- function parseAdditivityForLogger($props, &$cat, $loggerName)
- {
- $value = LoggerOptionConverter::findAndSubst(
- LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName,
- $props
- );
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseAdditivityForLogger() ".
- "Handling " . LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName . "=[{$value}]"
- );
- // touch additivity only if necessary
- if(!empty($value)) {
- $additivity = LoggerOptionConverter::toBoolean($value, true);
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseAdditivityForLogger() ".
- "Setting additivity for [{$loggerName}] to [{$additivity}]"
- );
- $cat->setAdditivity($additivity);
- }
- }
-
- /**
- * This method must work for the root category as well.
- *
- * @param array $props array of properties
- * @param Logger &$logger
- * @param string $optionKey
- * @param string $loggerName
- * @param string $value
- * @return Logger
- */
- function &parseCategory($props, &$logger, $optionKey, $loggerName, $value)
- {
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseCategory() ".
- "Parsing for [{$loggerName}] with value=[{$value}]."
- );
-
- // We must skip over ',' but not white space
- $st = explode(',', $value);
-
- // If value is not in the form ", appender.." or "", then we should set
- // the level of the loggeregory.
-
- if(!(@$value{0} == ',' || empty($value))) {
- // just to be on the safe side...
- if(sizeof($st) == 0)
- return;
-
- $levelStr = current($st);
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseCategory() ".
- "Level token is [$levelStr]."
- );
-
- // If the level value is inherited, set category level value to
- // null. We also check that the user has not specified inherited for the
- // root category.
- if('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) {
- if ($loggerName == LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME) {
- LoggerLog::warn(
- "LoggerPropertyConfigurator::parseCategory() ".
- "The root logger cannot be set to null."
- );
- } else {
- $logger->setLevel(null);
- }
- } else {
- $logger->setLevel(LoggerOptionConverter::toLevel($levelStr, LoggerLevel::getLevelDebug()));
- }
- }
-
- // Begin by removing all existing appenders.
- $logger->removeAllAppenders();
- while($appenderName = next($st)) {
- $appenderName = trim($appenderName);
- if(empty($appenderName))
- continue;
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseCategory() ".
- "Parsing appender named [{$appenderName}]."
- );
- $appender =& $this->parseAppender($props, $appenderName);
- if($appender !== null) {
- $logger->addAppender($appender);
- }
- }
- }
-
- /**
- * @param array $props array of properties
- * @param string $appenderName
- * @return LoggerAppender
- */
- function &parseAppender($props, $appenderName)
- {
- $appender =& LoggerAppender::singleton($appenderName);
- if($appender !== null) {
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseAppender() ".
- "Appender [{$appenderName}] was already parsed."
- );
- return $appender;
- }
- // Appender was not previously initialized.
- $prefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX . $appenderName;
- $layoutPrefix = $prefix . ".layout";
- $appenderClass = @$props[$prefix];
- if (!empty($appenderClass)) {
- $appender =& LoggerAppender::singleton($appenderName, $appenderClass);
- if($appender === null) {
- LoggerLog::warn(
- "LoggerPropertyConfigurator::parseAppender() ".
- "Could not instantiate appender named [$appenderName]."
- );
- return null;
- }
- } else {
- LoggerLog::warn(
- "LoggerPropertyConfigurator::parseAppender() ".
- "Could not instantiate appender named [$appenderName] with null className."
- );
- return null;
- }
-
- $appender->setName($appenderName);
- if( $appender->requiresLayout() ) {
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseAppender() ".
- "Parsing layout section for [$appenderName]."
- );
- $layoutClass = @$props[$layoutPrefix];
- $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props);
- if (empty($layoutClass)) {
- LoggerLog::warn(
- "LoggerPropertyConfigurator::parseAppender() ".
- "layout class is empty in '$layoutPrefix'. Using Simple layout"
- );
- $layout = LoggerLayout::factory('LoggerLayoutSimple');
- } else {
- $layout = LoggerLayout::factory($layoutClass);
-
- if($layout === null) {
- LoggerLog::warn(
- "LoggerPropertyConfigurator::parseAppender() ".
- "cannot create layout '$layoutClass'. Using Simple layout"
- );
- $layout = LoggerLayout::factory('LoggerLayoutSimple');
- }
- }
-
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseAppender() ".
- "Parsing layout options for [$appenderName]."
- );
- LoggerPropertySetter::setPropertiesByObject($layout, $props, $layoutPrefix . ".");
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseAppender() ".
- "End Parsing layout options for [$appenderName]."
- );
- $appender->setLayout($layout);
-
- }
- LoggerPropertySetter::setPropertiesByObject($appender, $props, $prefix . ".");
- LoggerLog::debug(
- "LoggerPropertyConfigurator::parseAppender() ".
- "Parsed [{$appenderName}] options."
- );
- return $appender;
- }
-
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+require_once(LOG4PHP_DIR . '/config/LoggerPropertySetter.php');
+require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php');
+require_once(LOG4PHP_DIR . '/or/LoggerObjectRenderer.php');
+require_once(LOG4PHP_DIR . '/or/LoggerRendererMap.php');
+require_once(LOG4PHP_DIR . '/spi/LoggerConfigurator.php');
+require_once(LOG4PHP_DIR . '/spi/LoggerFilter.php');
+require_once(LOG4PHP_DIR . '/LoggerAppender.php');
+require_once(LOG4PHP_DIR . '/LoggerDefaultCategoryFactory.php');
+require_once(LOG4PHP_DIR . '/LoggerLayout.php');
+require_once(LOG4PHP_DIR . '/LoggerLevel.php');
+require_once(LOG4PHP_DIR . '/LoggerManager.php');
+
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX', "log4php.category.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX', "log4php.logger.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_FACTORY_PREFIX', "log4php.factory");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX', "log4php.additivity.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX', "log4php.rootCategory");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX', "log4php.rootLogger");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX', "log4php.appender.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX', "log4php.renderer.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX', "log4php.threshold");
+
+/**
+ * Key for specifying the {@link LoggerFactory}.
+ */
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY', "log4php.loggerFactory");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY', "log4php.debug");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME', "root");
+
+
+
+/**
+ * Allows the configuration of log4php from an external file.
+ *
+ * See {@link doConfigure()} for the expected format.
+ *
+ * <p>It is sometimes useful to see how log4php is reading configuration
+ * files. You can enable log4php internal logging by defining the
+ * <b>log4php.debug</b> variable.</p>
+ *
+ * <p>The <i>LoggerPropertyConfigurator</i> does not handle the
+ * advanced configuration features supported by the {@link LoggerDOMConfigurator}
+ * such as support for {@link LoggerFilter},
+ custom {@link LoggerErrorHandlers}, nested appenders such as the
+ {@link Logger AsyncAppender},
+ * etc.
+ *
+ * <p>All option <i>values</i> admit variable substitution. The
+ * syntax of variable substitution is similar to that of Unix
+ * shells. The string between an opening <b>"${"</b> and
+ * closing <b>"}"</b> is interpreted as a key. The value of
+ * the substituted variable can be defined as a system property or in
+ * the configuration file itself. The value of the key is first
+ * searched in the defined constants, in the enviroments variables
+ * and if not found there, it is
+ * then searched in the configuration file being parsed. The
+ * corresponding value replaces the ${variableName} sequence.</p>
+ * <p>For example, if <b>$_ENV['home']</b> env var is set to
+ * <b>/home/xyz</b>, then every occurrence of the sequence
+ * <b>${home}</b> will be interpreted as
+ * <b>/home/xyz</b>. See {@link LoggerOptionConverter::getSystemProperty()}
+ * for details.</p>
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.6 $
+ * @package log4php
+ * @since 0.5
+ */
+class LoggerPropertyConfigurator extends LoggerConfigurator {
+
+ /**
+ * @var LoggerFactory
+ */
+ var $loggerFactory = null;
+
+ /**
+ * Constructor
+ */
+ function LoggerPropertyConfigurator()
+ {
+ $this->loggerFactory = new LoggerDefaultCategoryFactory();
+ }
+
+ /**
+ * Configure the default repository using the resource pointed by <b>url</b>.
+ * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function.
+ * Note that the resource will be search with <i>use_include_path</i> parameter
+ * set to "1".
+ *
+ * @param string $url
+ * @return boolean configuration result
+ * @static
+ */
+ function configure($url = '')
+ {
+ $configurator = new LoggerPropertyConfigurator();
+ $repository =& LoggerManager::getLoggerRepository();
+ return $configurator->doConfigure($url, $repository);
+ }
+
+ /**
+ * Read configuration from a file.
+ *
+ * <p>The function {@link PHP_MANUAL#parse_ini_file} is used to read the
+ * file.</p>
+ *
+ * <b>The existing configuration is not cleared nor reset.</b>
+ * If you require a different behavior, then call
+ * {@link LoggerManager::resetConfiguration()}
+ * method before calling {@link doConfigure()}.
+ *
+ * <p>The configuration file consists of statements in the format
+ * <b>key=value</b>. The syntax of different configuration
+ * elements are discussed below.
+ *
+ * <p><b>Repository-wide threshold</b></p>
+ *
+ * <p>The repository-wide threshold filters logging requests by level
+ * regardless of logger. The syntax is:
+ *
+ * <pre>
+ * log4php.threshold=[level]
+ * </pre>
+ *
+ * <p>The level value can consist of the string values OFF, FATAL,
+ * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A
+ * custom level value can be specified in the form
+ * <samp>level#classname</samp>. By default the repository-wide threshold is set
+ * to the lowest possible value, namely the level <b>ALL</b>.
+ * </p>
+ *
+ *
+ * <p><b>Appender configuration</b></p>
+ *
+ * <p>Appender configuration syntax is:</p>
+ * <pre>
+ * ; For appender named <i>appenderName</i>, set its class.
+ * ; Note: The appender name can contain dots.
+ * log4php.appender.appenderName=name_of_appender_class
+ *
+ * ; Set appender specific options.
+ *
+ * log4php.appender.appenderName.option1=value1
+ * log4php.appender.appenderName.optionN=valueN
+ * </pre>
+ *
+ * For each named appender you can configure its {@link LoggerLayout}. The
+ * syntax for configuring an appender's layout is:
+ * <pre>
+ * log4php.appender.appenderName.layout=name_of_layout_class
+ * log4php.appender.appenderName.layout.option1=value1
+ * ....
+ * log4php.appender.appenderName.layout.optionN=valueN
+ * </pre>
+ *
+ * <p><b>Configuring loggers</b></p>
+ *
+ * <p>The syntax for configuring the root logger is:
+ * <pre>
+ * log4php.rootLogger=[level], appenderName, appenderName, ...
+ * </pre>
+ *
+ * <p>This syntax means that an optional <i>level</i> can be
+ * supplied followed by appender names separated by commas.
+ *
+ * <p>The level value can consist of the string values OFF, FATAL,
+ * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A
+ * custom level value can be specified in the form</p>
+ *
+ * <pre>level#classname</pre>
+ *
+ * <p>If a level value is specified, then the root level is set
+ * to the corresponding level. If no level value is specified,
+ * then the root level remains untouched.
+ *
+ * <p>The root logger can be assigned multiple appenders.
+ *
+ * <p>Each <i>appenderName</i> (separated by commas) will be added to
+ * the root logger. The named appender is defined using the
+ * appender syntax defined above.
+ *
+ * <p>For non-root categories the syntax is almost the same:
+ * <pre>
+ * log4php.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ...
+ * </pre>
+ *
+ * <p>The meaning of the optional level value is discussed above
+ * in relation to the root logger. In addition however, the value
+ * INHERITED can be specified meaning that the named logger should
+ * inherit its level from the logger hierarchy.</p>
+ *
+ * <p>If no level value is supplied, then the level of the
+ * named logger remains untouched.</p>
+ *
+ * <p>By default categories inherit their level from the
+ * hierarchy. However, if you set the level of a logger and later
+ * decide that that logger should inherit its level, then you should
+ * specify INHERITED as the value for the level value. NULL is a
+ * synonym for INHERITED.</p>
+ *
+ * <p>Similar to the root logger syntax, each <i>appenderName</i>
+ * (separated by commas) will be attached to the named logger.</p>
+ *
+ * <p>See the <i>appender additivity rule</i> in the user manual for
+ * the meaning of the <b>additivity</b> flag.
+ *
+ * <p><b>ObjectRenderers</b></p>
+ *
+ * <p>You can customize the way message objects of a given type are
+ * converted to String before being logged. This is done by
+ * specifying a {@link LoggerObjectRenderer}
+ * for the object type would like to customize.</p>
+ *
+ * <p>The syntax is:
+ *
+ * <pre>
+ * log4php.renderer.name_of_rendered_class=name_of_rendering.class
+ * </pre>
+ *
+ * As in,
+ * <pre>
+ * log4php.renderer.myFruit=myFruitRenderer
+ * </pre>
+ *
+ * <p><b>Logger Factories</b></p>
+ *
+ * The usage of custom logger factories is discouraged and no longer
+ * documented.
+ *
+ * <p><b>Example</b></p>
+ *
+ * <p>An example configuration is given below. Other configuration
+ * file examples are given in the <b>tests</b> folder.
+ *
+ * <pre>
+ * ; Set options for appender named "A1".
+ * ; Appender "A1" will be a SyslogAppender
+ * log4php.appender.A1=SyslogAppender
+ *
+ * ; The syslog daemon resides on www.abc.net
+ * log4php.appender.A1.SyslogHost=www.abc.net
+ *
+ * ; A1's layout is a LoggerPatternLayout, using the conversion pattern
+ * ; <b>%r %-5p %c{2} %M.%L %x - %m%n</b>. Thus, the log output will
+ * ; include the relative time since the start of the application in
+ * ; milliseconds, followed by the level of the log request,
+ * ; followed by the two rightmost components of the logger name,
+ * ; followed by the callers method name, followed by the line number,
+ * ; the nested disgnostic context and finally the message itself.
+ * ; Refer to the documentation of LoggerPatternLayout} for further information
+ * ; on the syntax of the ConversionPattern key.
+ * log4php.appender.A1.layout=LoggerPatternLayout
+ * log4php.appender.A1.layout.ConversionPattern="%-4r %-5p %c{2} %M.%L %x - %m%n"
+ *
+ * ; Set options for appender named "A2"
+ * ; A2 should be a LoggerAppenderRollingFile, with maximum file size of 10 MB
+ * ; using at most one backup file. A2's layout is TTCC, using the
+ * ; ISO8061 date format with context printing enabled.
+ * log4php.appender.A2=LoggerAppenderRollingFile
+ * log4php.appender.A2.MaxFileSize=10MB
+ * log4php.appender.A2.MaxBackupIndex=1
+ * log4php.appender.A2.layout=LoggerLayoutTTCC
+ * log4php.appender.A2.layout.ContextPrinting="true"
+ * log4php.appender.A2.layout.DateFormat="%c"
+ *
+ * ; Root logger set to DEBUG using the A2 appender defined above.
+ * log4php.rootLogger=DEBUG, A2
+ *
+ * ; Logger definitions:
+ * ; The SECURITY logger inherits is level from root. However, it's output
+ * ; will go to A1 appender defined above. It's additivity is non-cumulative.
+ * log4php.logger.SECURITY=INHERIT, A1
+ * log4php.additivity.SECURITY=false
+ *
+ * ; Only warnings or above will be logged for the logger "SECURITY.access".
+ * ; Output will go to A1.
+ * log4php.logger.SECURITY.access=WARN
+ *
+ *
+ * ; The logger "class.of.the.day" inherits its level from the
+ * ; logger hierarchy. Output will go to the appender's of the root
+ * ; logger, A2 in this case.
+ * log4php.logger.class.of.the.day=INHERIT
+ * </pre>
+ *
+ * <p>Refer to the <b>setOption</b> method in each Appender and
+ * Layout for class specific options.</p>
+ *
+ * <p>Use the <b>";"</b> character at the
+ * beginning of a line for comments.</p>
+ *
+ * @param string $url The name of the configuration file where the
+ * configuration information is stored.
+ * @param LoggerHierarchy &$repository the repository to apply the configuration
+ */
+ function doConfigure($url, &$repository)
+ {
+ $properties = @parse_ini_file($url);
+ if ($properties === false) {
+ LoggerLog::warn("LoggerPropertyConfigurator::doConfigure() cannot load '$url' configuration.");
+ return false;
+ }
+ return $this->doConfigureProperties($properties, $repository);
+ }
+
+
+ /**
+ * Read configuration options from <b>properties</b>.
+ *
+ * @see doConfigure().
+ * @param array $properties
+ * @param LoggerHierarchy &$hierarchy
+ */
+ function doConfigureProperties($properties, &$hierarchy)
+ {
+ $value = @$properties[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY];
+
+ if (!empty($value)) {
+ LoggerLog::internalDebugging(LoggerOptionConverter::toBoolean($value, LoggerLog::internalDebugging()));
+ }
+
+ $thresholdStr = @$properties[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX];
+ $hierarchy->setThreshold(LoggerOptionConverter::toLevel($thresholdStr, LoggerLevel::getLevelAll()));
+
+ $this->configureRootCategory($properties, $hierarchy);
+ $this->configureLoggerFactory($properties);
+ $this->parseCatsAndRenderers($properties, $hierarchy);
+
+ LoggerLog::debug("LoggerPropertyConfigurator::doConfigureProperties() Finished configuring.");
+
+ return true;
+ }
+
+ // --------------------------------------------------------------------------
+ // Internal stuff
+ // --------------------------------------------------------------------------
+
+ /**
+ * Check the provided <b>Properties</b> object for a
+ * {@link LoggerFactory} entry specified by
+ * {@link LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY}.
+ *
+ * If such an entry exists, an attempt is made to create an instance using
+ * the default constructor.
+ * This instance is used for subsequent Category creations
+ * within this configurator.
+ *
+ * @see parseCatsAndRenderers()
+ * @param array $props array of properties
+ */
+ function configureLoggerFactory($props)
+ {
+ $factoryFqcn = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY];
+ if(!empty($factoryFqcn)) {
+ $factoryClassName = basename($factoryFqcn);
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::configureLoggerFactory() Trying to load factory [" .
+ $factoryClassName .
+ "]."
+ );
+
+ if (!class_exists($factoryClassName))
+ @include_once("{$factoryFqcn}.php");
+ if (class_exists($factoryClassName)) {
+ $loggerFactory = new $factoryClassName();
+ } else {
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::configureLoggerFactory() Unable to load factory [" .
+ $factoryClassName .
+ "]. Using default."
+ );
+ $loggerFactory = $this->loggerFactory;
+ }
+
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::configureLoggerFactory() ".
+ "Setting properties for category factory [" . get_class($loggerFactory) . "]."
+ );
+
+ LoggerPropertySetter::setPropertiesByObject($loggerFactory, $props, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_FACTORY_PREFIX . ".");
+ }
+ }
+
+ /**
+ * @param array $props array of properties
+ * @param LoggerHierarchy &$hierarchy
+ */
+ function configureRootCategory($props, &$hierarchy)
+ {
+ $effectivePrefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX;
+ $value = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX];
+
+ if(empty($value)) {
+ $value = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX];
+ $effectivePrefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX;
+ }
+
+ if (empty($value)) {
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::configureRootCategory() ".
+ "Could not find root logger information. Is this OK?"
+ );
+ } else {
+ $root =& $hierarchy->getRootLogger();
+ // synchronized(root) {
+ $this->parseCategory(
+ $props,
+ $root,
+ $effectivePrefix,
+ LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME,
+ $value
+ );
+ // }
+ }
+ }
+
+ /**
+ * Parse non-root elements, such non-root categories and renderers.
+ *
+ * @param array $props array of properties
+ * @param LoggerHierarchy &$hierarchy
+ */
+ function parseCatsAndRenderers($props, &$hierarchy)
+ {
+ while(list($key,$value) = each($props)) {
+ if( strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0 or
+ strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) {
+ if(strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0) {
+ $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX));
+ } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) {
+ $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX));
+ }
+ $logger =& $hierarchy->getLogger($loggerName, $this->loggerFactory);
+ // synchronized(logger) {
+ $this->parseCategory($props, $logger, $key, $loggerName, $value);
+ $this->parseAdditivityForLogger($props, $logger, $loggerName);
+ // }
+ } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX) === 0) {
+ $renderedClass = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX));
+ $renderingClass = $value;
+ if (method_exists($hierarchy, 'addrenderer')) {
+ LoggerRendererMap::addRenderer($hierarchy, $renderedClass, $renderingClass);
+ }
+ }
+ }
+ }
+
+ /**
+ * Parse the additivity option for a non-root category.
+ *
+ * @param array $props array of properties
+ * @param Logger &$cat
+ * @param string $loggerName
+ */
+ function parseAdditivityForLogger($props, &$cat, $loggerName)
+ {
+ $value = LoggerOptionConverter::findAndSubst(
+ LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName,
+ $props
+ );
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseAdditivityForLogger() ".
+ "Handling " . LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName . "=[{$value}]"
+ );
+ // touch additivity only if necessary
+ if(!empty($value)) {
+ $additivity = LoggerOptionConverter::toBoolean($value, true);
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseAdditivityForLogger() ".
+ "Setting additivity for [{$loggerName}] to [{$additivity}]"
+ );
+ $cat->setAdditivity($additivity);
+ }
+ }
+
+ /**
+ * This method must work for the root category as well.
+ *
+ * @param array $props array of properties
+ * @param Logger &$logger
+ * @param string $optionKey
+ * @param string $loggerName
+ * @param string $value
+ * @return Logger
+ */
+ function &parseCategory($props, &$logger, $optionKey, $loggerName, $value)
+ {
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseCategory() ".
+ "Parsing for [{$loggerName}] with value=[{$value}]."
+ );
+
+ // We must skip over ',' but not white space
+ $st = explode(',', $value);
+
+ // If value is not in the form ", appender.." or "", then we should set
+ // the level of the loggeregory.
+
+ if(!(@$value{0} == ',' || empty($value))) {
+ // just to be on the safe side...
+ if(sizeof($st) == 0)
+ return;
+
+ $levelStr = current($st);
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseCategory() ".
+ "Level token is [$levelStr]."
+ );
+
+ // If the level value is inherited, set category level value to
+ // null. We also check that the user has not specified inherited for the
+ // root category.
+ if('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) {
+ if ($loggerName == LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME) {
+ LoggerLog::warn(
+ "LoggerPropertyConfigurator::parseCategory() ".
+ "The root logger cannot be set to null."
+ );
+ } else {
+ $logger->setLevel(null);
+ }
+ } else {
+ $logger->setLevel(LoggerOptionConverter::toLevel($levelStr, LoggerLevel::getLevelDebug()));
+ }
+ }
+
+ // Begin by removing all existing appenders.
+ $logger->removeAllAppenders();
+ while($appenderName = next($st)) {
+ $appenderName = trim($appenderName);
+ if(empty($appenderName))
+ continue;
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseCategory() ".
+ "Parsing appender named [{$appenderName}]."
+ );
+ $appender =& $this->parseAppender($props, $appenderName);
+ if($appender !== null) {
+ $logger->addAppender($appender);
+ }
+ }
+ }
+
+ /**
+ * @param array $props array of properties
+ * @param string $appenderName
+ * @return LoggerAppender
+ */
+ function &parseAppender($props, $appenderName)
+ {
+ $appender =& LoggerAppender::singleton($appenderName);
+ if($appender !== null) {
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "Appender [{$appenderName}] was already parsed."
+ );
+ return $appender;
+ }
+ // Appender was not previously initialized.
+ $prefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX . $appenderName;
+ $layoutPrefix = $prefix . ".layout";
+ $appenderClass = @$props[$prefix];
+ if (!empty($appenderClass)) {
+ $appender =& LoggerAppender::singleton($appenderName, $appenderClass);
+ if($appender === null) {
+ LoggerLog::warn(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "Could not instantiate appender named [$appenderName]."
+ );
+ return null;
+ }
+ } else {
+ LoggerLog::warn(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "Could not instantiate appender named [$appenderName] with null className."
+ );
+ return null;
+ }
+
+ $appender->setName($appenderName);
+ if( $appender->requiresLayout() ) {
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "Parsing layout section for [$appenderName]."
+ );
+ $layoutClass = @$props[$layoutPrefix];
+ $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props);
+ if (empty($layoutClass)) {
+ LoggerLog::warn(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "layout class is empty in '$layoutPrefix'. Using Simple layout"
+ );
+ $layout = LoggerLayout::factory('LoggerLayoutSimple');
+ } else {
+ $layout = LoggerLayout::factory($layoutClass);
+
+ if($layout === null) {
+ LoggerLog::warn(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "cannot create layout '$layoutClass'. Using Simple layout"
+ );
+ $layout = LoggerLayout::factory('LoggerLayoutSimple');
+ }
+ }
+
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "Parsing layout options for [$appenderName]."
+ );
+ LoggerPropertySetter::setPropertiesByObject($layout, $props, $layoutPrefix . ".");
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "End Parsing layout options for [$appenderName]."
+ );
+ $appender->setLayout($layout);
+
+ }
+ LoggerPropertySetter::setPropertiesByObject($appender, $props, $prefix . ".");
+ LoggerLog::debug(
+ "LoggerPropertyConfigurator::parseAppender() ".
+ "Parsed [{$appenderName}] options."
+ );
+ return $appender;
+ }
+
+}
?>
Modified: vtigercrm/trunk/log4php/LoggerRoot.php
==============================================================================
--- vtigercrm/trunk/log4php/LoggerRoot.php (original)
+++ vtigercrm/trunk/log4php/LoggerRoot.php Wed May 3 22:07:13 2006
@@ -1,101 +1,101 @@
-<?php
-/**
- * log4php is a PHP port of the log4j java logging package.
- *
- * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
- * <p>Design, strategies and part of the methods documentation are developed by log4j team
- * (Ceki Gülcü as log4j project founder and
- * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
- *
- * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
- * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
- *
- * <p>This software is published under the terms of the LGPL License
- * a copy of which has been included with this distribution in the LICENSE file.</p>
- *
- * @package log4php
- */
-
-/**
- * @ignore
- */
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
-/**
- */
-require_once(LOG4PHP_DIR . '/Logger.php');
-require_once(LOG4PHP_DIR . '/LoggerLevel.php');
-
-/**
- * The root logger.
- *
- * @author VxR <vxr at vxr.it>
- * @version $Revision: 1.1 $
- * @package log4php
- * @see Logger
- */
-class LoggerRoot extends Logger {
-
- /**
- * @var string name of logger
- */
- var $name = 'root';
-
- /**
- * @var object must be null for LoggerRoot
- */
- var $parent = null;
-
-
- /**
- * Constructor
- *
- * @param integer $level initial log level
- */
- function LoggerRoot($level = null)
- {
- $this->Logger($this->name);
- if ($level == null)
- $level = LoggerLevel::getLevelAll();
- $this->setLevel($level);
- }
-
- /**
- * @return integer the level
- */
- function getChainedLevel()
- {
- return $this->level;
- }
-
- /**
- * Setting a null value to the level of the root category may have catastrophic results.
- * @param LoggerLevel $level
- */
- function setLevel($level)
- {
- $this->level = $level;
- }
-
- /**
- * Please use setLevel() instead.
- * @param LoggerLevel $level
- * @deprecated
- */
- function setPriority($level)
- {
- $this->setLevel($level);
- }
-
- /**
- * Always returns false.
- * Because LoggerRoot has no parents, it returns false.
- * @param Logger $parent
- * @return boolean
- */
- function setParent($parent)
- {
- return false;
- }
-}
+<?php
+/**
+ * log4php is a PHP port of the log4j java logging package.
+ *
+ * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
+ * <p>Design, strategies and part of the methods documentation are developed by log4j team
+ * (Ceki Gülcü as log4j project founder and
+ * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
+ *
+ * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
+ * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
+ *
+ * <p>This software is published under the terms of the LGPL License
+ * a copy of which has been included with this distribution in the LICENSE file.</p>
+ *
+ * @package log4php
+ */
+
+/**
+ * @ignore
+ */
+if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
+
+/**
+ */
+require_once(LOG4PHP_DIR . '/Logger.php');
+require_once(LOG4PHP_DIR . '/LoggerLevel.php');
+
+/**
+ * The root logger.
+ *
+ * @author VxR <vxr at vxr.it>
+ * @version $Revision: 1.9 $
+ * @package log4php
+ * @see Logger
+ */
+class LoggerRoot extends Logger {
+
+ /**
+ * @var string name of logger
+ */
+ var $name = 'root';
+
+ /**
+ * @var object must be null for LoggerRoot
+ */
+ var $parent = null;
+
+
+ /**
+ * Constructor
+ *
+ * @param integer $level initial log level
+ */
+ function LoggerRoot($level = null)
+ {
+ $this->Logger($this->name);
+ if ($level == null)
+ $level = LoggerLevel::getLevelAll();
+ $this->setLevel($level);
+ }
+
+ /**
+ * @return integer the level
+ */
+ function getChainedLevel()
+ {
+ return $this->level;
+ }
+
+ /**
+ * Setting a null value to the level of the root category may have catastrophic results.
+ * @param LoggerLevel $level
+ */
+ function setLevel($level)
+ {
+ $this->level = $level;
+ }
+
+ /**
+ * Please use setLevel() instead.
+ * @param LoggerLevel $level
+ * @deprecated
+ */
+ function setPriority($level)
+ {
+ $this->setLevel($level);
+ }
+
+ /**
+ * Always returns false.
+ * Because LoggerRoot has no parents, it returns false.
+ * @param Logger $parent
+ * @return boolean
+ */
+ function setParent($parent)
+ {
+ return false;
+ }
+}
?>
More information about the vtigercrm-commits
mailing list