123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <?php
- if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
- require_once(LOG4PHP_DIR . '/LoggerHierarchy.php');
- class LoggerManager {
-
- function exists($name)
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->exists($name);
- }
-
- function getCurrentLoggers()
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->getCurrentLoggers();
- }
-
-
- function &getRootLogger()
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->getRootLogger();
- }
-
-
- function &getLogger($name, $factory = null)
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->getLogger($name, $factory);
- }
-
-
- function &getLoggerRepository()
- {
- return LoggerHierarchy::singleton();
- }
-
-
- function resetConfiguration()
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->resetConfiguration();
- }
-
-
- function setRepositorySelector($selector, $guard)
- {
- return;
- }
-
-
- function shutdown()
- {
- $repository =& LoggerManager::getLoggerRepository();
- return $repository->shutdown();
- }
- }
- if (!defined('LOG4PHP_DEFAULT_INIT_OVERRIDE')) {
- if (isset($_ENV['log4php.defaultInitOverride'])) {
-
- define('LOG4PHP_DEFAULT_INIT_OVERRIDE',
- LoggerOptionConverter::toBoolean($_ENV['log4php.defaultInitOverride'], false)
- );
- } elseif (isset($GLOBALS['log4php.defaultInitOverride'])) {
-
- define('LOG4PHP_DEFAULT_INIT_OVERRIDE',
- LoggerOptionConverter::toBoolean($GLOBALS['log4php.defaultInitOverride'], false)
- );
- } else {
-
- define('LOG4PHP_DEFAULT_INIT_OVERRIDE', false);
- }
- }
- if (!defined('LOG4PHP_CONFIGURATION')) {
- if (isset($_ENV['log4php.configuration'])) {
-
- define('LOG4PHP_CONFIGURATION', trim($_ENV['log4php.configuration']));
- } else {
-
- define('LOG4PHP_CONFIGURATION', 'log4php.properties');
- }
- }
- if (!defined('LOG4PHP_CONFIGURATOR_CLASS')) {
- if ( strtolower(substr( LOG4PHP_CONFIGURATION, -4 )) == '.xml') {
-
- define('LOG4PHP_CONFIGURATOR_CLASS', LOG4PHP_DIR . '/xml/LoggerDOMConfigurator');
- } else {
-
- define('LOG4PHP_CONFIGURATOR_CLASS', LOG4PHP_DIR . '/LoggerPropertyConfigurator');
- }
- }
- if (!LOG4PHP_DEFAULT_INIT_OVERRIDE) {
- if (!LoggerManagerDefaultInit())
- LoggerLog::warn("LOG4PHP main() Default Init failed.");
- }
- 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;
- }
- }
- ?>
|