From 802ea9b60742f88c133b7c7b4b871bfcaadb9649 Mon Sep 17 00:00:00 2001
From: YuCheng Hu
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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); + +/** + * Abstract class that defines output logs strategies. + * + * @author VxRIf this method returns true, meaning that layout is required, + * then the configurator will configure a layout using the configuration + * information at its disposal. If this method returns false, + * 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.
+ * + *In the rather exceptional case, where the appender + * implementation admits a layout but can also work without it, then + * the appender should return true.
+ * + * @return boolean + */ + function requiresLayout() + { + // override me + } + +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/LoggerAppenderSkeleton.php b/oss/vtiger/trunk/log4php.debug/LoggerAppenderSkeleton.php new file mode 100644 index 00000000..a98eff46 --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/LoggerAppenderSkeleton.php @@ -0,0 +1,355 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details). + *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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. + * + *For file based configuration see {@link LoggerPropertyConfigurator}. + *
For XML based configuration see {@link LoggerDOMConfigurator}.
+ *
+ * @author VxR
+ * LoggerManager::resetConfiguration();
+ *
+ *
+ * @see LoggerHierarchy::resetConfiguration()
+ * @static
+ */
+ function resetConfiguration()
+ {
+ LoggerManager::resetConfiguration();
+ }
+}
+?>
diff --git a/oss/vtiger/trunk/log4php.debug/LoggerCategory.php b/oss/vtiger/trunk/log4php.debug/LoggerCategory.php
new file mode 100644
index 00000000..119e95a9
--- /dev/null
+++ b/oss/vtiger/trunk/log4php.debug/LoggerCategory.php
@@ -0,0 +1,572 @@
+This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).
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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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. + * + *The casual user does not have to deal with this class directly.
+ * + *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.
+ * + *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.
+ * + * @author VxRExisting categories are not removed. They are just reset. + * + *
This method should be used sparingly and with care as it will + * block all logging until it is completed.
+ */ + 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 safely close and remove + * all appenders in all categories including the root logger. + * + *Some appenders such as {@link LoggerSocketAppender} + * need to be closed before the + * application exists. Otherwise, pending logging events might be + * lost. + * + *
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(); + } + } + } +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/LoggerLayout.php b/oss/vtiger/trunk/log4php.debug/LoggerLayout.php new file mode 100644 index 00000000..a5f774fc --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/LoggerLayout.php @@ -0,0 +1,98 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).
+ *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); + +/** + * Extend this abstract class to create your own log layout format. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 + * OFF, FATAL, ERROR, + * WARN, INFODEBUG and + * ALL. + * + *The LoggerLevel class may be subclassed to define a larger + * level set.
+ * + * @author VxRYou should think twice before overriding the default + * implementation of isGreaterOrEqual 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; + } + } + } + } +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/LoggerLog.php b/oss/vtiger/trunk/log4php.debug/LoggerLog.php new file mode 100644 index 00000000..558129e9 --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/LoggerLog.php @@ -0,0 +1,99 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).
+ *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); + +/** + * Helper class for internal logging + * + *It uses php {@link PHP_MANUAL#trigger_error trigger_error()} function + * to output messages.
+ *You need to recode methods to output messages in a different way.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 mapped diagnostic contexts. + * + * A Mapped Diagnostic Context, 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. + * + *The MDC is managed on a per thread basis.
+ *
+ * @author VxR If the current thread does not have a context map it is
+ * created as a side effect. Note that you cannot put more than {@link LOGGER_MDC_HT_SIZE} keys. 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. This method has no side effects.
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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 VxRIf it is not user defined, log4php tries to autoconfigure using (in order):
+ * + * - the$_ENV['log4php.defaultInitOverride'] variable.
+ * - the $GLOBALS['log4php.defaultInitOverride'] global variable.
+ * - defaults to false
+ *
+ * @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.
+ *
+ * This constant tells configurator classes where the configuration + * file is located.
+ *If not set by user, log4php tries to set it automatically using + * (in order):
+ * + * - the$_ENV['log4php.configuration'] 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.
+ *
+ * This constant is set with the fullname (path included but non the + * .php extension) of the configurator class that init procedure will use.
+ *If not set by user, log4php tries to set it automatically.
+ *If {@link LOG4PHP_CONFIGURATION} has '.xml' extension set the + * constants to '{@link LOG4PHP_DIR}/xml/{@link LoggerDOMConfigurator}'.
+ *Otherwise set the constants to + * '{@link LOG4PHP_DIR}/{@link LoggerPropertyConfigurator}'.
+ * + *Security Note: classfile pointed by this constant will be brutally
+ * included with a:
+ * @include_once(LOG4PHP_CONFIGURATOR_CLASS . ".php");
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.
+ *Users can skip this procedure using {@link LOG4PHP_DEFAULT_INIT_OVERRIDE} + * constant.
+ * + * @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; + } +} + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/LoggerNDC.php b/oss/vtiger/trunk/log4php.debug/LoggerNDC.php new file mode 100644 index 00000000..ac94ee43 --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/LoggerNDC.php @@ -0,0 +1,240 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details). + *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 nested diagnostic contexts as + * defined by Neil Harrison in the article "Patterns for Logging + * Diagnostic Messages" part of the book "Pattern Languages of + * Program Design 3" edited by Martin et al. + * + *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. + * + *
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. + * + *
Note that NDCs are managed on a per thread + * basis. NDC operations such as {@link push()}, {@link pop()}, + * {@link clear()}, {@link getDepth()} and {@link setMaxDepth()} + * affect the NDC of the current thread only. NDCs of other + * threads remain unaffected. + * + *
For example, a servlet can build a per client request NDC + * consisting the clients host name and other information contained in + * the the request. Cookies are another source of distinctive + * information. To build an NDC one uses the {@link push()} + * operation.
+ * + * Simply put, + * + * - Contexts can be nested. + * - When entering a context, call + *LoggerNDC::push()
+ * 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
+ * LoggerNDC::pop()
+ * - When exiting a thread make sure to call {@link remove()}
+ *
+ * There is no penalty for forgetting to match each
+ * push operation with a corresponding pop,
+ * except the obvious mismatch between the real application context
+ * and the context set in the NDC.
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.
+ * + * + * @author VxRThis method is equivalent to calling the {@link setMaxDepth()} + * method with a zero maxDepth 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. + * + *
The returned value is the value that was pushed last. If no + * context is available, then the empty string "" is returned.
+ * + * @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. + * + *The returned value is the value that was pushed last. If no + * context is available, then the empty string "" is returned.
+ * @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. + * + *The contents of the message 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 maxDepth, then no + * action is taken. + * + *
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; + } + } + +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/LoggerPropertyConfigurator.php b/oss/vtiger/trunk/log4php.debug/LoggerPropertyConfigurator.php new file mode 100644 index 00000000..98964394 --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/LoggerPropertyConfigurator.php @@ -0,0 +1,650 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).
+ *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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. + * + *It is sometimes useful to see how log4php is reading configuration + * files. You can enable log4php internal logging by defining the + * log4php.debug variable.
+ * + *The LoggerPropertyConfigurator 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. + * + *
All option values admit variable substitution. The + * syntax of variable substitution is similar to that of Unix + * shells. The string between an opening "${" and + * closing "}" 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.
+ *For example, if $_ENV['home'] env var is set to + * /home/xyz, then every occurrence of the sequence + * ${home} will be interpreted as + * /home/xyz. See {@link LoggerOptionConverter::getSystemProperty()} + * for details.
+ * + * @author VxRThe function {@link PHP_MANUAL#parse_ini_file} is used to read the + * file.
+ * + * The existing configuration is not cleared nor reset. + * If you require a different behavior, then call + * {@link LoggerManager::resetConfiguration()} + * method before calling {@link doConfigure()}. + * + *The configuration file consists of statements in the format + * key=value. The syntax of different configuration + * elements are discussed below. + * + *
Repository-wide threshold
+ * + *The repository-wide threshold filters logging requests by level + * regardless of logger. The syntax is: + * + *
+ * log4php.threshold=[level] + *+ * + *
The level value can consist of the string values OFF, FATAL, + * ERROR, WARN, INFO, DEBUG, ALL or a custom level value. A + * custom level value can be specified in the form + * level#classname. By default the repository-wide threshold is set + * to the lowest possible value, namely the level ALL. + *
+ * + * + *Appender configuration
+ * + *Appender configuration syntax is:
+ *+ * ; For appender named appenderName, 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 + *+ * + * For each named appender you can configure its {@link LoggerLayout}. The + * syntax for configuring an appender's layout is: + *
+ * log4php.appender.appenderName.layout=name_of_layout_class + * log4php.appender.appenderName.layout.option1=value1 + * .... + * log4php.appender.appenderName.layout.optionN=valueN + *+ * + *
Configuring loggers
+ * + *The syntax for configuring the root logger is: + *
+ * log4php.rootLogger=[level], appenderName, appenderName, ... + *+ * + *
This syntax means that an optional level can be + * supplied followed by appender names separated by commas. + * + *
The level value can consist of the string values OFF, FATAL, + * ERROR, WARN, INFO, DEBUG, ALL or a custom level value. A + * custom level value can be specified in the form
+ * + *level#classname+ * + *
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. + * + *
The root logger can be assigned multiple appenders. + * + *
Each appenderName (separated by commas) will be added to + * the root logger. The named appender is defined using the + * appender syntax defined above. + * + *
For non-root categories the syntax is almost the same: + *
+ * log4php.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ... + *+ * + *
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.
+ * + *If no level value is supplied, then the level of the + * named logger remains untouched.
+ * + *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.
+ * + *Similar to the root logger syntax, each appenderName + * (separated by commas) will be attached to the named logger.
+ * + *See the appender additivity rule in the user manual for + * the meaning of the additivity flag. + * + *
ObjectRenderers
+ * + *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.
+ * + *The syntax is: + * + *
+ * log4php.renderer.name_of_rendered_class=name_of_rendering.class + *+ * + * As in, + *
+ * log4php.renderer.myFruit=myFruitRenderer + *+ * + *
Logger Factories
+ * + * The usage of custom logger factories is discouraged and no longer + * documented. + * + *Example
+ * + *An example configuration is given below. Other configuration + * file examples are given in the tests folder. + * + *
+ * ; 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
+ * ; %r %-5p %c{2} %M.%L %x - %m%n. 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
+ *
+ *
+ * Refer to the setOption method in each Appender and + * Layout for class specific options.
+ * + *Use the ";" character at the + * beginning of a line for comments.
+ * + * @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 properties. + * + * @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 Properties 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; + } + +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/LoggerRoot.php b/oss/vtiger/trunk/log4php.debug/LoggerRoot.php new file mode 100644 index 00000000..c25a401b --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/LoggerRoot.php @@ -0,0 +1,101 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details). + *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @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 VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + + +define('LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT', 'php://stdout'); +define('LOG4PHP_LOGGER_APPENDER_CONSOLE_STDERR', 'php://stderr'); + +/** + * ConsoleAppender appends log events to STDOUT or STDERR using a layout specified by the user. + * + *Optional parameter is {@link $target}. The default target is Stdout.
+ *Note: Use this Appender with command-line php scripts. + * On web scripts this appender has no effects.
+ *This appender requires a layout.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/appenders/LoggerAppenderFile.php'); + +/** + * LoggerAppenderDailyFile appends log events to a file ne. + * + * A formatted version of the date pattern is used as to create the file name + * using the {@link PHP_MANUAL#sprintf} function. + *Parameters are {@link $datePattern}, {@link $file}. Note that file + * parameter should include a '%s' identifier and should always be set + * before {@link $file} param.
+ * + * @author Abel GonzalezDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); +require_once('DB.php'); + +/** + * Appends log events to a db table using PEAR::DB class. + * + *This appender uses a table in a database to log events.
+ *Parameters are {@link $dsn}, {@link $createTable}, {@link table} and {@link $sql}.
+ *See examples in test directory.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * LoggerAppenderEcho uses {@link PHP_MANUAL#echo echo} function to output events. + * + *This appender requires a layout.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * FileAppender appends log events to a file. + * + * Parameters are ({@link $fileName} but option name is file), + * {@link $append}. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Appends log events to mail using php function {@link PHP_MANUAL#mail}. + * + *Parameters are {@link $from}, {@link $to}, {@link $subject}.
+ *This appender requires a layout.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Log events to an email address. It will be created an email for each event. + * + *Parameters are + * {@link $smtpHost} (optional), + * {@link $port} (optional), + * {@link $from} (optional), + * {@link $to}, + * {@link $subject} (optional).
+ *A layout is required.
+ * + * @author Domenico LordiDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * A NullAppender merely exists, it never outputs a message to any device. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/LoggerLevel.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Log events using php {@link PHP_MANUAL#trigger_error} function and a {@link LoggerLayoutTTCC} default layout. + * + *Levels are mapped as follows:
+ * - level < WARN mapped to E_USER_NOTICE + * - WARN <= level < ERROR mapped to E_USER_WARNING + * - level >= ERROR mapped to E_USER_ERROR + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/appenders/LoggerAppenderFile.php'); + +/** + * LoggerAppenderRollingFile extends LoggerAppenderFile to backup the log files + * when they reach a certain size. + * + *Parameters are {@link $maxFileSize}, {@link $maxBackupIndex}.
+ * + *Contributors: Sergio Strampelli.
+ * + * @author VxRIn configuration files, the MaxFileSize option takes a + * long integer in the range 0 - 2^63. You can specify the value + * with the suffixes "KB", "MB" or "GB" so that the integer is + * interpreted being expressed respectively in kilobytes, megabytes + * or gigabytes. For example, the value "10KB" will be interpreted + * as 10240.
+ *The default maximum file size is 10MB.
+ * + *Note that MaxFileSize cannot exceed 2 GB.
+ * + * @var integer + */ + var $maxFileSize = 10485760; + + /** + * Set the maximum number of backup files to keep around. + * + *The MaxBackupIndex option determines how many backup + * files are kept before the oldest is erased. This option takes + * a positive integer value. If set to zero, then there will be no + * backup files and the log file will be truncated when it reaches + * MaxFileSize.
+ *There is one backup file by default.
+ * + * @var integer + */ + var $maxBackupIndex = 1; + + /** + * @var string the filename expanded + * @access private + */ + var $expandedFileName = null; + + /** + * Constructor. + * + * @param string $name appender name + */ + function LoggerAppenderRollingFile($name) + { + $this->LoggerAppenderFile($name); + } + + /** + * Returns the value of the MaxBackupIndex option. + * @return integer + */ + function getExpandedFileName() { + return $this->expandedFileName; + } + + /** + * Returns the value of the MaxBackupIndex option. + * @return integer + */ + function getMaxBackupIndex() { + return $this->maxBackupIndex; + } + + /** + * Get the maximum size that the output file is allowed to reach + * before being rolled over to backup files. + * @return integer + */ + function getMaximumFileSize() { + return $this->maxFileSize; + } + + /** + * Implements the usual roll over behaviour. + * + *If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. + * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. + * + *
If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. + */ + function rollOver() + { + // If maxBackups <= 0, then there is no file renaming to be done. + if($this->maxBackupIndex > 0) { + $fileName = $this->getExpandedFileName(); + // Delete the oldest file, to keep Windows happy. + $file = $fileName . '.' . $this->maxBackupIndex; + if (is_writable($file)) + unlink($file); + // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} + for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { + $file = $fileName . "." . $i; + if (is_readable($file)) { + $target = $fileName . '.' . ($i + 1); + rename($file, $target); + } + } + + // Rename fileName to fileName.1 + $target = $fileName . ".1"; + + $this->closeFile(); // keep windows happy. + + $file = $fileName; + + //As of now suppress the error in rename. we have to handle in future + @rename($file, $target); + } + + $this->setFile($fileName, false); + unset($this->fp); + $this->activateOptions(); + } + + function setFileName($fileName) + { + $this->fileName = $fileName; + $this->expandedFileName = realpath($fileName); + LoggerLog::debug("LoggerAppenderRollingFile::setFileName():filename=[{$fileName}]:expandedFileName=[{$this->expandedFileName}]"); + } + + + /** + * Set the maximum number of backup files to keep around. + * + *
The MaxBackupIndex option determines how many backup + * files are kept before the oldest is erased. This option takes + * a positive integer value. If set to zero, then there will be no + * backup files and the log file will be truncated when it reaches + * MaxFileSize. + * + * @param mixed $maxBackups + */ + function setMaxBackupIndex($maxBackups) + { + if (is_numeric($maxBackups)) + $this->maxBackupIndex = abs((int)$maxBackups); + } + + /** + * Set the maximum size that the output file is allowed to reach + * before being rolled over to backup files. + * + * @param mixed $maxFileSize + * @see setMaxFileSize() + */ + function setMaximumFileSize($maxFileSize) + { + $this->setMaxFileSize($maxFileSize); + } + + /** + * Set the maximum size that the output file is allowed to reach + * before being rolled over to backup files. + *
In configuration files, the MaxFileSize option takes an + * long integer in the range 0 - 2^63. You can specify the value + * with the suffixes "KB", "MB" or "GB" so that the integer is + * interpreted being expressed respectively in kilobytes, megabytes + * or gigabytes. For example, the value "10KB" will be interpreted + * as 10240. + * + * @param mixed $value + */ + function setMaxFileSize($value) + { + $maxFileSize = null; + $numpart = substr($value,0, strlen($value) -2); + $suffix = strtoupper(substr($value, -2)); + + switch ($suffix) { + case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; + case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; + case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; + default: + if (is_numeric($value)) { + $maxFileSize = (int)$value; + } + } + + if ($maxFileSize === null) { + LoggerLog::debug("LoggerAppenderRollingFile::setMaxFileSize():value=[$value] wrong declaration"); + } else { + $this->maxFileSize = abs($maxFileSize); + } + } + + /** + * @param LoggerLoggingEvent $event + */ + function append($event) + { + if ($this->fp) { + parent::append($event); + if (ftell($this->fp) > $this->getMaximumFileSize()) + $this->rollOver(); + } + } +} +?> diff --git a/oss/vtiger/trunk/log4php.debug/appenders/LoggerAppenderSocket.php b/oss/vtiger/trunk/log4php.debug/appenders/LoggerAppenderSocket.php new file mode 100644 index 00000000..8bc9dcdf --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/appenders/LoggerAppenderSocket.php @@ -0,0 +1,285 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).
+ *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +define('LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_PORT', 4446); +define('LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_TIMEOUT', 30); + +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); +require_once(LOG4PHP_DIR . '/LoggerLayout.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Serialize events and send them to a network socket. + * + * Parameters are {@link $remoteHost}, {@link $port}, {@link $timeout}, + * {@link $locationInfo}, {@link $useXml} and {@link $log4jNamespace}. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage appenders + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); +require_once(LOG4PHP_DIR . '/LoggerLevel.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Log events using php {@link PHP_MANUAL#syslog} function. + * + * Levels are mapped as follows: + * - level >= FATAL to LOG_ALERT + * - FATAL > level >= ERROR to LOG_ERR + * - ERROR > level >= WARN to LOG_WARNING + * - WARN > level >= INFO to LOG_INFO + * - INFO > level >= DEBUG to LOG_DEBUG + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage config + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage config + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/LoggerLog.php'); +require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); + +/** + * General purpose Object property setter. Clients repeatedly invokes + * {@link setProperty()} in order to invoke setters + * on the Object specified in the constructor. + * + * Usage: + *
+ * $ps = new LoggerPropertySetter($anObject);
+ * $ps->set("name", "Joe");
+ * $ps->set("age", 32);
+ * $ps->set("isMale", true);
+ *
+ * will cause the invocations
+ *
+ * $anObject->setName("Joe");
+ * $anObject->setAge(32);
+ * $anObject->setMale(true)
+ *
+ * if such methods exist.
+ *
+ * @author VxR properties are parsed relative to a
+ * prefix.
+ *
+ * @param object &$obj The object to configure.
+ * @param array $properties An array containing keys and values.
+ * @param string $prefix Only keys having the specified prefix will be set.
+ * @static
+ */
+ function setPropertiesByObject(&$obj, $properties, $prefix)
+ {
+ $pSetter = new LoggerPropertySetter($obj);
+ return $pSetter->setProperties($properties, $prefix);
+ }
+
+
+ /**
+ * Set the properites for the object that match the
+ * prefix passed as parameter.
+ *
+ * @param array $properties An array containing keys and values.
+ * @param string $prefix Only keys having the specified prefix will be set.
+ */
+ function setProperties($properties, $prefix)
+ {
+ LoggerLog::debug("LoggerOptionConverter::setProperties():prefix=[{$prefix}]");
+
+ $len = strlen($prefix);
+ while (list($key,) = each($properties)) {
+ if (strpos($key, $prefix) === 0) {
+ if (strpos($key, '.', ($len + 1)) > 0)
+ continue;
+ $value = LoggerOptionConverter::findAndSubst($key, $properties);
+ $key = substr($key, $len);
+ if ($key == 'layout' and is_a($this->obj, 'loggerappender')) {
+ continue;
+ }
+ $this->setProperty($key, $value);
+ }
+ }
+ $this->activate();
+ }
+
+ /**
+ * Set a property on this PropertySetter's Object. If successful, this
+ * method will invoke a setter method on the underlying Object. The
+ * setter is the one for the specified property name and the value is
+ * determined partly from the setter argument type and partly from the
+ * value specified in the call to this method.
+ *
+ * If the setter expects a String no conversion is necessary. + * If it expects an int, then an attempt is made to convert 'value' + * to an int using new Integer(value). If the setter expects a boolean, + * the conversion is by new Boolean(value). + * + * @param string $name name of the property + * @param string $value String value of the property + */ + function setProperty($name, $value) + { + LoggerLog::debug("LoggerOptionConverter::setProperty():name=[{$name}]:value=[{$value}]"); + + if ($value === null) return; + + $method = "set" . ucfirst($name); + + if (!method_exists($this->obj, $method)) { + LoggerLog::warn( + "LoggerOptionConverter::setProperty() No such setter method for [{$name}] property in " . + get_class($this->obj) . "." + ); + } else { + return call_user_func(array(&$this->obj, $method), $value); + } + } + + function activate() + { + LoggerLog::debug("LoggerOptionConverter::activate()"); + + if (method_exists($this->obj, 'activateoptions')) { + return call_user_func(array(&$this->obj, 'activateoptions')); + } else { + LoggerLog::debug("LoggerOptionConverter::activate() Nothing to activate."); + } + } +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/helpers/LoggerFormattingInfo.php b/oss/vtiger/trunk/log4php.debug/helpers/LoggerFormattingInfo.php new file mode 100644 index 00000000..f642b634 --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/helpers/LoggerFormattingInfo.php @@ -0,0 +1,61 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).
+ *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage helpers + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * This class encapsulates the information obtained when parsing + * formatting modifiers in conversion modifiers. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage helpers + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/LoggerLevel.php'); + +define('LOG4PHP_OPTION_CONVERTER_DELIM_START', '${'); +define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP', '}'); +define('LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN', 2); +define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN', 1); + +/** + * A convenience class to convert property values to specific types. + * + * @author VxRCase of value is unimportant.
+ * + * @param string $value + * @param boolean $default + * @return boolean + * + * @static + */ + function toBoolean($value, $default) + { + if($value === null) + return $default; + if ($value == 1) + return true; + $trimmedVal = strtolower(trim($value)); + if ("true" == $trimmedVal or "yes" == $trimmedVal) + return true; + if ("false" == $trimmedVal) + return false; + return $default; + } + + /** + * @param string $value + * @param integer $default + * @return integer + * @static + */ + function toInt($value, $default) + { + $value = trim($value); + if (is_numeric($value)) { + return (int)$value; + } else { + return $default; + } + } + + /** + * Converts a standard or custom priority level to a Level + * object. + * + *If $value is of form "level#full_file_classname", + * where full_file_classname means the class filename with path + * but without php extension, then the specified class' toLevel() method + * is called to process the specified level string; if no '#' + * character is present, then the default {@link LoggerLevel} + * class is used to process the level value.
+ * + *As a special case, if the $value parameter is + * equal to the string "NULL", then the value null will + * be returned.
+ * + *If any error occurs while converting the value to a level, + * the $defaultValue parameter, which may be + * null, is returned.
+ * + *Case of $value is insignificant for the level level, but is + * significant for the class name part, if present.
+ * + * @param string $value + * @param LoggerLevel $defaultValue + * @return LoggerLevel a {@link LoggerLevel} or null + * @static + */ + function toLevel($value, $defaultValue) + { + if($value === null) + return $defaultValue; + + $hashIndex = strpos($value, '#'); + if ($hashIndex === false) { + if("NULL" == strtoupper($value)) { + return null; + } else { + // no class name specified : use standard Level class + return LoggerLevel::toLevel($value, $defaultValue); + } + } + + $result = $defaultValue; + + $clazz = substr($value, ($hashIndex + 1)); + $levelName = substr($value, 0, $hashIndex); + + // This is degenerate case but you never know. + if("NULL" == strtoupper($levelName)) { + return null; + } + + LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}]:pri=[{$levelName}]"); + + if (!class_exists($clazz)) + @include_once("{$clazz}.php"); + + $clazz = basename($clazz); + + if (class_exists($clazz)) { + $result = @call_user_func(array($clazz, 'toLevel'), $value, $defaultValue); + if (!is_a($result, 'loggerlevel')) { + LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}] cannot call toLevel(). Returning default."); + $result = $defaultValue; + } + } else { + LoggerLog::warn("LoggerOptionConverter::toLevel() class '{$clazz}' doesnt exists."); + } + return $result; + } + + /** + * @param string $value + * @param float $default + * @return float + * + * @static + */ + function toFileSize($value, $default) + { + if ($value === null) + return $default; + + $s = strtoupper(trim($value)); + $multiplier = (float)1; + if(($index = strpos($s, 'KB')) !== false) { + $multiplier = 1024; + $s = substr($s, 0, $index); + } elseif(($index = strpos($s, 'MB')) !== false) { + $multiplier = 1024 * 1024; + $s = substr($s, 0, $index); + } elseif(($index = strpos($s, 'GB')) !== false) { + $multiplier = 1024 * 1024 * 1024; + $s = substr($s, 0, $index); + } + if(is_numeric($s)) { + return (float)$s * $multiplier; + } else { + LoggerLog::warn("LoggerOptionConverter::toFileSize() [{$s}] is not in proper form."); + } + return $default; + } + + /** + * Find the value corresponding to $key in + * $props. Then perform variable substitution on the + * found value. + * + * @param string $key + * @param array $props + * @return string + * + * @static + */ + function findAndSubst($key, $props) + { + $value = @$props[$key]; + if(empty($value)) { + return null; + } + return LoggerOptionConverter::substVars($value, $props); + } + + /** + * Perform variable substitution in string $val from the + * values of keys found with the {@link getSystemProperty()} method. + * + *The variable substitution delimeters are ${ and }. + * + *
For example, if the "MY_CONSTANT" contains "value", then
+ * the call
+ *
+ * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
+ *
+ * will set the variable $s to "Value of key is value.".
If no value could be found for the specified key, then the + * $props parameter is searched, if the value could not + * be found there, then substitution defaults to the empty string.
+ * + *For example, if {@link getSystemProperty()} cannot find any value for the key
+ * "inexistentKey", then the call
+ *
+ * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
+ *
+ * will set $s to "Value of inexistentKey is []".
A warn is thrown if $val contains a start delimeter "${" + * which is not balanced by a stop delimeter "}" and an empty string is returned.
+ * + * @log4j-author Avy Sharell + * + * @param string $val The string on which variable substitution is performed. + * @param array $props + * @return string + * + * @static + */ + function substVars($val, $props = null) + { + LoggerLog::debug("LoggerOptionConverter::substVars():val=[{$val}]"); + + $sbuf = ''; + $i = 0; + while(true) { + $j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i); + if ($j === false) { + LoggerLog::debug("LoggerOptionConverter::substVars() no more variables"); + // no more variables + if ($i == 0) { // this is a simple string + LoggerLog::debug("LoggerOptionConverter::substVars() simple string"); + return $val; + } else { // add the tail string which contails no variables and return the result. + $sbuf .= substr($val, $i); + LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]. Returning sbuf"); + return $sbuf; + } + } else { + + $sbuf .= substr($val, $i, $j-$i); + LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}."); + $k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j); + if ($k === false) { + LoggerLog::warn( + "LoggerOptionConverter::substVars() " . + "'{$val}' has no closing brace. Opening brace at position {$j}." + ); + return ''; + } else { + $j += LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN; + $key = substr($val, $j, $k - $j); + // first try in System properties + $replacement = LoggerOptionConverter::getSystemProperty($key, null); + // then try props parameter + if($replacement == null and $props !== null) { + $replacement = @$props[$key]; + } + + if(!empty($replacement)) { + // Do variable substitution on the replacement string + // such that we can solve "Hello ${x2}" as "Hello p1" + // the where the properties are + // x1=p1 + // x2=${x1} + $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props); + $sbuf .= $recursiveReplacement; + } + $i = $k + LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN; + } + } + } + } + +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/helpers/LoggerPatternConverter.php b/oss/vtiger/trunk/log4php.debug/helpers/LoggerPatternConverter.php new file mode 100644 index 00000000..3d68be81 --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/helpers/LoggerPatternConverter.php @@ -0,0 +1,504 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details). + *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage helpers + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Array for fast space padding + * Used by {@link LoggerPatternConverter::spacePad()}. + */ +$GLOBALS['log4php.LoggerPatternConverter.spaces'] = array(" ", " ", " ", " ", //1,2,4,8 spaces + " ", // 16 spaces + " " ); // 32 spaces + +/** + * LoggerPatternConverter is an abstract class that provides the formatting + * functionality that derived classes need. + * + *Conversion specifiers in a conversion patterns are parsed to + * individual PatternConverters. Each of which is responsible for + * converting a logging event in a converter specific manner.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage helpers + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +if (!defined('LOG4PHP_LINE_SEP')) { + if (substr(php_uname(), 0, 7) == "Windows") { + /** + * @ignore + */ + define('LOG4PHP_LINE_SEP', "\r\n"); + } else { + /** + * @ignore + */ + define('LOG4PHP_LINE_SEP', "\n"); + } +} + +/** + */ +require_once(LOG4PHP_DIR . '/helpers/LoggerFormattingInfo.php'); +require_once(LOG4PHP_DIR . '/helpers/LoggerPatternConverter.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +define('LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR', '%'); + +define('LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE', 0); +define('LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE', 1); +define('LOG4PHP_LOGGER_PATTERN_PARSER_MINUS_STATE', 2); +define('LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE', 3); +define('LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE', 4); +define('LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE', 5); + +define('LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER', 1000); +define('LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER', 1001); +define('LOG4PHP_LOGGER_PATTERN_PARSER_CLASS_LOCATION_CONVERTER', 1002); +define('LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER', 1003); +define('LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER', 1004); + +define('LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER', 2000); +define('LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER', 2001); +define('LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER', 2002); +define('LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER', 2003); +define('LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER', 2004); + +define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601', 'Y-m-d H:i:s,u'); +define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE', 'H:i:s'); +define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE', 'd M Y H:i:s,u'); + +/** + * Most of the work of the {@link LoggerPatternLayout} class + * is delegated to the {@link LoggerPatternParser} class. + * + *It is this class that parses conversion patterns and creates + * a chained list of {@link LoggerPatternConverter} converters.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage helpers + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +define('LOG4PHP_LOGGER_TRANSFORM_CDATA_START', ''); +define('LOG4PHP_LOGGER_TRANSFORM_CDATA_PSEUDO_END', ']]>'); +define('LOG4PHP_LOGGER_TRANSFORM_CDATA_EMBEDDED_END', + LOG4PHP_LOGGER_TRANSFORM_CDATA_END . + LOG4PHP_LOGGER_TRANSFORM_CDATA_PSEUDO_END . + LOG4PHP_LOGGER_TRANSFORM_CDATA_START +); + +/** + * Utility class for transforming strings. + * + * @log4j-class org.apache.log4j.helpers.Transform + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage layouts + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +if (!defined('LOG4PHP_LINE_SEP')) { + if (substr(php_uname(), 0, 7) == "Windows") { + /** + * @ignore + */ + define('LOG4PHP_LINE_SEP', "\r\n"); + } else { + /** + * @ignore + */ + define('LOG4PHP_LINE_SEP', "\n"); + } +} + +/** + */ +require_once(LOG4PHP_DIR . '/LoggerLayout.php'); +require_once(LOG4PHP_DIR . '/spi/LoggerLoggingEvent.php'); + +/** + * This layout outputs events in a HTML table. + * + * Parameters are: {@link $title}, {@link $locationInfo}. + * + * @author VxRIf you are embedding this layout within a {@link LoggerAppenderMail} + * or a {@link LoggerAppenderMailEvent} then make sure to set the + * LocationInfo option of that appender as well. + * @var boolean + */ + var $locationInfo = false; + + /** + * The Title option takes a String value. This option sets the + * document title of the generated HTML document. + * Defaults to 'Log4php Log Messages'. + * @var string + */ + var $title = "Log4php Log Messages"; + + /** + * Constructor + */ + function LoggerLayoutHtml() + { + return; + } + + /** + * The LocationInfo option takes a boolean value. By + * default, it is set to false which means there will be no location + * information output by this layout. If the the option is set to + * true, then the file name and line number of the statement + * at the origin of the log statement will be output. + * + *
If you are embedding this layout within a {@link LoggerAppenderMail} + * or a {@link LoggerAppenderMailEvent} then make sure to set the + * LocationInfo option of that appender as well. + */ + function setLocationInfo($flag) + { + if (is_bool($flag)) { + $this->locationInfo = $flag; + } else { + $this->locationInfo = (bool)(strtolower($flag) == 'true'); + } + } + + /** + * Returns the current value of the LocationInfo option. + */ + function getLocationInfo() + { + return $this->locationInfo; + } + + /** + * The Title option takes a String value. This option sets the + * document title of the generated HTML document. + * Defaults to 'Log4php Log Messages'. + */ + function setTitle($title) + { + $this->title = $title; + } + + /** + * @return string Returns the current value of the Title option. + */ + function getTitle() + { + return $this->title; + } + + /** + * @return string Returns the content type output by this layout, i.e "text/html". + */ + function getContentType() + { + return "text/html"; + } + + /** + * No options to activate. + */ + function activateOptions() + { + return true; + } + + /** + * @param LoggerLoggingEvent $event + * @return string + */ + function format($event) + { + $sbuf = LOG4PHP_LINE_SEP . "
| Time | " . LOG4PHP_LINE_SEP; + $sbuf .= "Thread | " . LOG4PHP_LINE_SEP; + $sbuf .= "Level | " . LOG4PHP_LINE_SEP; + $sbuf .= "Category | " . LOG4PHP_LINE_SEP; + if ($this->locationInfo) + $sbuf .= "File:Line | " . LOG4PHP_LINE_SEP; + $sbuf .= "Message | " . LOG4PHP_LINE_SEP; + $sbuf .= "
|---|
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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage layouts + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +if (!defined('LOG4PHP_LINE_SEP')) { + if (substr(php_uname(), 0, 7) == "Windows") { + define('LOG4PHP_LINE_SEP', "\r\n"); + } else { + /** + * @ignore + */ + define('LOG4PHP_LINE_SEP', "\n"); + } +} + + +/** + */ +require_once(LOG4PHP_DIR . '/LoggerLayout.php'); + +/** + * A simple layout. + * + * Returns the log statement in a format consisting of the + * level, followed by " - " and then the message. + * For example, + * INFO - "A message" + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage layouts + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +if (!defined('LOG4PHP_LINE_SEP')) { + if (substr(php_uname(), 0, 7) == "Windows") { + /** + * @ignore + */ + define('LOG4PHP_LINE_SEP', "\r\n"); + } else { + /** + * @ignore + */ + define('LOG4PHP_LINE_SEP', "\n"); + } +} + +/** + */ +require_once(LOG4PHP_DIR . '/LoggerLayout.php'); + +/** + * String constant designating no time information. Current value of + * this constant is NULL. + */ +define ('LOG4PHP_LOGGER_LAYOUT_NULL_DATE_FORMAT', 'NULL'); + +/** + * String constant designating relative time. Current value of + * this constant is RELATIVE. + */ +define ('LOG4PHP_LOGGER_LAYOUT_RELATIVE_TIME_DATE_FORMAT', 'RELATIVE'); + +/** + * TTCC layout format consists of time, thread, category and nested + * diagnostic context information, hence the name. + * + *Each of the four fields can be individually enabled or + * disabled. The time format depends on the DateFormat used.
+ * + *If no dateFormat is specified it defaults to '%c'. + * See php {@link PHP_MANUAL#date} function for details.
+ * + * Params: + * - {@link $threadPrinting} (true|false) enable/disable pid reporting. + * - {@link $categoryPrefixing} (true|false) enable/disable logger category reporting. + * - {@link $contextPrinting} (true|false) enable/disable NDC reporting. + * - {@link $microSecondsPrinting} (true|false) enable/disable micro seconds reporting in timestamp. + * - {@link $dateFormat} (string) set date format. See php {@link PHP_MANUAL#date} function for details. + * + * @author VxRTime, thread, category are printed depending on options. + * + * @param LoggerLoggingEvent $event + * @return string + */ + function format($event) + { + $timeStamp = (float)$event->getTimeStamp(); + $format = strftime($this->dateFormat, (int)$timeStamp); + + if ($this->microSecondsPrinting) { + $usecs = round(($timeStamp - (int)$timeStamp) * 1000); + $format .= sprintf(',%03d', $usecs); + } + + $format .= ' '; + + if ($this->threadPrinting) + $format .= '['.getmypid().'] '; + + $level = $event->getLevel(); + $format .= $level->toString().' '; + + if($this->categoryPrefixing) { + $format .= $event->getLoggerName().' '; + } + + if($this->contextPrinting) { + $ndc = $event->getNDC(); + if($ndc != null) { + $format .= $ndc.' '; + } + } + + $format .= '- '.$event->getRenderedMessage(); + $format .= LOG4PHP_LINE_SEP; + + return $format; + } + + function ignoresThrowable() + { + return true; + } +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/log4php.debug/layouts/LoggerPatternLayout.php b/oss/vtiger/trunk/log4php.debug/layouts/LoggerPatternLayout.php new file mode 100644 index 00000000..6c21ef24 --- /dev/null +++ b/oss/vtiger/trunk/log4php.debug/layouts/LoggerPatternLayout.php @@ -0,0 +1,260 @@ +This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).
+ *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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage layouts + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/helpers/LoggerPatternParser.php'); +require_once(LOG4PHP_DIR . '/LoggerLayout.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Default conversion Pattern + */ +define('LOG4PHP_LOGGER_PATTERN_LAYOUT_DEFAULT_CONVERSION_PATTERN', '%m%n'); + +define('LOG4PHP_LOGGER_PATTERN_LAYOUT_TTCC_CONVERSION_PATTERN', '%r [%t] %p %c %x - %m%n'); + +/** + * A flexible layout configurable with pattern string. + * + *The goal of this class is to {@link format()} a {@link LoggerLoggingEvent} and return the results as a string. + * The results depend on the conversion pattern. + * The conversion pattern is closely related to the conversion pattern of the printf function in C. + * A conversion pattern is composed of literal text and format control expressions called conversion specifiers. + * You are free to insert any literal text within the conversion pattern.
+ * + *Each conversion specifier starts with a percent sign (%) and is followed by optional + * format modifiers and a conversion character.
+ * + *The conversion character specifies the type of data, e.g. category, priority, date, thread name. + * The format modifiers control such things as field width, padding, left and right justification.
+ * + * The following is a simple example. + * + *Let the conversion pattern be "%-5p [%t]: %m%n" and assume that the log4php environment + * was set to use a LoggerPatternLayout.
+ * + * Then the statements + *
+ * $root =& LoggerManager::getRoot();
+ * $root->debug("Message 1");
+ * $root->warn("Message 2");
+ *
+ * would yield the output
+ * + * DEBUG [main]: Message 1 + * WARN [main]: Message 2 + *+ * + *
Note that there is no explicit separator between text and conversion specifiers.
+ * + *The pattern parser knows when it has reached the end of a conversion specifier when it reads a conversion character. + * In the example above the conversion specifier %-5p means the priority of the logging event should be + * left justified to a width of five characters.
+ * + * Not all log4j conversion characters are implemented. The recognized conversion characters are: + * - c Used to output the category of the logging event. The category conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets. + * If a precision specifier is given, then only the corresponding number of right most components of the category name will be printed. + * By default the category name is printed in full. + * For example, for the category name "a.b.c" the pattern %c{2} will output "b.c". + * - C Used to output the fully qualified class name of the caller issuing the logging request. + * This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets. + * If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. + * By default the class name is output in fully qualified form. + * For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass". + * - d Used to output the date of the logging event. + * The date conversion specifier may be followed by a date format specifier enclosed between braces. + * The format specifier follows the {@link PHP_MANUAL#date} function. + * Note that the special character u is used to as microseconds replacement (to avoid replacement, + * use \u). + * For example, %d{H:i:s,u} or %d{d M Y H:i:s,u}. If no date format specifier is given then ISO8601 format is assumed. + * The date format specifier admits the same syntax as the time pattern string of the SimpleDateFormat. + * It is recommended to use the predefined log4php date formatters. + * These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying + * AbsoluteTimeDateFormat, DateTimeDateFormat and respectively ISO8601DateFormat. + * For example, %d{ISO8601} or %d{ABSOLUTE}. + * - F Used to output the file name where the logging request was issued. + * - l Used to output location information of the caller which generated the logging event. + * - L Used to output the line number from where the logging request was issued. + * - m Used to output the application supplied message associated with the logging event. + * - M Used to output the method name where the logging request was issued. + * - p Used to output the priority of the logging event. + * - r Used to output the number of milliseconds elapsed since the start of + * the application until the creation of the logging event. + * - t Used to output the name of the thread that generated the logging event. + * - x Used to output the NDC (nested diagnostic context) associated with + * the thread that generated the logging event. + * - X Used to output the MDC (mapped diagnostic context) associated with + * the thread that generated the logging event. + * The X conversion character must be followed by the key for the map placed between braces, + * as in %X{clientNumber} where clientNumber is the key. + * The value in the MDC corresponding to the key will be output. + * See {@link LoggerMDC} class for more details. + * - % The sequence %% outputs a single percent sign. + * + *By default the relevant information is output as is. + * However, with the aid of format modifiers it is possible to change the minimum field width, + * the maximum field width and justification.
+ * + *The optional format modifier is placed between the percent sign and the conversion character.
+ *The first optional format modifier is the left justification flag which is just the minus (-) character. + * Then comes the optional minimum field width modifier. + * This is a decimal constant that represents the minimum number of characters to output. + * If the data item requires fewer characters, it is padded on either the left or the right until the minimum width is reached. The default is to pad on the left (right justify) but you can specify right padding with the left justification flag. The padding character is space. If the data item is larger than the minimum field width, the field is expanded to accommodate the data. + * The value is never truncated.
+ * + *This behavior can be changed using the maximum field width modifier which is designated by a period + * followed by a decimal constant. + * If the data item is longer than the maximum field, + * then the extra characters are removed from the beginning of the data item and not from the end. + * For example, it the maximum field width is eight and the data item is ten characters long, + * then the first two characters of the data item are dropped. + * This behavior deviates from the printf function in C where truncation is done from the end.
+ * + *Below are various format modifier examples for the category conversion specifier.
+ *+ * Format modifier left justify minimum width maximum width comment + * %20c false 20 none Left pad with spaces if the category name + * is less than 20 characters long. + * %-20c true 20 none Right pad with spaces if the category name + * is less than 20 characters long. + * %.30c NA none 30 Truncate from the beginning if the category name + * is longer than 30 characters. + * %20.30c false 20 30 Left pad with spaces if the category name + * is shorter than 20 characters. + * However, if category name is longer than 30 chars, + * then truncate from the beginning. + * %-20.30c true 20 30 Right pad with spaces if the category name is + * shorter than 20 chars. + * However, if category name is longer than 30 chars, + * then truncate from the beginning. + *+ * + * @author VxR
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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage layouts + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +define('LOG4PHP_LOGGER_XML_LAYOUT_LOG4J_NS_PREFIX', 'log4j'); +define('LOG4PHP_LOGGER_XML_LAYOUT_LOG4J_NS', 'http://jakarta.apache.org/log4j/'); + +define('LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS_PREFIX', 'log4php'); +define('LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS', 'http://www.vxr.it/log4php/'); + +/** + */ +require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); +require_once(LOG4PHP_DIR . '/helpers/LoggerTransform.php'); +require_once(LOG4PHP_DIR . '/LoggerLayout.php'); + +/** + * The output of the LoggerXmlLayout consists of a series of log4php:event elements. + * + *Parameters: {@link $locationInfo}.
+ * + *It does not output a complete well-formed XML file. + * The output is designed to be included as an external entity in a separate file to form + * a correct XML file.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage or + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/or/LoggerObjectRenderer.php'); + +/** + * The default Renderer renders objects by type casting + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage or + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + * Subclass this abstract class in order to render objects as strings. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage or + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/or/LoggerDefaultRenderer.php'); +require_once(LOG4PHP_DIR . '/or/LoggerObjectRenderer.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Map class objects to an {@link LoggerObjectRenderer}. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage spi + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); + +/** + * Special level value signifying inherited behaviour. The current + * value of this string constant is inherited. + * {@link LOG4PHP_LOGGER_CONFIGURATOR_NULL} is a synonym. + */ +define('LOG4PHP_LOGGER_CONFIGURATOR_INHERITED', 'inherited'); + +/** + * Special level signifying inherited behaviour, same as + * {@link LOG4PHP_LOGGER_CONFIGURATOR_INHERITED}. + * The current value of this string constant is null. + */ +define('LOG4PHP_LOGGER_CONFIGURATOR_NULL', 'null'); + +/** + * Implemented by classes capable of configuring log4php using a URL. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage spi + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); + +require_once(LOG4PHP_DIR . '/LoggerLog.php'); + +/** + * Extend and implement this abstract class to create new instances of + * {@link Logger} or a sub-class of {@link Logger}. + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage spi + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + * The log event must be logged immediately without consulting with + * the remaining filters, if any, in the chain. + */ +define('LOG4PHP_LOGGER_FILTER_ACCEPT', 1); + +/** + * This filter is neutral with respect to the log event. The + * remaining filters, if any, should be consulted for a final decision. + */ +define('LOG4PHP_LOGGER_FILTER_NEUTRAL', 0); + +/** + * The log event must be dropped immediately without consulting + * with the remaining filters, if any, in the chain. + */ +define('LOG4PHP_LOGGER_FILTER_DENY', -1); + +/** + * Users should extend this class to implement customized logging + * event filtering. Note that {@link LoggerCategory} and {@link LoggerAppenderSkeleton}, + * the parent class of all standard + * appenders, have built-in filtering rules. It is suggested that you + * first use and understand the built-in rules before rushing to write + * your own custom filters. + * + *This abstract class assumes and also imposes that filters be + * organized in a linear chain. The {@link #decide + * decide(LoggerLoggingEvent)} method of each filter is called sequentially, + * in the order of their addition to the chain. + * + *
The {@link decide()} method must return one + * of the integer constants {@link LOG4PHP_LOG4PHP_LOGGER_FILTER_DENY}, + * {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} or {@link LOG4PHP_LOGGER_FILTER_ACCEPT}. + * + *
If the value {@link LOG4PHP_LOGGER_FILTER_DENY} is returned, then the log event is + * dropped immediately without consulting with the remaining + * filters. + * + *
If the value {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} is returned, then the next filter + * in the chain is consulted. If there are no more filters in the + * chain, then the log event is logged. Thus, in the presence of no + * filters, the default behaviour is to log all logging events. + * + *
If the value {@link LOG4PHP_LOGGER_FILTER_ACCEPT} is returned, then the log + * event is logged without consulting the remaining filters. + * + *
The philosophy of log4php filters is largely inspired from the
+ * Linux ipchains.
+ *
+ * @author VxR If the decision is {@link LOG4PHP_LOGGER_FILTER_DENY}, then the event will be
+ * dropped. If the decision is {@link LOG4PHP_LOGGER_FILTER_NEUTRAL}, then the next
+ * filter, if any, will be invoked. If the decision is {@link LOG4PHP_LOGGER_FILTER_ACCEPT} then
+ * the event will be logged without consulting with other filters in
+ * the chain.
+ *
+ * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon.
+ * @return integer {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} or {@link LOG4PHP_LOGGER_FILTER_DENY}|{@link LOG4PHP_LOGGER_FILTER_ACCEPT}
+ */
+ function decide($event)
+ {
+ return LOG4PHP_LOGGER_FILTER_NEUTRAL;
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/log4php.debug/spi/LoggerLocationInfo.php b/oss/vtiger/trunk/log4php.debug/spi/LoggerLocationInfo.php
new file mode 100644
index 00000000..cc461337
--- /dev/null
+++ b/oss/vtiger/trunk/log4php.debug/spi/LoggerLocationInfo.php
@@ -0,0 +1,116 @@
+This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details). 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}). PHP port, extensions and modifications by VxR. All rights reserved. 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. This information is not always available.
+ */
+ function getFileName()
+ {
+ return ($this->fileName === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->fileName;
+ }
+
+ /**
+ * Returns the line number of the caller.
+ * This information is not always available.
+ */
+ function getLineNumber()
+ {
+ return ($this->lineNumber === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->lineNumber;
+ }
+
+ /**
+ * Returns the method name of the caller.
+ */
+ function getMethodName()
+ {
+ return ($this->methodName === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->methodName;
+ }
+}
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/log4php.debug/spi/LoggerLoggingEvent.php b/oss/vtiger/trunk/log4php.debug/spi/LoggerLoggingEvent.php
new file mode 100644
index 00000000..d842c0f6
--- /dev/null
+++ b/oss/vtiger/trunk/log4php.debug/spi/LoggerLoggingEvent.php
@@ -0,0 +1,384 @@
+This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details). 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}). PHP port, extensions and modifications by VxR. All rights reserved. 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. This field should not be accessed directly. You shoud use the
+ * {@link getLevel()} method instead.
+ *
+ * @deprecated
+ * @var LoggerLevel
+ */
+ var $level;
+
+ /**
+ * @var string The nested diagnostic context (NDC) of logging event.
+ */
+ var $ndc;
+
+ /**
+ * Have we tried to do an NDC lookup? If we did, there is no need
+ * to do it again. Note that its value is always false when
+ * serialized. Thus, a receiving SocketNode will never use it's own
+ * (incorrect) NDC. See also writeObject method.
+ * @var boolean
+ */
+ var $ndcLookupRequired = true;
+
+ /**
+ * Have we tried to do an MDC lookup? If we did, there is no need
+ * to do it again. Note that its value is always false when
+ * serialized. See also the getMDC and getMDCCopy methods.
+ * @var boolean
+ */
+ var $mdcCopyLookupRequired = true;
+
+ /**
+ * @var mixed The application supplied message of logging event.
+ */
+ var $message;
+
+ /**
+ * The application supplied message rendered through the log4php
+ * objet rendering mechanism. At present renderedMessage == message.
+ * @var string
+ */
+ var $renderedMessage;
+
+ /**
+ * The name of thread in which this logging event was generated.
+ * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()}
+ * @var mixed
+ */
+ var $threadName = null;
+
+ /**
+ * The number of seconds elapsed from 1/1/1970 until logging event
+ * was created plus microseconds if available.
+ * @var float
+ */
+ var $timeStamp;
+
+ /**
+ * @var LoggerLocationInfo Location information for the caller.
+ */
+ var $locationInfo = null;
+
+ // Serialization
+ /*
+ var $serialVersionUID = -868428216207166145L;
+ var $PARAM_ARRAY = array();
+ var $TO_LEVEL = "toLevel";
+ var $TO_LEVEL_PARAMS = null;
+ var $methodCache = array(); // use a tiny table
+ */
+
+ /**
+ * Instantiate a LoggingEvent from the supplied parameters.
+ *
+ * Except {@link $timeStamp} all the other fields of
+ * LoggerLoggingEvent are filled when actually needed.
+ *
+ * @param string $fqcn name of the caller class.
+ * @param mixed &$logger The {@link Logger} category of this event or the logger name.
+ * @param LoggerLevel $priority The level of this event.
+ * @param mixed $message The message of this event.
+ * @param integer $timeStamp the timestamp of this logging event.
+ */
+ function LoggerLoggingEvent($fqcn, &$logger, $priority, $message, $timeStamp = null)
+ {
+ $this->fqcn = $fqcn;
+ if (is_a($logger, 'logger')) {
+ $this->logger =& $logger;
+ $this->categoryName = $logger->getName();
+ } else {
+ $this->categoryName = (string)$logger;
+ }
+ $this->level = $priority;
+ $this->message = $message;
+ if ($timeStamp !== null and is_float($timeStamp)) {
+ $this->timeStamp = $timeStamp;
+ } else {
+ if (function_exists('microtime')) {
+ list($usecs, $secs) = explode(' ', microtime());
+ $this->timeStamp = ((float)$usecs + (float)$secs);
+ } else {
+ $this->timeStamp = time();
+ }
+ }
+ }
+
+ /**
+ * Set the location information for this logging event. The collected
+ * information is cached for future use.
+ *
+ * This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
+ * to collect informations about caller. It only recognize informations generated by {@link Logger} and its subclasses. Before serialization, the returned object is the message
+ * passed by the user to generate the logging event. After
+ * serialization, the returned value equals the String form of the
+ * message possibly after object rendering.
+ * @return mixed
+ */
+ function getMessage()
+ {
+ if($this->message !== null) {
+ return $this->message;
+ } else {
+ return $this->getRenderedMessage();
+ }
+ }
+
+ /**
+ * This method returns the NDC for this event. It will return the
+ * correct content even if the event was generated in a different
+ * thread or even on a different machine. The {@link LoggerNDC::get()} method
+ * should never be called directly.
+ * @return string
+ */
+ function getNDC()
+ {
+ if ($this->ndcLookupRequired) {
+ $this->ndcLookupRequired = false;
+ $this->ndc = implode(' ',LoggerNDC::get());
+ }
+ return $this->ndc;
+ }
+
+
+ /**
+ * Returns the the context corresponding to the 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}). PHP port, extensions and modifications by VxR. All rights reserved. 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. You can add this filter to the end of a filter chain to
+ * switch from the default "accept all unless instructed otherwise"
+ * filtering behaviour to a "deny all unless instructed otherwise"
+ * behaviour.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.key
+ * parameter.
+ * @return string
+ */
+ function getMDC($key)
+ {
+ return LoggerMDC::get($key);
+ }
+
+ /**
+ * Render message.
+ * @return string
+ */
+ function getRenderedMessage()
+ {
+ if($this->renderedMessage === null and $this->message !== null) {
+ if (is_string($this->message)) {
+ $this->renderedMessage = $this->message;
+ } else {
+ if ($this->logger !== null) {
+ $repository =& $this->logger->getLoggerRepository();
+ } else {
+ $repository =& LoggerManager::getLoggerRepository();
+ }
+ if (method_exists($repository, 'getrenderermap')) {
+ $rendererMap =& $repository->getRendererMap();
+ $this->renderedMessage= $rendererMap->findAndRender($this->message);
+ } else {
+ $this->renderedMessage = (string)$this->message;
+ }
+ }
+ }
+ return $this->renderedMessage;
+ }
+
+ /**
+ * Returns the time when the application started, in seconds
+ * elapsed since 01.01.1970 plus microseconds if available.
+ *
+ * @return float
+ * @static
+ */
+ function getStartTime()
+ {
+ static $startTime;
+
+ if (!isset($startTime)) {
+ if (function_exists('microtime')) {
+ list($usec, $sec) = explode(' ', microtime());
+ $startTime = ((float)$usec + (float)$sec);
+ } else {
+ $startTime = time();
+ }
+ }
+ return $startTime;
+ }
+
+ /**
+ * @return float
+ */
+ function getTimeStamp()
+ {
+ return $this->timeStamp;
+ }
+
+ /**
+ * @return mixed
+ */
+ function getThreadName()
+ {
+ if ($this->threadName === null)
+ $this->threadName = (string)getmypid();
+ return $this->threadName;
+ }
+
+ /**
+ * @return mixed null
+ */
+ function getThrowableInformation()
+ {
+ return null;
+ }
+
+ /**
+ * Serialize this object
+ * @return string
+ */
+ function toString()
+ {
+ serialize($this);
+ }
+
+ /**
+ * Avoid serialization of the {@link $logger} object
+ */
+ function __sleep()
+ {
+ return array(
+ 'fqcn','categoryName',
+ 'level',
+ 'ndc','ndcLookupRequired',
+ 'message','renderedMessage',
+ 'threadName',
+ 'timestamp',
+ 'locationInfo'
+ );
+ }
+
+}
+
+LoggerLoggingEvent::getStartTime();
+
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/log4php.debug/varia/LoggerDenyAllFilter.php b/oss/vtiger/trunk/log4php.debug/varia/LoggerDenyAllFilter.php
new file mode 100644
index 00000000..ce8699f9
--- /dev/null
+++ b/oss/vtiger/trunk/log4php.debug/varia/LoggerDenyAllFilter.php
@@ -0,0 +1,57 @@
+This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage varia + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); +require_once(LOG4PHP_DIR . '/spi/LoggerFilter.php'); + +/** + * This is a very simple filter based on level matching. + * + *The filter admits two options LevelToMatch and + * AcceptOnMatch. If there is an exact match between the value + * of the LevelToMatch option and the level of the + * {@link LoggerLoggingEvent}, then the {@link decide()} method returns + * {@link LOG4PHP_LOGGER_FILTER_ACCEPT} in case the AcceptOnMatch + * option value is set to true, if it is false then + * {@link LOG4PHP_LOGGER_FILTER_DENY} is returned. If there is no match, + * {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} is returned.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage varia + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); +require_once(LOG4PHP_DIR . '/spi/LoggerFilter.php'); + +/** + * This is a very simple filter based on level matching, which can be + * used to reject messages with priorities outside a certain range. + * + *The filter admits three options LevelMin, LevelMax + * and AcceptOnMatch.
+ * + *If the level of the {@link LoggerLoggingEvent} is not between Min and Max + * (inclusive), then {@link LOG4PHP_LOGGER_FILTER_DENY} is returned.
+ * + *If the Logging event level is within the specified range, then if + * AcceptOnMatch is true, + * {@link LOG4PHP_LOGGER_FILTER_ACCEPT} is returned, and if + * AcceptOnMatch is false, + * {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} is returned.
+ * + *If LevelMin is not defined, then there is no + * minimum acceptable level (ie a level is never rejected for + * being too "low"/unimportant). If LevelMax is not + * defined, then there is no maximum acceptable level (ie a + * level is never rejected for beeing too "high"/important).
+ * + *Refer to the {@link LoggerAppenderSkeleton::setThreshold()} method + * available to all appenders extending {@link LoggerAppenderSkeleton} + * for a more convenient way to filter out events by level.
+ * + * @log4j-class org.apache.log4j.varia.LevelRangeFilter + * @log4j-author Simon Kitching + * @log4j-author based on code by Ceki Gülcü + * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage varia + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +/** + */ +require_once(LOG4PHP_DIR . '/spi/LoggerFilter.php'); + +/** + * This is a very simple filter based on string matching. + * + *The filter admits two options {@link $stringToMatch} and + * {@link $acceptOnMatch}. If there is a match (using {@link PHP_MANUAL#strpos} + * between the value of the {@link $stringToMatch} option and the message + * of the {@link LoggerLoggingEvent}, + * then the {@link decide()} method returns {@link LOG4PHP_LOGGER_FILTER_ACCEPT} if + * the AcceptOnMatch option value is true, if it is false then + * {@link LOG4PHP_LOGGER_FILTER_DENY} is returned. If there is no match, {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} + * is returned.
+ * + * @author VxRDesign, 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}).
+ * + *PHP port, extensions and modifications by VxR. All rights reserved.
+ * For more information, please see {@link http://www.vxr.it/log4php/}.
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.
+ * + * @package log4php + * @subpackage xml + */ + +/** + * @ignore + */ +if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); + +require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); +require_once(LOG4PHP_DIR . '/or/LoggerObjectRenderer.php'); +require_once(LOG4PHP_DIR . '/spi/LoggerConfigurator.php'); +require_once(LOG4PHP_DIR . '/LoggerAppender.php'); +require_once(LOG4PHP_DIR . '/LoggerLayout.php'); +require_once(LOG4PHP_DIR . '/LoggerLog.php'); +require_once(LOG4PHP_DIR . '/LoggerManager.php'); + +define('LOG4PHP_LOGGER_DOM_CONFIGURATOR_APPENDER_STATE', 1000); +define('LOG4PHP_LOGGER_DOM_CONFIGURATOR_LAYOUT_STATE', 1010); +define('LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE', 1020); +define('LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE', 1030); +define('LOG4PHP_LOGGER_DOM_CONFIGURATOR_FILTER_STATE', 1040); + +define('LOG4PHP_LOGGER_DOM_CONFIGURATOR_DEFAULT_FILENAME', './log4php.xml'); + +/** + * @var string the default configuration document + */ +define('LOG4PHP_LOGGER_DOM_CONFIGURATOR_DEFAULT_CONFIGURATION', +' +Read the log4php.dtd included in the documentation directory. Note that + * php parser does not validate the document.
+ * + *Sometimes it is useful to see how log4php is reading configuration + * files. You can enable log4php internal logging by setting the debug + * attribute in the log4php:configuration element. As in + *
+ * <log4php:configuration debug="true" xmlns:log4php="http://www.vxr.it/log4php/"> + * ... + * </log4php:configuration> + *+ * + *
There are sample XML files included in the package under tests/ + * subdirectories.
+ * + * @author VxR