123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
-
- require_once(LOG4PHP_DIR . '/LoggerLog.php');
- define('LOGGER_MDC_HT_SIZE', 7);
- $GLOBALS['log4php.LoggerMDC.ht'] = array();
- class LoggerMDC {
-
-
- function put($key, $value)
- {
- if ( sizeof($GLOBALS['log4php.LoggerMDC.ht']) < LOGGER_MDC_HT_SIZE )
- $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value;
- }
-
-
- function get($key)
- {
- LoggerLog::debug("LoggerMDC::get() key='$key'");
-
- if (!empty($key)) {
- if (strpos($key, 'server.') === 0) {
- $varName = substr($key, 7);
-
- LoggerLog::debug("LoggerMDC::get() a _SERVER[$varName] is requested.");
-
- return $_SERVER[$varName];
- } elseif (strpos($key, 'env.') === 0) {
- $varName = substr($key, 4);
-
- LoggerLog::debug("LoggerMDC::get() a _ENV[$varName] is requested.");
-
- return $_ENV[$varName];
- } elseif (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) {
-
- LoggerLog::debug("LoggerMDC::get() a user key is requested.");
-
- return $GLOBALS['log4php.LoggerMDC.ht'][$key];
- }
- }
- return '';
- }
-
- function remove($key)
- {
- unset($GLOBALS['log4php.LoggerMDC.ht'][$key]);
- }
- }
- ?>
|