@@ -46,94 +46,94 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | class LoggerAppenderConsole extends LoggerAppenderSkeleton { |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Can be 'php://stdout' or 'php://stderr'. But it's better to use keywords <b>STDOUT</b> and <b>STDERR</b> (case insensitive). |
|
| 51 | - * Default is STDOUT |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - var $target = 'php://stdout'; |
|
| 49 | + /** |
|
| 50 | + * Can be 'php://stdout' or 'php://stderr'. But it's better to use keywords <b>STDOUT</b> and <b>STDERR</b> (case insensitive). |
|
| 51 | + * Default is STDOUT |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + var $target = 'php://stdout'; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var boolean |
|
| 58 | - * @access private |
|
| 59 | - */ |
|
| 60 | - var $requiresLayout = true; |
|
| 56 | + /** |
|
| 57 | + * @var boolean |
|
| 58 | + * @access private |
|
| 59 | + */ |
|
| 60 | + var $requiresLayout = true; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @var mixed the resource used to open stdout/stderr |
|
| 64 | - * @access private |
|
| 65 | - */ |
|
| 66 | - var $fp = false; |
|
| 62 | + /** |
|
| 63 | + * @var mixed the resource used to open stdout/stderr |
|
| 64 | + * @access private |
|
| 65 | + */ |
|
| 66 | + var $fp = false; |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Constructor. |
|
| 70 | - * |
|
| 71 | - * @param string $name appender name |
|
| 72 | - */ |
|
| 73 | - public function LoggerAppenderConsole($name) |
|
| 74 | - { |
|
| 75 | - $this->LoggerAppenderSkeleton($name); |
|
| 76 | - } |
|
| 68 | + /** |
|
| 69 | + * Constructor. |
|
| 70 | + * |
|
| 71 | + * @param string $name appender name |
|
| 72 | + */ |
|
| 73 | + public function LoggerAppenderConsole($name) |
|
| 74 | + { |
|
| 75 | + $this->LoggerAppenderSkeleton($name); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Set console target. |
|
| 80 | - * @param mixed $value a constant or a string |
|
| 81 | - */ |
|
| 82 | - public function setTarget($value) |
|
| 83 | - { |
|
| 84 | - $v = trim($value); |
|
| 85 | - if ($v == LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT || strtoupper($v) == 'STDOUT') { |
|
| 86 | - $this->target = LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT; |
|
| 87 | - } elseif ($v == LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT || strtoupper($v) == 'STDERR') { |
|
| 88 | - $target = LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT; |
|
| 89 | - } else { |
|
| 90 | - LoggerLog::debug( |
|
| 91 | - "LoggerAppenderConsole::targetWarn() ". |
|
| 92 | - "Invalid target. Using '".LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT."' by default." |
|
| 93 | - ); |
|
| 94 | - } |
|
| 95 | - } |
|
| 78 | + /** |
|
| 79 | + * Set console target. |
|
| 80 | + * @param mixed $value a constant or a string |
|
| 81 | + */ |
|
| 82 | + public function setTarget($value) |
|
| 83 | + { |
|
| 84 | + $v = trim($value); |
|
| 85 | + if ($v == LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT || strtoupper($v) == 'STDOUT') { |
|
| 86 | + $this->target = LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT; |
|
| 87 | + } elseif ($v == LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT || strtoupper($v) == 'STDERR') { |
|
| 88 | + $target = LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT; |
|
| 89 | + } else { |
|
| 90 | + LoggerLog::debug( |
|
| 91 | + "LoggerAppenderConsole::targetWarn() ". |
|
| 92 | + "Invalid target. Using '".LOG4PHP_LOGGER_APPENDER_CONSOLE_STDOUT."' by default." |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public function getTarget() |
|
| 98 | - { |
|
| 99 | - return $this->target; |
|
| 100 | - } |
|
| 97 | + public function getTarget() |
|
| 98 | + { |
|
| 99 | + return $this->target; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - public function activateOptions() |
|
| 103 | - { |
|
| 104 | - LoggerLog::debug("LoggerAppenderConsole::activateOptions()"); |
|
| 102 | + public function activateOptions() |
|
| 103 | + { |
|
| 104 | + LoggerLog::debug("LoggerAppenderConsole::activateOptions()"); |
|
| 105 | 105 | |
| 106 | - $this->fp = @fopen($this->getTarget(), 'w'); |
|
| 106 | + $this->fp = @fopen($this->getTarget(), 'w'); |
|
| 107 | 107 | |
| 108 | - if ($this->fp && $this->layout !== null) |
|
| 109 | - @fwrite($this->fp, $this->layout->getHeader()); |
|
| 108 | + if ($this->fp && $this->layout !== null) |
|
| 109 | + @fwrite($this->fp, $this->layout->getHeader()); |
|
| 110 | 110 | |
| 111 | - $this->closed = (bool)($this->fp === false); |
|
| 112 | - } |
|
| 111 | + $this->closed = (bool)($this->fp === false); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * @see LoggerAppender::close() |
|
| 116 | - */ |
|
| 117 | - public function close() |
|
| 118 | - { |
|
| 119 | - LoggerLog::debug("LoggerAppenderConsole::close()"); |
|
| 114 | + /** |
|
| 115 | + * @see LoggerAppender::close() |
|
| 116 | + */ |
|
| 117 | + public function close() |
|
| 118 | + { |
|
| 119 | + LoggerLog::debug("LoggerAppenderConsole::close()"); |
|
| 120 | 120 | |
| 121 | - if ($this->fp && $this->layout !== null) { |
|
| 122 | - @fwrite($this->fp, $this->layout->getFooter()); |
|
| 123 | - } |
|
| 124 | - @fclose($this->fp); |
|
| 125 | - $this->closed = true; |
|
| 126 | - } |
|
| 121 | + if ($this->fp && $this->layout !== null) { |
|
| 122 | + @fwrite($this->fp, $this->layout->getFooter()); |
|
| 123 | + } |
|
| 124 | + @fclose($this->fp); |
|
| 125 | + $this->closed = true; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - public function append($event) |
|
| 129 | - { |
|
| 130 | - if ($this->fp && $this->layout !== null) { |
|
| 128 | + public function append($event) |
|
| 129 | + { |
|
| 130 | + if ($this->fp && $this->layout !== null) { |
|
| 131 | 131 | |
| 132 | - LoggerLog::debug("LoggerAppenderConsole::append()"); |
|
| 132 | + LoggerLog::debug("LoggerAppenderConsole::append()"); |
|
| 133 | 133 | |
| 134 | - @fwrite($this->fp, $this->layout->format($event)); |
|
| 135 | - } |
|
| 136 | - } |
|
| 134 | + @fwrite($this->fp, $this->layout->format($event)); |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | ?> |
| 140 | 140 | \ No newline at end of file |
@@ -31,68 +31,68 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class LoggerLayout { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Creates LoggerLayout instances with the given class name. |
|
| 36 | - * |
|
| 37 | - * @param string $class |
|
| 38 | - * @return LoggerLayout |
|
| 39 | - */ |
|
| 40 | - public function factory($class) |
|
| 41 | - { |
|
| 42 | - if (!empty($class)) { |
|
| 43 | - $class = basename($class); |
|
| 44 | - if (!class_exists($class)) |
|
| 45 | - @include_once(LOG4PHP_DIR . "/layouts/{$class}.php"); |
|
| 46 | - if (class_exists($class)) |
|
| 47 | - return new $class(); |
|
| 48 | - } |
|
| 49 | - return null; |
|
| 50 | - } |
|
| 34 | + /** |
|
| 35 | + * Creates LoggerLayout instances with the given class name. |
|
| 36 | + * |
|
| 37 | + * @param string $class |
|
| 38 | + * @return LoggerLayout |
|
| 39 | + */ |
|
| 40 | + public function factory($class) |
|
| 41 | + { |
|
| 42 | + if (!empty($class)) { |
|
| 43 | + $class = basename($class); |
|
| 44 | + if (!class_exists($class)) |
|
| 45 | + @include_once(LOG4PHP_DIR . "/layouts/{$class}.php"); |
|
| 46 | + if (class_exists($class)) |
|
| 47 | + return new $class(); |
|
| 48 | + } |
|
| 49 | + return null; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Override this method |
|
| 54 | - */ |
|
| 55 | - public function activateOptions() |
|
| 56 | - { |
|
| 57 | - // override; |
|
| 58 | - } |
|
| 52 | + /** |
|
| 53 | + * Override this method |
|
| 54 | + */ |
|
| 55 | + public function activateOptions() |
|
| 56 | + { |
|
| 57 | + // override; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Override this method to create your own layout format. |
|
| 62 | - * |
|
| 63 | - * @param LoggerLoggingEvent |
|
| 64 | - * @return string |
|
| 65 | - */ |
|
| 66 | - public function format($event) |
|
| 67 | - { |
|
| 68 | - return $event->getRenderedMessage(); |
|
| 69 | - } |
|
| 60 | + /** |
|
| 61 | + * Override this method to create your own layout format. |
|
| 62 | + * |
|
| 63 | + * @param LoggerLoggingEvent |
|
| 64 | + * @return string |
|
| 65 | + */ |
|
| 66 | + public function format($event) |
|
| 67 | + { |
|
| 68 | + return $event->getRenderedMessage(); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Returns the content type output by this layout. |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 75 | - public function getContentType() |
|
| 76 | - { |
|
| 77 | - return "text/plain"; |
|
| 78 | - } |
|
| 71 | + /** |
|
| 72 | + * Returns the content type output by this layout. |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | + public function getContentType() |
|
| 76 | + { |
|
| 77 | + return "text/plain"; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Returns the footer for the layout format. |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function getFooter() |
|
| 85 | - { |
|
| 86 | - return null; |
|
| 87 | - } |
|
| 80 | + /** |
|
| 81 | + * Returns the footer for the layout format. |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function getFooter() |
|
| 85 | + { |
|
| 86 | + return null; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Returns the header for the layout format. |
|
| 91 | - * @return string |
|
| 92 | - */ |
|
| 93 | - public function getHeader() |
|
| 94 | - { |
|
| 95 | - return null; |
|
| 96 | - } |
|
| 89 | + /** |
|
| 90 | + * Returns the header for the layout format. |
|
| 91 | + * @return string |
|
| 92 | + */ |
|
| 93 | + public function getHeader() |
|
| 94 | + { |
|
| 95 | + return null; |
|
| 96 | + } |
|
| 97 | 97 | } |
| 98 | 98 | ?> |
| 99 | 99 | \ No newline at end of file |
@@ -84,526 +84,526 @@ |
||
| 84 | 84 | */ |
| 85 | 85 | class LoggerDOMConfigurator extends LoggerConfigurator { |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @var LoggerHierarchy |
|
| 89 | - */ |
|
| 90 | - var $repository; |
|
| 87 | + /** |
|
| 88 | + * @var LoggerHierarchy |
|
| 89 | + */ |
|
| 90 | + var $repository; |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * @var array state stack |
|
| 94 | - */ |
|
| 95 | - var $state; |
|
| 92 | + /** |
|
| 93 | + * @var array state stack |
|
| 94 | + */ |
|
| 95 | + var $state; |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * @var Logger parsed Logger |
|
| 99 | - */ |
|
| 100 | - var $logger; |
|
| 97 | + /** |
|
| 98 | + * @var Logger parsed Logger |
|
| 99 | + */ |
|
| 100 | + var $logger; |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * @var LoggerAppender parsed LoggerAppender |
|
| 104 | - */ |
|
| 105 | - var $appender; |
|
| 102 | + /** |
|
| 103 | + * @var LoggerAppender parsed LoggerAppender |
|
| 104 | + */ |
|
| 105 | + var $appender; |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * @var LoggerFilter parsed LoggerFilter |
|
| 109 | - */ |
|
| 110 | - var $filter; |
|
| 107 | + /** |
|
| 108 | + * @var LoggerFilter parsed LoggerFilter |
|
| 109 | + */ |
|
| 110 | + var $filter; |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * @var LoggerLayout parsed LoggerLayout |
|
| 114 | - */ |
|
| 115 | - var $layout; |
|
| 112 | + /** |
|
| 113 | + * @var LoggerLayout parsed LoggerLayout |
|
| 114 | + */ |
|
| 115 | + var $layout; |
|
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Constructor |
|
| 119 | - */ |
|
| 120 | - public function LoggerDOMConfigurator() |
|
| 121 | - { |
|
| 122 | - $this->state = array(); |
|
| 123 | - $this->logger = null; |
|
| 124 | - $this->appender = null; |
|
| 125 | - $this->filter = null; |
|
| 126 | - $this->layout = null; |
|
| 127 | - } |
|
| 117 | + /** |
|
| 118 | + * Constructor |
|
| 119 | + */ |
|
| 120 | + public function LoggerDOMConfigurator() |
|
| 121 | + { |
|
| 122 | + $this->state = array(); |
|
| 123 | + $this->logger = null; |
|
| 124 | + $this->appender = null; |
|
| 125 | + $this->filter = null; |
|
| 126 | + $this->layout = null; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Configure the default repository using the resource pointed by <b>url</b>. |
|
| 131 | - * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function. |
|
| 132 | - * Note that the resource will be search with <i>use_include_path</i> parameter |
|
| 133 | - * set to "1". |
|
| 134 | - * |
|
| 135 | - * @param string $url |
|
| 136 | - * @static |
|
| 137 | - */ |
|
| 138 | - public function configure($url = '') |
|
| 139 | - { |
|
| 140 | - $configurator = new LoggerDOMConfigurator(); |
|
| 141 | - $repository =& LoggerManager::getLoggerRepository(); |
|
| 142 | - return $configurator->doConfigure($url, $repository); |
|
| 143 | - } |
|
| 129 | + /** |
|
| 130 | + * Configure the default repository using the resource pointed by <b>url</b>. |
|
| 131 | + * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function. |
|
| 132 | + * Note that the resource will be search with <i>use_include_path</i> parameter |
|
| 133 | + * set to "1". |
|
| 134 | + * |
|
| 135 | + * @param string $url |
|
| 136 | + * @static |
|
| 137 | + */ |
|
| 138 | + public function configure($url = '') |
|
| 139 | + { |
|
| 140 | + $configurator = new LoggerDOMConfigurator(); |
|
| 141 | + $repository =& LoggerManager::getLoggerRepository(); |
|
| 142 | + return $configurator->doConfigure($url, $repository); |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Configure the given <b>repository</b> using the resource pointed by <b>url</b>. |
|
| 147 | - * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function. |
|
| 148 | - * Note that the resource will be search with <i>use_include_path</i> parameter |
|
| 149 | - * set to "1". |
|
| 150 | - * |
|
| 151 | - * @param string $url |
|
| 152 | - * @param LoggerHierarchy &$repository |
|
| 153 | - */ |
|
| 154 | - public function doConfigure($url = '', &$repository) |
|
| 155 | - { |
|
| 156 | - $xmlData = ''; |
|
| 157 | - if (!empty($url)) |
|
| 158 | - $xmlData = implode('', file($url, 1)); |
|
| 159 | - return $this->doConfigureByString($xmlData, $repository); |
|
| 160 | - } |
|
| 145 | + /** |
|
| 146 | + * Configure the given <b>repository</b> using the resource pointed by <b>url</b>. |
|
| 147 | + * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function. |
|
| 148 | + * Note that the resource will be search with <i>use_include_path</i> parameter |
|
| 149 | + * set to "1". |
|
| 150 | + * |
|
| 151 | + * @param string $url |
|
| 152 | + * @param LoggerHierarchy &$repository |
|
| 153 | + */ |
|
| 154 | + public function doConfigure($url = '', &$repository) |
|
| 155 | + { |
|
| 156 | + $xmlData = ''; |
|
| 157 | + if (!empty($url)) |
|
| 158 | + $xmlData = implode('', file($url, 1)); |
|
| 159 | + return $this->doConfigureByString($xmlData, $repository); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Configure the given <b>repository</b> using the configuration written in <b>xmlData</b>. |
|
| 164 | - * Do not call this method directly. Use {@link doConfigure()} instead. |
|
| 165 | - * @param string $xmlData |
|
| 166 | - * @param LoggerHierarchy &$repository |
|
| 167 | - */ |
|
| 168 | - public function doConfigureByString($xmlData, &$repository) |
|
| 169 | - { |
|
| 170 | - return $this->parse($xmlData, $repository); |
|
| 171 | - } |
|
| 162 | + /** |
|
| 163 | + * Configure the given <b>repository</b> using the configuration written in <b>xmlData</b>. |
|
| 164 | + * Do not call this method directly. Use {@link doConfigure()} instead. |
|
| 165 | + * @param string $xmlData |
|
| 166 | + * @param LoggerHierarchy &$repository |
|
| 167 | + */ |
|
| 168 | + public function doConfigureByString($xmlData, &$repository) |
|
| 169 | + { |
|
| 170 | + return $this->parse($xmlData, $repository); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * @param LoggerHierarchy &$repository |
|
| 175 | - */ |
|
| 176 | - public function doConfigureDefault(&$repository) |
|
| 177 | - { |
|
| 178 | - return $this->doConfigureByString(LOG4PHP_LOGGER_DOM_CONFIGURATOR_DEFAULT_CONFIGURATION, $repository); |
|
| 179 | - } |
|
| 173 | + /** |
|
| 174 | + * @param LoggerHierarchy &$repository |
|
| 175 | + */ |
|
| 176 | + public function doConfigureDefault(&$repository) |
|
| 177 | + { |
|
| 178 | + return $this->doConfigureByString(LOG4PHP_LOGGER_DOM_CONFIGURATOR_DEFAULT_CONFIGURATION, $repository); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * @param string $xmlData |
|
| 183 | - */ |
|
| 184 | - public function parse($xmlData, &$repository) |
|
| 185 | - { |
|
| 186 | - // LoggerManager::resetConfiguration(); |
|
| 187 | - $this->repository =& $repository; |
|
| 181 | + /** |
|
| 182 | + * @param string $xmlData |
|
| 183 | + */ |
|
| 184 | + public function parse($xmlData, &$repository) |
|
| 185 | + { |
|
| 186 | + // LoggerManager::resetConfiguration(); |
|
| 187 | + $this->repository =& $repository; |
|
| 188 | 188 | |
| 189 | - $parser = xml_parser_create_ns(); |
|
| 189 | + $parser = xml_parser_create_ns(); |
|
| 190 | 190 | |
| 191 | - xml_set_object($parser, &$this); |
|
| 192 | - xml_set_element_handler($parser, "tagOpen", "tagClose"); |
|
| 191 | + xml_set_object($parser, &$this); |
|
| 192 | + xml_set_element_handler($parser, "tagOpen", "tagClose"); |
|
| 193 | 193 | |
| 194 | - $result = xml_parse($parser, $xmlData, true); |
|
| 195 | - if (!$result) { |
|
| 196 | - $errorCode = xml_get_error_code($parser); |
|
| 197 | - $errorStr = xml_error_string($errorCode); |
|
| 198 | - $errorLine = xml_get_current_line_number($parser); |
|
| 199 | - LoggerLog::warn( |
|
| 200 | - "LoggerDOMConfigurator::parse() ". |
|
| 201 | - "Parsing error [{$errorCode}] {$errorStr}, line {$errorLine}" |
|
| 202 | - ); |
|
| 203 | - $this->repository->resetConfiguration(); |
|
| 204 | - } else { |
|
| 205 | - xml_parser_free($parser); |
|
| 206 | - } |
|
| 207 | - return $result; |
|
| 208 | - } |
|
| 194 | + $result = xml_parse($parser, $xmlData, true); |
|
| 195 | + if (!$result) { |
|
| 196 | + $errorCode = xml_get_error_code($parser); |
|
| 197 | + $errorStr = xml_error_string($errorCode); |
|
| 198 | + $errorLine = xml_get_current_line_number($parser); |
|
| 199 | + LoggerLog::warn( |
|
| 200 | + "LoggerDOMConfigurator::parse() ". |
|
| 201 | + "Parsing error [{$errorCode}] {$errorStr}, line {$errorLine}" |
|
| 202 | + ); |
|
| 203 | + $this->repository->resetConfiguration(); |
|
| 204 | + } else { |
|
| 205 | + xml_parser_free($parser); |
|
| 206 | + } |
|
| 207 | + return $result; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * @param mixed $parser |
|
| 212 | - * @param string $tag |
|
| 213 | - * @param array $attribs |
|
| 214 | - * |
|
| 215 | - * @todo In 'LOGGER' case find a better way to detect 'getLogger()' method |
|
| 216 | - */ |
|
| 217 | - public function tagOpen($parser, $tag, $attribs) |
|
| 218 | - { |
|
| 219 | - switch ($tag) { |
|
| 210 | + /** |
|
| 211 | + * @param mixed $parser |
|
| 212 | + * @param string $tag |
|
| 213 | + * @param array $attribs |
|
| 214 | + * |
|
| 215 | + * @todo In 'LOGGER' case find a better way to detect 'getLogger()' method |
|
| 216 | + */ |
|
| 217 | + public function tagOpen($parser, $tag, $attribs) |
|
| 218 | + { |
|
| 219 | + switch ($tag) { |
|
| 220 | 220 | |
| 221 | - case 'CONFIGURATION' : |
|
| 222 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':CONFIGURATION': |
|
| 221 | + case 'CONFIGURATION' : |
|
| 222 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':CONFIGURATION': |
|
| 223 | 223 | |
| 224 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() CONFIGURATION"); |
|
| 224 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() CONFIGURATION"); |
|
| 225 | 225 | |
| 226 | - if (isset($attribs['THRESHOLD'])) { |
|
| 226 | + if (isset($attribs['THRESHOLD'])) { |
|
| 227 | 227 | |
| 228 | - $this->repository->setThreshold( |
|
| 229 | - LoggerOptionConverter::toLevel( |
|
| 230 | - $this->subst($attribs['THRESHOLD']), |
|
| 231 | - $this->repository->getThreshold() |
|
| 232 | - ) |
|
| 233 | - ); |
|
| 234 | - } |
|
| 235 | - if (isset($attribs['DEBUG'])) { |
|
| 236 | - $debug = LoggerOptionConverter::toBoolean($this->subst($attribs['DEBUG']), LoggerLog::internalDebugging()); |
|
| 237 | - $this->repository->debug = $debug; |
|
| 238 | - LoggerLog::internalDebugging($debug); |
|
| 239 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LOG4PHP:CONFIGURATION. Internal Debug turned ".($debug ? 'on':'off')); |
|
| 228 | + $this->repository->setThreshold( |
|
| 229 | + LoggerOptionConverter::toLevel( |
|
| 230 | + $this->subst($attribs['THRESHOLD']), |
|
| 231 | + $this->repository->getThreshold() |
|
| 232 | + ) |
|
| 233 | + ); |
|
| 234 | + } |
|
| 235 | + if (isset($attribs['DEBUG'])) { |
|
| 236 | + $debug = LoggerOptionConverter::toBoolean($this->subst($attribs['DEBUG']), LoggerLog::internalDebugging()); |
|
| 237 | + $this->repository->debug = $debug; |
|
| 238 | + LoggerLog::internalDebugging($debug); |
|
| 239 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LOG4PHP:CONFIGURATION. Internal Debug turned ".($debug ? 'on':'off')); |
|
| 240 | 240 | |
| 241 | - } |
|
| 242 | - break; |
|
| 241 | + } |
|
| 242 | + break; |
|
| 243 | 243 | |
| 244 | - case 'APPENDER' : |
|
| 245 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':APPENDER': |
|
| 244 | + case 'APPENDER' : |
|
| 245 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':APPENDER': |
|
| 246 | 246 | |
| 247 | - unset($this->appender); |
|
| 248 | - $this->appender = null; |
|
| 247 | + unset($this->appender); |
|
| 248 | + $this->appender = null; |
|
| 249 | 249 | |
| 250 | - $name = $this->subst(@$attribs['NAME']); |
|
| 251 | - $class = $this->subst(@$attribs['CLASS']); |
|
| 250 | + $name = $this->subst(@$attribs['NAME']); |
|
| 251 | + $class = $this->subst(@$attribs['CLASS']); |
|
| 252 | 252 | |
| 253 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen():tag=[$tag]:name=[$name]:class=[$class]"); |
|
| 253 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen():tag=[$tag]:name=[$name]:class=[$class]"); |
|
| 254 | 254 | |
| 255 | - $this->appender =& LoggerAppender::singleton($name, $class); |
|
| 256 | - if ($this->appender === null) { |
|
| 257 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER cannot instantiate appender '$name'"); |
|
| 258 | - } |
|
| 259 | - $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_APPENDER_STATE; |
|
| 260 | - break; |
|
| 255 | + $this->appender =& LoggerAppender::singleton($name, $class); |
|
| 256 | + if ($this->appender === null) { |
|
| 257 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER cannot instantiate appender '$name'"); |
|
| 258 | + } |
|
| 259 | + $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_APPENDER_STATE; |
|
| 260 | + break; |
|
| 261 | 261 | |
| 262 | - case 'APPENDER_REF' : |
|
| 263 | - case 'APPENDER-REF' : |
|
| 264 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':APPENDER_REF': |
|
| 265 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':APPENDER-REF': |
|
| 262 | + case 'APPENDER_REF' : |
|
| 263 | + case 'APPENDER-REF' : |
|
| 264 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':APPENDER_REF': |
|
| 265 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':APPENDER-REF': |
|
| 266 | 266 | |
| 267 | 267 | |
| 268 | - if (isset($attribs['REF']) && !empty($attribs['REF'])) { |
|
| 269 | - $appenderName = $this->subst($attribs['REF']); |
|
| 268 | + if (isset($attribs['REF']) && !empty($attribs['REF'])) { |
|
| 269 | + $appenderName = $this->subst($attribs['REF']); |
|
| 270 | 270 | |
| 271 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref='$appenderName'"); |
|
| 271 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref='$appenderName'"); |
|
| 272 | 272 | |
| 273 | - $appender =& LoggerAppender::singleton($appenderName); |
|
| 274 | - if ($appender !== null) { |
|
| 275 | - switch (end($this->state)) { |
|
| 276 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE: |
|
| 277 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE: |
|
| 278 | - $this->logger->addAppender($appender); |
|
| 279 | - break; |
|
| 280 | - } |
|
| 281 | - } else { |
|
| 282 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref '$appenderName' points to a null appender"); |
|
| 283 | - } |
|
| 284 | - } else { |
|
| 285 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref not set or empty"); |
|
| 286 | - } |
|
| 287 | - break; |
|
| 273 | + $appender =& LoggerAppender::singleton($appenderName); |
|
| 274 | + if ($appender !== null) { |
|
| 275 | + switch (end($this->state)) { |
|
| 276 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE: |
|
| 277 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE: |
|
| 278 | + $this->logger->addAppender($appender); |
|
| 279 | + break; |
|
| 280 | + } |
|
| 281 | + } else { |
|
| 282 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref '$appenderName' points to a null appender"); |
|
| 283 | + } |
|
| 284 | + } else { |
|
| 285 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref not set or empty"); |
|
| 286 | + } |
|
| 287 | + break; |
|
| 288 | 288 | |
| 289 | - case 'FILTER' : |
|
| 290 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':FILTER': |
|
| 289 | + case 'FILTER' : |
|
| 290 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':FILTER': |
|
| 291 | 291 | |
| 292 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() FILTER"); |
|
| 292 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() FILTER"); |
|
| 293 | 293 | |
| 294 | - unset($this->filter); |
|
| 295 | - $this->filter = null; |
|
| 294 | + unset($this->filter); |
|
| 295 | + $this->filter = null; |
|
| 296 | 296 | |
| 297 | - $filterName = basename($this->subst(@$attribs['CLASS'])); |
|
| 298 | - if (!empty($filterName)) { |
|
| 299 | - if (!class_exists($filterName)) { |
|
| 300 | - @include_once(LOG4PHP_DIR . "/varia/{$filterName}.php"); |
|
| 301 | - } |
|
| 302 | - if (class_exists($filterName)) { |
|
| 303 | - $this->filter = new $filterName(); |
|
| 304 | - } else { |
|
| 305 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() FILTER. class '$filterName' doesnt exist"); |
|
| 306 | - } |
|
| 307 | - $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_FILTER_STATE; |
|
| 308 | - } else { |
|
| 309 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() FILTER filter name cannot be empty"); |
|
| 310 | - } |
|
| 311 | - break; |
|
| 297 | + $filterName = basename($this->subst(@$attribs['CLASS'])); |
|
| 298 | + if (!empty($filterName)) { |
|
| 299 | + if (!class_exists($filterName)) { |
|
| 300 | + @include_once(LOG4PHP_DIR . "/varia/{$filterName}.php"); |
|
| 301 | + } |
|
| 302 | + if (class_exists($filterName)) { |
|
| 303 | + $this->filter = new $filterName(); |
|
| 304 | + } else { |
|
| 305 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() FILTER. class '$filterName' doesnt exist"); |
|
| 306 | + } |
|
| 307 | + $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_FILTER_STATE; |
|
| 308 | + } else { |
|
| 309 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() FILTER filter name cannot be empty"); |
|
| 310 | + } |
|
| 311 | + break; |
|
| 312 | 312 | |
| 313 | - case 'LAYOUT': |
|
| 314 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LAYOUT': |
|
| 313 | + case 'LAYOUT': |
|
| 314 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LAYOUT': |
|
| 315 | 315 | |
| 316 | - $class = @$attribs['CLASS']; |
|
| 316 | + $class = @$attribs['CLASS']; |
|
| 317 | 317 | |
| 318 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LAYOUT class='{$class}'"); |
|
| 318 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LAYOUT class='{$class}'"); |
|
| 319 | 319 | |
| 320 | - $this->layout = LoggerLayout::factory($this->subst($class)); |
|
| 321 | - if ($this->layout === null) |
|
| 322 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LAYOUT unable to instanciate class='{$class}'"); |
|
| 320 | + $this->layout = LoggerLayout::factory($this->subst($class)); |
|
| 321 | + if ($this->layout === null) |
|
| 322 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LAYOUT unable to instanciate class='{$class}'"); |
|
| 323 | 323 | |
| 324 | - $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_LAYOUT_STATE; |
|
| 325 | - break; |
|
| 324 | + $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_LAYOUT_STATE; |
|
| 325 | + break; |
|
| 326 | 326 | |
| 327 | - case 'LOGGER': |
|
| 328 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LOGGER': |
|
| 327 | + case 'LOGGER': |
|
| 328 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LOGGER': |
|
| 329 | 329 | |
| 330 | - // $this->logger is assigned by reference. |
|
| 331 | - // Only '$this->logger=null;' destroys referenced object |
|
| 332 | - unset($this->logger); |
|
| 333 | - $this->logger = null; |
|
| 330 | + // $this->logger is assigned by reference. |
|
| 331 | + // Only '$this->logger=null;' destroys referenced object |
|
| 332 | + unset($this->logger); |
|
| 333 | + $this->logger = null; |
|
| 334 | 334 | |
| 335 | - $loggerName = $this->subst(@$attribs['NAME']); |
|
| 336 | - if (!empty($loggerName)) { |
|
| 337 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LOGGER. name='$loggerName'"); |
|
| 335 | + $loggerName = $this->subst(@$attribs['NAME']); |
|
| 336 | + if (!empty($loggerName)) { |
|
| 337 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LOGGER. name='$loggerName'"); |
|
| 338 | 338 | |
| 339 | - $class = $this->subst(@$attribs['CLASS']); |
|
| 340 | - if (empty($class)) { |
|
| 341 | - $this->logger =& $this->repository->getLogger($loggerName); |
|
| 342 | - } else { |
|
| 343 | - $className = basename($class); |
|
| 344 | - if (!class_exists($className)) |
|
| 345 | - @include_once("{$class}.php"); |
|
| 346 | - if (!class_exists($className)) { |
|
| 347 | - LoggerLog::warn( |
|
| 348 | - "LoggerDOMConfigurator::tagOpen() LOGGER. ". |
|
| 349 | - "cannot find '$className'." |
|
| 350 | - ); |
|
| 351 | - } else { |
|
| 339 | + $class = $this->subst(@$attribs['CLASS']); |
|
| 340 | + if (empty($class)) { |
|
| 341 | + $this->logger =& $this->repository->getLogger($loggerName); |
|
| 342 | + } else { |
|
| 343 | + $className = basename($class); |
|
| 344 | + if (!class_exists($className)) |
|
| 345 | + @include_once("{$class}.php"); |
|
| 346 | + if (!class_exists($className)) { |
|
| 347 | + LoggerLog::warn( |
|
| 348 | + "LoggerDOMConfigurator::tagOpen() LOGGER. ". |
|
| 349 | + "cannot find '$className'." |
|
| 350 | + ); |
|
| 351 | + } else { |
|
| 352 | 352 | |
| 353 | - if (in_array('getlogger', get_class_methods($className))) { |
|
| 354 | - $this->logger =& call_user_func(array($className, 'getlogger'), $loggerName); |
|
| 355 | - } else { |
|
| 356 | - LoggerLog::warn( |
|
| 357 | - "LoggerDOMConfigurator::tagOpen() LOGGER. ". |
|
| 358 | - "class '$className' doesnt implement 'getLogger()' method." |
|
| 359 | - ); |
|
| 360 | - } |
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - if ($this->logger !== null && isset($attribs['ADDITIVITY'])) { |
|
| 364 | - $additivity = LoggerOptionConverter::toBoolean($this->subst($attribs['ADDITIVITY']), true); |
|
| 365 | - $this->logger->setAdditivity($additivity); |
|
| 366 | - } |
|
| 367 | - } else { |
|
| 368 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LOGGER. Attribute 'name' is not set or is empty."); |
|
| 369 | - } |
|
| 370 | - $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE;; |
|
| 371 | - break; |
|
| 353 | + if (in_array('getlogger', get_class_methods($className))) { |
|
| 354 | + $this->logger =& call_user_func(array($className, 'getlogger'), $loggerName); |
|
| 355 | + } else { |
|
| 356 | + LoggerLog::warn( |
|
| 357 | + "LoggerDOMConfigurator::tagOpen() LOGGER. ". |
|
| 358 | + "class '$className' doesnt implement 'getLogger()' method." |
|
| 359 | + ); |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + if ($this->logger !== null && isset($attribs['ADDITIVITY'])) { |
|
| 364 | + $additivity = LoggerOptionConverter::toBoolean($this->subst($attribs['ADDITIVITY']), true); |
|
| 365 | + $this->logger->setAdditivity($additivity); |
|
| 366 | + } |
|
| 367 | + } else { |
|
| 368 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LOGGER. Attribute 'name' is not set or is empty."); |
|
| 369 | + } |
|
| 370 | + $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE;; |
|
| 371 | + break; |
|
| 372 | 372 | |
| 373 | - case 'LEVEL': |
|
| 374 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LEVEL': |
|
| 375 | - case 'PRIORITY': |
|
| 376 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':PRIORITY': |
|
| 373 | + case 'LEVEL': |
|
| 374 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LEVEL': |
|
| 375 | + case 'PRIORITY': |
|
| 376 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':PRIORITY': |
|
| 377 | 377 | |
| 378 | - if (!isset($attribs['VALUE'])) { |
|
| 379 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LEVEL value not set"); |
|
| 380 | - break; |
|
| 381 | - } |
|
| 378 | + if (!isset($attribs['VALUE'])) { |
|
| 379 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LEVEL value not set"); |
|
| 380 | + break; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LEVEL value={$attribs['VALUE']}"); |
|
| 383 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LEVEL value={$attribs['VALUE']}"); |
|
| 384 | 384 | |
| 385 | - if ($this->logger === null) { |
|
| 386 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LEVEL. parent logger is null"); |
|
| 387 | - break; |
|
| 388 | - } |
|
| 385 | + if ($this->logger === null) { |
|
| 386 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LEVEL. parent logger is null"); |
|
| 387 | + break; |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | - switch (end($this->state)) { |
|
| 391 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE: |
|
| 392 | - $this->logger->setLevel( |
|
| 393 | - LoggerOptionConverter::toLevel( |
|
| 394 | - $this->subst($attribs['VALUE']), |
|
| 395 | - $this->logger->getLevel() |
|
| 396 | - ) |
|
| 397 | - ); |
|
| 398 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LEVEL root level is now '{$attribs['VALUE']}' "); |
|
| 399 | - break; |
|
| 400 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE: |
|
| 401 | - $this->logger->setLevel( |
|
| 402 | - LoggerOptionConverter::toLevel( |
|
| 403 | - $this->subst($attribs['VALUE']), |
|
| 404 | - $this->logger->getLevel() |
|
| 405 | - ) |
|
| 406 | - ); |
|
| 407 | - break; |
|
| 408 | - default: |
|
| 409 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LEVEL state '{$this->state}' not allowed here"); |
|
| 410 | - } |
|
| 411 | - break; |
|
| 390 | + switch (end($this->state)) { |
|
| 391 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE: |
|
| 392 | + $this->logger->setLevel( |
|
| 393 | + LoggerOptionConverter::toLevel( |
|
| 394 | + $this->subst($attribs['VALUE']), |
|
| 395 | + $this->logger->getLevel() |
|
| 396 | + ) |
|
| 397 | + ); |
|
| 398 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LEVEL root level is now '{$attribs['VALUE']}' "); |
|
| 399 | + break; |
|
| 400 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE: |
|
| 401 | + $this->logger->setLevel( |
|
| 402 | + LoggerOptionConverter::toLevel( |
|
| 403 | + $this->subst($attribs['VALUE']), |
|
| 404 | + $this->logger->getLevel() |
|
| 405 | + ) |
|
| 406 | + ); |
|
| 407 | + break; |
|
| 408 | + default: |
|
| 409 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LEVEL state '{$this->state}' not allowed here"); |
|
| 410 | + } |
|
| 411 | + break; |
|
| 412 | 412 | |
| 413 | - case 'PARAM': |
|
| 414 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':PARAM': |
|
| 413 | + case 'PARAM': |
|
| 414 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':PARAM': |
|
| 415 | 415 | |
| 416 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() PARAM"); |
|
| 416 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() PARAM"); |
|
| 417 | 417 | |
| 418 | - if (!isset($attribs['NAME'])) { |
|
| 419 | - LoggerLog::warn( |
|
| 420 | - "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 421 | - "attribute 'name' not defined." |
|
| 422 | - ); |
|
| 423 | - break; |
|
| 424 | - } |
|
| 425 | - if (!isset($attribs['VALUE'])) { |
|
| 426 | - LoggerLog::warn( |
|
| 427 | - "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 428 | - "attribute 'value' not defined." |
|
| 429 | - ); |
|
| 430 | - break; |
|
| 431 | - } |
|
| 418 | + if (!isset($attribs['NAME'])) { |
|
| 419 | + LoggerLog::warn( |
|
| 420 | + "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 421 | + "attribute 'name' not defined." |
|
| 422 | + ); |
|
| 423 | + break; |
|
| 424 | + } |
|
| 425 | + if (!isset($attribs['VALUE'])) { |
|
| 426 | + LoggerLog::warn( |
|
| 427 | + "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 428 | + "attribute 'value' not defined." |
|
| 429 | + ); |
|
| 430 | + break; |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | - switch (end($this->state)) { |
|
| 434 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_APPENDER_STATE: |
|
| 435 | - if ($this->appender !== null) { |
|
| 436 | - $this->setter($this->appender, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE'])); |
|
| 437 | - } else { |
|
| 438 | - LoggerLog::warn( |
|
| 439 | - "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 440 | - " trying to set property to a null appender." |
|
| 441 | - ); |
|
| 442 | - } |
|
| 443 | - break; |
|
| 444 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LAYOUT_STATE: |
|
| 445 | - if ($this->layout !== null) { |
|
| 446 | - $this->setter($this->layout, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE'])); |
|
| 447 | - } else { |
|
| 448 | - LoggerLog::warn( |
|
| 449 | - "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 450 | - " trying to set property to a null layout." |
|
| 451 | - ); |
|
| 452 | - } |
|
| 453 | - break; |
|
| 454 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_FILTER_STATE: |
|
| 455 | - if ($this->filter !== null) { |
|
| 456 | - $this->setter($this->filter, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE'])); |
|
| 457 | - } else { |
|
| 458 | - LoggerLog::warn( |
|
| 459 | - "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 460 | - " trying to set property to a null filter." |
|
| 461 | - ); |
|
| 462 | - } |
|
| 463 | - break; |
|
| 464 | - default: |
|
| 465 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() PARAM state '{$this->state}' not allowed here"); |
|
| 466 | - } |
|
| 467 | - break; |
|
| 433 | + switch (end($this->state)) { |
|
| 434 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_APPENDER_STATE: |
|
| 435 | + if ($this->appender !== null) { |
|
| 436 | + $this->setter($this->appender, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE'])); |
|
| 437 | + } else { |
|
| 438 | + LoggerLog::warn( |
|
| 439 | + "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 440 | + " trying to set property to a null appender." |
|
| 441 | + ); |
|
| 442 | + } |
|
| 443 | + break; |
|
| 444 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LAYOUT_STATE: |
|
| 445 | + if ($this->layout !== null) { |
|
| 446 | + $this->setter($this->layout, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE'])); |
|
| 447 | + } else { |
|
| 448 | + LoggerLog::warn( |
|
| 449 | + "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 450 | + " trying to set property to a null layout." |
|
| 451 | + ); |
|
| 452 | + } |
|
| 453 | + break; |
|
| 454 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_FILTER_STATE: |
|
| 455 | + if ($this->filter !== null) { |
|
| 456 | + $this->setter($this->filter, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE'])); |
|
| 457 | + } else { |
|
| 458 | + LoggerLog::warn( |
|
| 459 | + "LoggerDOMConfigurator::tagOpen() PARAM. ". |
|
| 460 | + " trying to set property to a null filter." |
|
| 461 | + ); |
|
| 462 | + } |
|
| 463 | + break; |
|
| 464 | + default: |
|
| 465 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() PARAM state '{$this->state}' not allowed here"); |
|
| 466 | + } |
|
| 467 | + break; |
|
| 468 | 468 | |
| 469 | - case 'RENDERER': |
|
| 470 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':RENDERER': |
|
| 469 | + case 'RENDERER': |
|
| 470 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':RENDERER': |
|
| 471 | 471 | |
| 472 | - $renderedClass = $this->subst(@$attribs['RENDEREDCLASS']); |
|
| 473 | - $renderingClass = $this->subst(@$attribs['RENDERINGCLASS']); |
|
| 472 | + $renderedClass = $this->subst(@$attribs['RENDEREDCLASS']); |
|
| 473 | + $renderingClass = $this->subst(@$attribs['RENDERINGCLASS']); |
|
| 474 | 474 | |
| 475 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() RENDERER renderedClass='$renderedClass' renderingClass='$renderingClass'"); |
|
| 475 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() RENDERER renderedClass='$renderedClass' renderingClass='$renderingClass'"); |
|
| 476 | 476 | |
| 477 | - if (!empty($renderedClass) && !empty($renderingClass)) { |
|
| 478 | - $renderer = LoggerObjectRenderer::factory($renderingClass); |
|
| 479 | - if ($renderer === null) { |
|
| 480 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() RENDERER cannot instantiate '$renderingClass'"); |
|
| 481 | - } else { |
|
| 482 | - $this->repository->setRenderer($renderedClass, $renderer); |
|
| 483 | - } |
|
| 484 | - } else { |
|
| 485 | - LoggerLog::warn("LoggerDOMConfigurator::tagOpen() RENDERER renderedClass or renderingClass is empty"); |
|
| 486 | - } |
|
| 487 | - break; |
|
| 477 | + if (!empty($renderedClass) && !empty($renderingClass)) { |
|
| 478 | + $renderer = LoggerObjectRenderer::factory($renderingClass); |
|
| 479 | + if ($renderer === null) { |
|
| 480 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() RENDERER cannot instantiate '$renderingClass'"); |
|
| 481 | + } else { |
|
| 482 | + $this->repository->setRenderer($renderedClass, $renderer); |
|
| 483 | + } |
|
| 484 | + } else { |
|
| 485 | + LoggerLog::warn("LoggerDOMConfigurator::tagOpen() RENDERER renderedClass or renderingClass is empty"); |
|
| 486 | + } |
|
| 487 | + break; |
|
| 488 | 488 | |
| 489 | - case 'ROOT': |
|
| 490 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':ROOT': |
|
| 489 | + case 'ROOT': |
|
| 490 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':ROOT': |
|
| 491 | 491 | |
| 492 | - LoggerLog::debug("LoggerDOMConfigurator::tagOpen() ROOT"); |
|
| 492 | + LoggerLog::debug("LoggerDOMConfigurator::tagOpen() ROOT"); |
|
| 493 | 493 | |
| 494 | - $this->logger =& LoggerManager::getRootLogger(); |
|
| 494 | + $this->logger =& LoggerManager::getRootLogger(); |
|
| 495 | 495 | |
| 496 | - $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE; |
|
| 497 | - break; |
|
| 496 | + $this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE; |
|
| 497 | + break; |
|
| 498 | 498 | |
| 499 | - } |
|
| 499 | + } |
|
| 500 | 500 | |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | |
| 504 | - /** |
|
| 505 | - * @param mixed $parser |
|
| 506 | - * @param string $tag |
|
| 507 | - */ |
|
| 508 | - public function tagClose($parser, $tag) |
|
| 509 | - { |
|
| 510 | - switch ($tag) { |
|
| 504 | + /** |
|
| 505 | + * @param mixed $parser |
|
| 506 | + * @param string $tag |
|
| 507 | + */ |
|
| 508 | + public function tagClose($parser, $tag) |
|
| 509 | + { |
|
| 510 | + switch ($tag) { |
|
| 511 | 511 | |
| 512 | - case 'CONFIGURATION' : |
|
| 513 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':CONFIGURATION': |
|
| 512 | + case 'CONFIGURATION' : |
|
| 513 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':CONFIGURATION': |
|
| 514 | 514 | |
| 515 | - LoggerLog::debug("LoggerDOMConfigurator::tagClose() CONFIGURATION"); |
|
| 516 | - break; |
|
| 515 | + LoggerLog::debug("LoggerDOMConfigurator::tagClose() CONFIGURATION"); |
|
| 516 | + break; |
|
| 517 | 517 | |
| 518 | - case 'APPENDER' : |
|
| 519 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':APPENDER': |
|
| 518 | + case 'APPENDER' : |
|
| 519 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':APPENDER': |
|
| 520 | 520 | |
| 521 | - LoggerLog::debug("LoggerDOMConfigurator::tagClose() APPENDER"); |
|
| 521 | + LoggerLog::debug("LoggerDOMConfigurator::tagClose() APPENDER"); |
|
| 522 | 522 | |
| 523 | - if ($this->appender !== null) { |
|
| 524 | - if ($this->appender->requiresLayout() && $this->appender->layout === null) { |
|
| 525 | - $appenderName = $this->appender->getName(); |
|
| 526 | - LoggerLog::warn( |
|
| 527 | - "LoggerDOMConfigurator::tagClose() APPENDER. ". |
|
| 528 | - "'$appenderName' requires a layout that is not defined. ". |
|
| 529 | - "Using a simple layout" |
|
| 530 | - ); |
|
| 531 | - $this->appender->setLayout(LoggerLayout::factory('LoggerLayoutSimple')); |
|
| 532 | - } |
|
| 533 | - $this->appender->activateOptions(); |
|
| 534 | - } |
|
| 535 | - array_pop($this->state); |
|
| 536 | - break; |
|
| 523 | + if ($this->appender !== null) { |
|
| 524 | + if ($this->appender->requiresLayout() && $this->appender->layout === null) { |
|
| 525 | + $appenderName = $this->appender->getName(); |
|
| 526 | + LoggerLog::warn( |
|
| 527 | + "LoggerDOMConfigurator::tagClose() APPENDER. ". |
|
| 528 | + "'$appenderName' requires a layout that is not defined. ". |
|
| 529 | + "Using a simple layout" |
|
| 530 | + ); |
|
| 531 | + $this->appender->setLayout(LoggerLayout::factory('LoggerLayoutSimple')); |
|
| 532 | + } |
|
| 533 | + $this->appender->activateOptions(); |
|
| 534 | + } |
|
| 535 | + array_pop($this->state); |
|
| 536 | + break; |
|
| 537 | 537 | |
| 538 | - case 'FILTER' : |
|
| 539 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':FILTER': |
|
| 538 | + case 'FILTER' : |
|
| 539 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':FILTER': |
|
| 540 | 540 | |
| 541 | - LoggerLog::debug("LoggerDOMConfigurator::tagClose() FILTER"); |
|
| 541 | + LoggerLog::debug("LoggerDOMConfigurator::tagClose() FILTER"); |
|
| 542 | 542 | |
| 543 | - if ($this->filter !== null) { |
|
| 544 | - $this->filter->activateOptions(); |
|
| 545 | - $this->appender->addFilter($this->filter); |
|
| 546 | - $this->filter = null; |
|
| 547 | - } |
|
| 548 | - array_pop($this->state); |
|
| 549 | - break; |
|
| 543 | + if ($this->filter !== null) { |
|
| 544 | + $this->filter->activateOptions(); |
|
| 545 | + $this->appender->addFilter($this->filter); |
|
| 546 | + $this->filter = null; |
|
| 547 | + } |
|
| 548 | + array_pop($this->state); |
|
| 549 | + break; |
|
| 550 | 550 | |
| 551 | - case 'LAYOUT': |
|
| 552 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LAYOUT': |
|
| 551 | + case 'LAYOUT': |
|
| 552 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LAYOUT': |
|
| 553 | 553 | |
| 554 | - LoggerLog::debug("LoggerDOMConfigurator::tagClose() LAYOUT"); |
|
| 554 | + LoggerLog::debug("LoggerDOMConfigurator::tagClose() LAYOUT"); |
|
| 555 | 555 | |
| 556 | - if ($this->appender !== null && $this->layout !== null && $this->appender->requiresLayout()) { |
|
| 557 | - $this->layout->activateOptions(); |
|
| 558 | - $this->appender->setLayout($this->layout); |
|
| 559 | - $this->layout = null; |
|
| 560 | - } |
|
| 561 | - array_pop($this->state); |
|
| 562 | - break; |
|
| 556 | + if ($this->appender !== null && $this->layout !== null && $this->appender->requiresLayout()) { |
|
| 557 | + $this->layout->activateOptions(); |
|
| 558 | + $this->appender->setLayout($this->layout); |
|
| 559 | + $this->layout = null; |
|
| 560 | + } |
|
| 561 | + array_pop($this->state); |
|
| 562 | + break; |
|
| 563 | 563 | |
| 564 | - case 'LOGGER': |
|
| 565 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LOGGER': |
|
| 564 | + case 'LOGGER': |
|
| 565 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':LOGGER': |
|
| 566 | 566 | |
| 567 | - LoggerLog::debug("LoggerDOMConfigurator::tagClose() LOGGER"); |
|
| 567 | + LoggerLog::debug("LoggerDOMConfigurator::tagClose() LOGGER"); |
|
| 568 | 568 | |
| 569 | - array_pop($this->state); |
|
| 570 | - break; |
|
| 569 | + array_pop($this->state); |
|
| 570 | + break; |
|
| 571 | 571 | |
| 572 | - case 'ROOT': |
|
| 573 | - case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':ROOT': |
|
| 572 | + case 'ROOT': |
|
| 573 | + case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS.':ROOT': |
|
| 574 | 574 | |
| 575 | - LoggerLog::debug("LoggerDOMConfigurator::tagClose() ROOT"); |
|
| 575 | + LoggerLog::debug("LoggerDOMConfigurator::tagClose() ROOT"); |
|
| 576 | 576 | |
| 577 | - array_pop($this->state); |
|
| 578 | - break; |
|
| 579 | - } |
|
| 580 | - } |
|
| 577 | + array_pop($this->state); |
|
| 578 | + break; |
|
| 579 | + } |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - /** |
|
| 583 | - * @param object $object |
|
| 584 | - * @param string $name |
|
| 585 | - * @param mixed $value |
|
| 586 | - */ |
|
| 587 | - public function setter(&$object, $name, $value) |
|
| 588 | - { |
|
| 589 | - if (empty($name)) { |
|
| 590 | - LoggerLog::debug("LoggerDOMConfigurator::setter() 'name' param cannot be empty"); |
|
| 591 | - return false; |
|
| 592 | - } |
|
| 593 | - $methodName = 'set'.ucfirst($name); |
|
| 594 | - if (method_exists($object, $methodName)) { |
|
| 595 | - LoggerLog::debug("LoggerDOMConfigurator::setter() Calling ".get_class($object)."::{$methodName}({$value})"); |
|
| 596 | - return call_user_func(array(&$object, $methodName), $value); |
|
| 597 | - } else { |
|
| 598 | - LoggerLog::warn("LoggerDOMConfigurator::setter() ".get_class($object)."::{$methodName}() does not exists"); |
|
| 599 | - return false; |
|
| 600 | - } |
|
| 601 | - } |
|
| 582 | + /** |
|
| 583 | + * @param object $object |
|
| 584 | + * @param string $name |
|
| 585 | + * @param mixed $value |
|
| 586 | + */ |
|
| 587 | + public function setter(&$object, $name, $value) |
|
| 588 | + { |
|
| 589 | + if (empty($name)) { |
|
| 590 | + LoggerLog::debug("LoggerDOMConfigurator::setter() 'name' param cannot be empty"); |
|
| 591 | + return false; |
|
| 592 | + } |
|
| 593 | + $methodName = 'set'.ucfirst($name); |
|
| 594 | + if (method_exists($object, $methodName)) { |
|
| 595 | + LoggerLog::debug("LoggerDOMConfigurator::setter() Calling ".get_class($object)."::{$methodName}({$value})"); |
|
| 596 | + return call_user_func(array(&$object, $methodName), $value); |
|
| 597 | + } else { |
|
| 598 | + LoggerLog::warn("LoggerDOMConfigurator::setter() ".get_class($object)."::{$methodName}() does not exists"); |
|
| 599 | + return false; |
|
| 600 | + } |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - public function subst($value) |
|
| 604 | - { |
|
| 605 | - return LoggerOptionConverter::substVars($value); |
|
| 606 | - } |
|
| 603 | + public function subst($value) |
|
| 604 | + { |
|
| 605 | + return LoggerOptionConverter::substVars($value); |
|
| 606 | + } |
|
| 607 | 607 | |
| 608 | 608 | } |
| 609 | 609 | ?> |
| 610 | 610 | \ No newline at end of file |
@@ -34,66 +34,66 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | class LoggerLog { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Log if debug is enabled. |
|
| 39 | - * |
|
| 40 | - * Log using php {@link PHP_MANUAL#trigger_error trigger_error()} function |
|
| 41 | - * with E_USER_NOTICE level by default. |
|
| 42 | - * |
|
| 43 | - * @param string $message log message |
|
| 44 | - * @param integer $errLevel level to log |
|
| 45 | - * @static |
|
| 46 | - */ |
|
| 47 | - public function log($message, $errLevel = E_USER_NOTICE) |
|
| 48 | - { |
|
| 49 | - if (LoggerLog::internalDebugging()) |
|
| 50 | - trigger_error($message, $errLevel); |
|
| 51 | - } |
|
| 37 | + /** |
|
| 38 | + * Log if debug is enabled. |
|
| 39 | + * |
|
| 40 | + * Log using php {@link PHP_MANUAL#trigger_error trigger_error()} function |
|
| 41 | + * with E_USER_NOTICE level by default. |
|
| 42 | + * |
|
| 43 | + * @param string $message log message |
|
| 44 | + * @param integer $errLevel level to log |
|
| 45 | + * @static |
|
| 46 | + */ |
|
| 47 | + public function log($message, $errLevel = E_USER_NOTICE) |
|
| 48 | + { |
|
| 49 | + if (LoggerLog::internalDebugging()) |
|
| 50 | + trigger_error($message, $errLevel); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function internalDebugging($value = null) |
|
| 54 | - { |
|
| 55 | - static $debug = false; |
|
| 53 | + public function internalDebugging($value = null) |
|
| 54 | + { |
|
| 55 | + static $debug = false; |
|
| 56 | 56 | |
| 57 | - if (is_bool($value)) |
|
| 58 | - $debug = $value; |
|
| 59 | - return $debug; |
|
| 60 | - } |
|
| 57 | + if (is_bool($value)) |
|
| 58 | + $debug = $value; |
|
| 59 | + return $debug; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Report a debug message. |
|
| 64 | - * |
|
| 65 | - * @param string $message log message |
|
| 66 | - * @static |
|
| 67 | - * @since 0.3 |
|
| 68 | - */ |
|
| 69 | - public function debug($message) |
|
| 70 | - { |
|
| 71 | - LoggerLog::log($message, E_USER_NOTICE); |
|
| 72 | - } |
|
| 62 | + /** |
|
| 63 | + * Report a debug message. |
|
| 64 | + * |
|
| 65 | + * @param string $message log message |
|
| 66 | + * @static |
|
| 67 | + * @since 0.3 |
|
| 68 | + */ |
|
| 69 | + public function debug($message) |
|
| 70 | + { |
|
| 71 | + LoggerLog::log($message, E_USER_NOTICE); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Report an error message. |
|
| 76 | - * |
|
| 77 | - * @param string $message log message |
|
| 78 | - * @static |
|
| 79 | - * @since 0.3 |
|
| 80 | - */ |
|
| 81 | - public function error($message) |
|
| 82 | - { |
|
| 83 | - trigger_error($message, E_USER_ERROR); |
|
| 84 | - } |
|
| 74 | + /** |
|
| 75 | + * Report an error message. |
|
| 76 | + * |
|
| 77 | + * @param string $message log message |
|
| 78 | + * @static |
|
| 79 | + * @since 0.3 |
|
| 80 | + */ |
|
| 81 | + public function error($message) |
|
| 82 | + { |
|
| 83 | + trigger_error($message, E_USER_ERROR); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Report a warning message. |
|
| 88 | - * |
|
| 89 | - * @param string $message log message |
|
| 90 | - * @static |
|
| 91 | - * @since 0.3 |
|
| 92 | - */ |
|
| 93 | - public function warn($message) |
|
| 94 | - { |
|
| 95 | - trigger_error($message, E_USER_WARNING); |
|
| 96 | - } |
|
| 86 | + /** |
|
| 87 | + * Report a warning message. |
|
| 88 | + * |
|
| 89 | + * @param string $message log message |
|
| 90 | + * @static |
|
| 91 | + * @since 0.3 |
|
| 92 | + */ |
|
| 93 | + public function warn($message) |
|
| 94 | + { |
|
| 95 | + trigger_error($message, E_USER_WARNING); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | ?> |
| 100 | 100 | \ No newline at end of file |
@@ -47,73 +47,73 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | class LoggerLevelMatchFilter extends LoggerFilter { |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var boolean |
|
| 52 | - */ |
|
| 53 | - var $acceptOnMatch = true; |
|
| 50 | + /** |
|
| 51 | + * @var boolean |
|
| 52 | + */ |
|
| 53 | + var $acceptOnMatch = true; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @var LoggerLevel |
|
| 57 | - */ |
|
| 58 | - var $levelToMatch; |
|
| 55 | + /** |
|
| 56 | + * @var LoggerLevel |
|
| 57 | + */ |
|
| 58 | + var $levelToMatch; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @return boolean |
|
| 62 | - */ |
|
| 63 | - public function getAcceptOnMatch() |
|
| 64 | - { |
|
| 65 | - return $this->acceptOnMatch; |
|
| 66 | - } |
|
| 60 | + /** |
|
| 61 | + * @return boolean |
|
| 62 | + */ |
|
| 63 | + public function getAcceptOnMatch() |
|
| 64 | + { |
|
| 65 | + return $this->acceptOnMatch; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @param boolean $acceptOnMatch |
|
| 70 | - */ |
|
| 71 | - public function setAcceptOnMatch($acceptOnMatch) |
|
| 72 | - { |
|
| 73 | - $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
| 74 | - } |
|
| 68 | + /** |
|
| 69 | + * @param boolean $acceptOnMatch |
|
| 70 | + */ |
|
| 71 | + public function setAcceptOnMatch($acceptOnMatch) |
|
| 72 | + { |
|
| 73 | + $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @return LoggerLevel |
|
| 78 | - */ |
|
| 79 | - public function getLevelToMatch() |
|
| 80 | - { |
|
| 81 | - return $this->levelToMatch; |
|
| 82 | - } |
|
| 76 | + /** |
|
| 77 | + * @return LoggerLevel |
|
| 78 | + */ |
|
| 79 | + public function getLevelToMatch() |
|
| 80 | + { |
|
| 81 | + return $this->levelToMatch; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @param string $l the level to match |
|
| 86 | - */ |
|
| 87 | - public function setLevelToMatch($l) |
|
| 88 | - { |
|
| 89 | - $this->levelToMatch = LoggerOptionConverter::toLevel($l, null); |
|
| 90 | - } |
|
| 84 | + /** |
|
| 85 | + * @param string $l the level to match |
|
| 86 | + */ |
|
| 87 | + public function setLevelToMatch($l) |
|
| 88 | + { |
|
| 89 | + $this->levelToMatch = LoggerOptionConverter::toLevel($l, null); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Return the decision of this filter. |
|
| 94 | - * |
|
| 95 | - * Returns {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} if the <b><var>LevelToMatch</var></b> |
|
| 96 | - * option is not set or if there is not match. Otherwise, if there is a |
|
| 97 | - * match, then the returned decision is {@link LOG4PHP_LOGGER_FILTER_ACCEPT} if the |
|
| 98 | - * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The |
|
| 99 | - * returned decision is {@link LOG4PHP_LOGGER_FILTER_DENY} if the |
|
| 100 | - * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>. |
|
| 101 | - * |
|
| 102 | - * @param LoggerLoggingEvent $event |
|
| 103 | - * @return integer |
|
| 104 | - */ |
|
| 105 | - public function decide($event) |
|
| 106 | - { |
|
| 107 | - if($this->levelToMatch === null) |
|
| 108 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 92 | + /** |
|
| 93 | + * Return the decision of this filter. |
|
| 94 | + * |
|
| 95 | + * Returns {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} if the <b><var>LevelToMatch</var></b> |
|
| 96 | + * option is not set or if there is not match. Otherwise, if there is a |
|
| 97 | + * match, then the returned decision is {@link LOG4PHP_LOGGER_FILTER_ACCEPT} if the |
|
| 98 | + * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The |
|
| 99 | + * returned decision is {@link LOG4PHP_LOGGER_FILTER_DENY} if the |
|
| 100 | + * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>. |
|
| 101 | + * |
|
| 102 | + * @param LoggerLoggingEvent $event |
|
| 103 | + * @return integer |
|
| 104 | + */ |
|
| 105 | + public function decide($event) |
|
| 106 | + { |
|
| 107 | + if($this->levelToMatch === null) |
|
| 108 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 109 | 109 | |
| 110 | - if ($this->levelToMatch->equals($event->getLevel())) { |
|
| 111 | - return $this->getAcceptOnMatch() ? |
|
| 112 | - LOG4PHP_LOGGER_FILTER_ACCEPT : |
|
| 113 | - LOG4PHP_LOGGER_FILTER_DENY; |
|
| 114 | - } else { |
|
| 115 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 116 | - } |
|
| 117 | - } |
|
| 110 | + if ($this->levelToMatch->equals($event->getLevel())) { |
|
| 111 | + return $this->getAcceptOnMatch() ? |
|
| 112 | + LOG4PHP_LOGGER_FILTER_ACCEPT : |
|
| 113 | + LOG4PHP_LOGGER_FILTER_DENY; |
|
| 114 | + } else { |
|
| 115 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | ?> |
| 120 | 120 | \ No newline at end of file |
@@ -65,104 +65,104 @@ |
||
| 65 | 65 | */ |
| 66 | 66 | class LoggerLevelRangeFilter extends LoggerFilter { |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var boolean |
|
| 70 | - */ |
|
| 71 | - var $acceptOnMatch = true; |
|
| 68 | + /** |
|
| 69 | + * @var boolean |
|
| 70 | + */ |
|
| 71 | + var $acceptOnMatch = true; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @var LoggerLevel |
|
| 75 | - */ |
|
| 76 | - var $levelMin; |
|
| 73 | + /** |
|
| 74 | + * @var LoggerLevel |
|
| 75 | + */ |
|
| 76 | + var $levelMin; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @var LoggerLevel |
|
| 80 | - */ |
|
| 81 | - var $levelMax; |
|
| 78 | + /** |
|
| 79 | + * @var LoggerLevel |
|
| 80 | + */ |
|
| 81 | + var $levelMax; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @return boolean |
|
| 85 | - */ |
|
| 86 | - public function getAcceptOnMatch() |
|
| 87 | - { |
|
| 88 | - return $this->acceptOnMatch; |
|
| 89 | - } |
|
| 83 | + /** |
|
| 84 | + * @return boolean |
|
| 85 | + */ |
|
| 86 | + public function getAcceptOnMatch() |
|
| 87 | + { |
|
| 88 | + return $this->acceptOnMatch; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @param boolean $acceptOnMatch |
|
| 93 | - */ |
|
| 94 | - public function setAcceptOnMatch($acceptOnMatch) |
|
| 95 | - { |
|
| 96 | - $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
| 97 | - } |
|
| 91 | + /** |
|
| 92 | + * @param boolean $acceptOnMatch |
|
| 93 | + */ |
|
| 94 | + public function setAcceptOnMatch($acceptOnMatch) |
|
| 95 | + { |
|
| 96 | + $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * @return LoggerLevel |
|
| 101 | - */ |
|
| 102 | - public function getLevelMin() |
|
| 103 | - { |
|
| 104 | - return $this->levelMin; |
|
| 105 | - } |
|
| 99 | + /** |
|
| 100 | + * @return LoggerLevel |
|
| 101 | + */ |
|
| 102 | + public function getLevelMin() |
|
| 103 | + { |
|
| 104 | + return $this->levelMin; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * @param string $l the level min to match |
|
| 109 | - */ |
|
| 110 | - public function setLevelMin($l) |
|
| 111 | - { |
|
| 112 | - $this->levelMin = LoggerOptionConverter::toLevel($l, null); |
|
| 113 | - } |
|
| 107 | + /** |
|
| 108 | + * @param string $l the level min to match |
|
| 109 | + */ |
|
| 110 | + public function setLevelMin($l) |
|
| 111 | + { |
|
| 112 | + $this->levelMin = LoggerOptionConverter::toLevel($l, null); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * @return LoggerLevel |
|
| 117 | - */ |
|
| 118 | - public function getLevelMax() |
|
| 119 | - { |
|
| 120 | - return $this->levelMax; |
|
| 121 | - } |
|
| 115 | + /** |
|
| 116 | + * @return LoggerLevel |
|
| 117 | + */ |
|
| 118 | + public function getLevelMax() |
|
| 119 | + { |
|
| 120 | + return $this->levelMax; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * @param string $l the level max to match |
|
| 125 | - */ |
|
| 126 | - public function setLevelMax($l) |
|
| 127 | - { |
|
| 128 | - $this->levelMax = LoggerOptionConverter::toLevel($l, null); |
|
| 129 | - } |
|
| 123 | + /** |
|
| 124 | + * @param string $l the level max to match |
|
| 125 | + */ |
|
| 126 | + public function setLevelMax($l) |
|
| 127 | + { |
|
| 128 | + $this->levelMax = LoggerOptionConverter::toLevel($l, null); |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Return the decision of this filter. |
|
| 133 | - * |
|
| 134 | - * @param LoggerLoggingEvent $event |
|
| 135 | - * @return integer |
|
| 136 | - */ |
|
| 137 | - public function decide($event) |
|
| 138 | - { |
|
| 139 | - $level = $event->getLevel(); |
|
| 131 | + /** |
|
| 132 | + * Return the decision of this filter. |
|
| 133 | + * |
|
| 134 | + * @param LoggerLoggingEvent $event |
|
| 135 | + * @return integer |
|
| 136 | + */ |
|
| 137 | + public function decide($event) |
|
| 138 | + { |
|
| 139 | + $level = $event->getLevel(); |
|
| 140 | 140 | |
| 141 | - if($this->levelMin !== null) { |
|
| 142 | - if ($level->isGreaterOrEqual($this->levelMin) === false) { |
|
| 143 | - // level of event is less than minimum |
|
| 144 | - return LOG4PHP_LOGGER_FILTER_DENY; |
|
| 145 | - } |
|
| 146 | - } |
|
| 141 | + if($this->levelMin !== null) { |
|
| 142 | + if ($level->isGreaterOrEqual($this->levelMin) === false) { |
|
| 143 | + // level of event is less than minimum |
|
| 144 | + return LOG4PHP_LOGGER_FILTER_DENY; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - if($this->levelMax !== null) { |
|
| 149 | - if ($level->toInt() > $this->levelMax->toInt()) { |
|
| 150 | - // level of event is greater than maximum |
|
| 151 | - // Alas, there is no Level.isGreater method. and using |
|
| 152 | - // a combo of isGreaterOrEqual && !Equal seems worse than |
|
| 153 | - // checking the int values of the level objects.. |
|
| 154 | - return LOG4PHP_LOGGER_FILTER_DENY; |
|
| 155 | - } |
|
| 156 | - } |
|
| 148 | + if($this->levelMax !== null) { |
|
| 149 | + if ($level->toInt() > $this->levelMax->toInt()) { |
|
| 150 | + // level of event is greater than maximum |
|
| 151 | + // Alas, there is no Level.isGreater method. and using |
|
| 152 | + // a combo of isGreaterOrEqual && !Equal seems worse than |
|
| 153 | + // checking the int values of the level objects.. |
|
| 154 | + return LOG4PHP_LOGGER_FILTER_DENY; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - if ($this->getAcceptOnMatch()) { |
|
| 159 | - // this filter set up to bypass later filters and always return |
|
| 160 | - // accept if level in range |
|
| 161 | - return LOG4PHP_LOGGER_FILTER_ACCEPT; |
|
| 162 | - } else { |
|
| 163 | - // event is ok for this filter; allow later filters to have a look.. |
|
| 164 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 165 | - } |
|
| 166 | - } |
|
| 158 | + if ($this->getAcceptOnMatch()) { |
|
| 159 | + // this filter set up to bypass later filters and always return |
|
| 160 | + // accept if level in range |
|
| 161 | + return LOG4PHP_LOGGER_FILTER_ACCEPT; |
|
| 162 | + } else { |
|
| 163 | + // event is ok for this filter; allow later filters to have a look.. |
|
| 164 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | 167 | } |
| 168 | 168 | ?> |
| 169 | 169 | \ No newline at end of file |
@@ -46,63 +46,63 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | class LoggerStringMatchFilter extends LoggerFilter { |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var boolean |
|
| 51 | - */ |
|
| 52 | - var $acceptOnMatch = true; |
|
| 49 | + /** |
|
| 50 | + * @var boolean |
|
| 51 | + */ |
|
| 52 | + var $acceptOnMatch = true; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 57 | - var $stringToMatch = null; |
|
| 54 | + /** |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | + var $stringToMatch = null; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return boolean |
|
| 61 | - */ |
|
| 62 | - public function getAcceptOnMatch() |
|
| 63 | - { |
|
| 64 | - return $this->acceptOnMatch; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * @return boolean |
|
| 61 | + */ |
|
| 62 | + public function getAcceptOnMatch() |
|
| 63 | + { |
|
| 64 | + return $this->acceptOnMatch; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false') |
|
| 69 | - */ |
|
| 70 | - public function setAcceptOnMatch($acceptOnMatch) |
|
| 71 | - { |
|
| 72 | - $this->acceptOnMatch = is_bool($acceptOnMatch) ? |
|
| 73 | - $acceptOnMatch : |
|
| 74 | - (bool)(strtolower($acceptOnMatch) == 'true'); |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false') |
|
| 69 | + */ |
|
| 70 | + public function setAcceptOnMatch($acceptOnMatch) |
|
| 71 | + { |
|
| 72 | + $this->acceptOnMatch = is_bool($acceptOnMatch) ? |
|
| 73 | + $acceptOnMatch : |
|
| 74 | + (bool)(strtolower($acceptOnMatch) == 'true'); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public function getStringToMatch() |
|
| 81 | - { |
|
| 82 | - return $this->stringToMatch; |
|
| 83 | - } |
|
| 77 | + /** |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public function getStringToMatch() |
|
| 81 | + { |
|
| 82 | + return $this->stringToMatch; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @param string $s the string to match |
|
| 87 | - */ |
|
| 88 | - public function setStringToMatch($s) |
|
| 89 | - { |
|
| 90 | - $this->stringToMatch = $s; |
|
| 91 | - } |
|
| 85 | + /** |
|
| 86 | + * @param string $s the string to match |
|
| 87 | + */ |
|
| 88 | + public function setStringToMatch($s) |
|
| 89 | + { |
|
| 90 | + $this->stringToMatch = $s; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. |
|
| 95 | - */ |
|
| 96 | - public function decide($event) |
|
| 97 | - { |
|
| 98 | - $msg = $event->getRenderedMessage(); |
|
| 93 | + /** |
|
| 94 | + * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. |
|
| 95 | + */ |
|
| 96 | + public function decide($event) |
|
| 97 | + { |
|
| 98 | + $msg = $event->getRenderedMessage(); |
|
| 99 | 99 | |
| 100 | - if($msg === null || $this->stringToMatch === null) |
|
| 101 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 102 | - if( strpos($msg, $this->stringToMatch) !== false ) { |
|
| 103 | - return ($this->acceptOnMatch) ? LOG4PHP_LOGGER_FILTER_ACCEPT : LOG4PHP_LOGGER_FILTER_DENY ; |
|
| 104 | - } |
|
| 105 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 106 | - } |
|
| 100 | + if($msg === null || $this->stringToMatch === null) |
|
| 101 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 102 | + if( strpos($msg, $this->stringToMatch) !== false ) { |
|
| 103 | + return ($this->acceptOnMatch) ? LOG4PHP_LOGGER_FILTER_ACCEPT : LOG4PHP_LOGGER_FILTER_DENY ; |
|
| 104 | + } |
|
| 105 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 106 | + } |
|
| 107 | 107 | } |
| 108 | 108 | ?> |
| 109 | 109 | \ No newline at end of file |
@@ -33,35 +33,35 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class Logger extends LoggerCategory { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Constructor |
|
| 38 | - * @param string $name logger name |
|
| 39 | - */ |
|
| 40 | - public function Logger($name) |
|
| 41 | - { |
|
| 42 | - $this->LoggerCategory($name); |
|
| 43 | - } |
|
| 36 | + /** |
|
| 37 | + * Constructor |
|
| 38 | + * @param string $name logger name |
|
| 39 | + */ |
|
| 40 | + public function Logger($name) |
|
| 41 | + { |
|
| 42 | + $this->LoggerCategory($name); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Get a Logger by name (Delegate to {@link LoggerManager}) |
|
| 47 | - * @param string $name logger name |
|
| 48 | - * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
| 49 | - * @return Logger |
|
| 50 | - * @static |
|
| 51 | - */ |
|
| 52 | - public function &getLogger($name, $factory = null) |
|
| 53 | - { |
|
| 54 | - return LoggerManager::getLogger($name, $factory); |
|
| 55 | - } |
|
| 45 | + /** |
|
| 46 | + * Get a Logger by name (Delegate to {@link LoggerManager}) |
|
| 47 | + * @param string $name logger name |
|
| 48 | + * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
| 49 | + * @return Logger |
|
| 50 | + * @static |
|
| 51 | + */ |
|
| 52 | + public function &getLogger($name, $factory = null) |
|
| 53 | + { |
|
| 54 | + return LoggerManager::getLogger($name, $factory); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * get the Root Logger (Delegate to {@link LoggerManager}) |
|
| 59 | - * @return LoggerRoot |
|
| 60 | - * @static |
|
| 61 | - */ |
|
| 62 | - public function &getRootLogger() |
|
| 63 | - { |
|
| 64 | - return LoggerManager::getRootLogger(); |
|
| 65 | - } |
|
| 57 | + /** |
|
| 58 | + * get the Root Logger (Delegate to {@link LoggerManager}) |
|
| 59 | + * @return LoggerRoot |
|
| 60 | + * @static |
|
| 61 | + */ |
|
| 62 | + public function &getRootLogger() |
|
| 63 | + { |
|
| 64 | + return LoggerManager::getRootLogger(); |
|
| 65 | + } |
|
| 66 | 66 | } |
| 67 | 67 | ?> |
| 68 | 68 | \ No newline at end of file |
@@ -50,157 +50,157 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | class LoggerXmlLayout extends LoggerLayout { |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * The <b>LocationInfo</b> option takes a boolean value. By default, |
|
| 55 | - * it is set to false which means there will be no location |
|
| 56 | - * information output by this layout. If the the option is set to |
|
| 57 | - * true, then the file name and line number of the statement at the |
|
| 58 | - * origin of the log statement will be output. |
|
| 59 | - * @var boolean |
|
| 60 | - */ |
|
| 61 | - var $locationInfo = true; |
|
| 53 | + /** |
|
| 54 | + * The <b>LocationInfo</b> option takes a boolean value. By default, |
|
| 55 | + * it is set to false which means there will be no location |
|
| 56 | + * information output by this layout. If the the option is set to |
|
| 57 | + * true, then the file name and line number of the statement at the |
|
| 58 | + * origin of the log statement will be output. |
|
| 59 | + * @var boolean |
|
| 60 | + */ |
|
| 61 | + var $locationInfo = true; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @var boolean set the elements namespace |
|
| 65 | - */ |
|
| 66 | - var $log4jNamespace = false; |
|
| 63 | + /** |
|
| 64 | + * @var boolean set the elements namespace |
|
| 65 | + */ |
|
| 66 | + var $log4jNamespace = false; |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @var string namespace |
|
| 71 | - * @private |
|
| 72 | - */ |
|
| 73 | - var $_namespace = LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS; |
|
| 69 | + /** |
|
| 70 | + * @var string namespace |
|
| 71 | + * @private |
|
| 72 | + */ |
|
| 73 | + var $_namespace = LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS; |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @var string namespace prefix |
|
| 77 | - * @private |
|
| 78 | - */ |
|
| 79 | - var $_namespacePrefix = LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS_PREFIX; |
|
| 75 | + /** |
|
| 76 | + * @var string namespace prefix |
|
| 77 | + * @private |
|
| 78 | + */ |
|
| 79 | + var $_namespacePrefix = LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS_PREFIX; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * No options to activate. |
|
| 83 | - */ |
|
| 84 | - public function activateOptions() |
|
| 85 | - { |
|
| 86 | - if ($this->getLog4jNamespace()) { |
|
| 87 | - $this->_namespace = LOG4PHP_LOGGER_XML_LAYOUT_LOG4J_NS; |
|
| 88 | - $this->_namespacePrefix = LOG4PHP_LOGGER_XML_LAYOUT_LOG4J_NS_PREFIX; |
|
| 89 | - } else { |
|
| 90 | - $this->_namespace = LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS; |
|
| 91 | - $this->_namespacePrefix = LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS_PREFIX; |
|
| 92 | - } |
|
| 93 | - } |
|
| 81 | + /** |
|
| 82 | + * No options to activate. |
|
| 83 | + */ |
|
| 84 | + public function activateOptions() |
|
| 85 | + { |
|
| 86 | + if ($this->getLog4jNamespace()) { |
|
| 87 | + $this->_namespace = LOG4PHP_LOGGER_XML_LAYOUT_LOG4J_NS; |
|
| 88 | + $this->_namespacePrefix = LOG4PHP_LOGGER_XML_LAYOUT_LOG4J_NS_PREFIX; |
|
| 89 | + } else { |
|
| 90 | + $this->_namespace = LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS; |
|
| 91 | + $this->_namespacePrefix = LOG4PHP_LOGGER_XML_LAYOUT_LOG4PHP_NS_PREFIX; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * @return string |
|
| 97 | - */ |
|
| 98 | - public function getHeader() |
|
| 99 | - { |
|
| 100 | - return "<{$this->_namespacePrefix}:eventSet ". |
|
| 101 | - "xmlns:{$this->_namespacePrefix}=\"{$this->_namespace}\" ". |
|
| 102 | - "version=\"0.3\" ". |
|
| 103 | - "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"". |
|
| 104 | - ">\r\n"; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd. |
|
| 109 | - * |
|
| 110 | - * @param LoggerLoggingEvent $event |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 113 | - public function format($event) |
|
| 114 | - { |
|
| 115 | - $loggerName = $event->getLoggerName(); |
|
| 116 | - $timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', ''); |
|
| 117 | - $thread = $event->getThreadName(); |
|
| 118 | - $level = $event->getLevel(); |
|
| 119 | - $levelStr = $level->toString(); |
|
| 120 | - |
|
| 121 | - $buf = "<{$this->_namespacePrefix}:event logger=\"{$loggerName}\" level=\"{$levelStr}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">\r\n"; |
|
| 122 | - $buf .= "<{$this->_namespacePrefix}:message><![CDATA["; |
|
| 123 | - LoggerTransform::appendEscapingCDATA($buf, $event->getRenderedMessage()); |
|
| 124 | - $buf .= "]]></{$this->_namespacePrefix}:message>\r\n"; |
|
| 125 | - |
|
| 126 | - $ndc = $event->getNDC(); |
|
| 127 | - if($ndc != null) { |
|
| 128 | - $buf .= "<{$this->_namespacePrefix}:NDC><![CDATA["; |
|
| 129 | - LoggerTransform::appendEscapingCDATA($buf, $ndc); |
|
| 130 | - $buf .= "]]></{$this->_namespacePrefix}:NDC>\r\n"; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - if ($this->getLocationInfo()) { |
|
| 134 | - $locationInfo = $event->getLocationInformation(); |
|
| 135 | - $buf .= "<{$this->_namespacePrefix}:locationInfo ". |
|
| 136 | - "class=\"" . $locationInfo->getClassName() . "\" ". |
|
| 137 | - "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ". |
|
| 138 | - "line=\"" . $locationInfo->getLineNumber() . "\" ". |
|
| 139 | - "method=\"" . $locationInfo->getMethodName() . "\" "; |
|
| 140 | - $buf .= "/>\r\n"; |
|
| 141 | - |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - $buf .= "</{$this->_namespacePrefix}:event>\r\n\r\n"; |
|
| 95 | + /** |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 98 | + public function getHeader() |
|
| 99 | + { |
|
| 100 | + return "<{$this->_namespacePrefix}:eventSet ". |
|
| 101 | + "xmlns:{$this->_namespacePrefix}=\"{$this->_namespace}\" ". |
|
| 102 | + "version=\"0.3\" ". |
|
| 103 | + "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"". |
|
| 104 | + ">\r\n"; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd. |
|
| 109 | + * |
|
| 110 | + * @param LoggerLoggingEvent $event |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | + public function format($event) |
|
| 114 | + { |
|
| 115 | + $loggerName = $event->getLoggerName(); |
|
| 116 | + $timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', ''); |
|
| 117 | + $thread = $event->getThreadName(); |
|
| 118 | + $level = $event->getLevel(); |
|
| 119 | + $levelStr = $level->toString(); |
|
| 120 | + |
|
| 121 | + $buf = "<{$this->_namespacePrefix}:event logger=\"{$loggerName}\" level=\"{$levelStr}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">\r\n"; |
|
| 122 | + $buf .= "<{$this->_namespacePrefix}:message><![CDATA["; |
|
| 123 | + LoggerTransform::appendEscapingCDATA($buf, $event->getRenderedMessage()); |
|
| 124 | + $buf .= "]]></{$this->_namespacePrefix}:message>\r\n"; |
|
| 125 | + |
|
| 126 | + $ndc = $event->getNDC(); |
|
| 127 | + if($ndc != null) { |
|
| 128 | + $buf .= "<{$this->_namespacePrefix}:NDC><![CDATA["; |
|
| 129 | + LoggerTransform::appendEscapingCDATA($buf, $ndc); |
|
| 130 | + $buf .= "]]></{$this->_namespacePrefix}:NDC>\r\n"; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + if ($this->getLocationInfo()) { |
|
| 134 | + $locationInfo = $event->getLocationInformation(); |
|
| 135 | + $buf .= "<{$this->_namespacePrefix}:locationInfo ". |
|
| 136 | + "class=\"" . $locationInfo->getClassName() . "\" ". |
|
| 137 | + "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ". |
|
| 138 | + "line=\"" . $locationInfo->getLineNumber() . "\" ". |
|
| 139 | + "method=\"" . $locationInfo->getMethodName() . "\" "; |
|
| 140 | + $buf .= "/>\r\n"; |
|
| 141 | + |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + $buf .= "</{$this->_namespacePrefix}:event>\r\n\r\n"; |
|
| 145 | 145 | |
| 146 | - return $buf; |
|
| 146 | + return $buf; |
|
| 147 | 147 | |
| 148 | - } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * @return string |
|
| 152 | - */ |
|
| 153 | - public function getFooter() |
|
| 154 | - { |
|
| 155 | - |
|
| 156 | - return "</{$this->_namespacePrefix}:eventSet>\r\n"; |
|
| 157 | - } |
|
| 150 | + /** |
|
| 151 | + * @return string |
|
| 152 | + */ |
|
| 153 | + public function getFooter() |
|
| 154 | + { |
|
| 155 | + |
|
| 156 | + return "</{$this->_namespacePrefix}:eventSet>\r\n"; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * @return boolean |
|
| 161 | - */ |
|
| 162 | - public function getLocationInfo() |
|
| 163 | - { |
|
| 164 | - return $this->locationInfo; |
|
| 165 | - } |
|
| 159 | + /** |
|
| 160 | + * @return boolean |
|
| 161 | + */ |
|
| 162 | + public function getLocationInfo() |
|
| 163 | + { |
|
| 164 | + return $this->locationInfo; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * @return boolean |
|
| 169 | - */ |
|
| 170 | - public function getLog4jNamespace() |
|
| 171 | - { |
|
| 172 | - return $this->log4jNamespace; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * The XMLLayout prints and does not ignore exceptions. Hence the |
|
| 177 | - * return value <b>false</b>. |
|
| 178 | - * @return boolean |
|
| 179 | - */ |
|
| 180 | - public function ignoresThrowable() |
|
| 181 | - { |
|
| 182 | - return false; |
|
| 183 | - } |
|
| 167 | + /** |
|
| 168 | + * @return boolean |
|
| 169 | + */ |
|
| 170 | + public function getLog4jNamespace() |
|
| 171 | + { |
|
| 172 | + return $this->log4jNamespace; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * The XMLLayout prints and does not ignore exceptions. Hence the |
|
| 177 | + * return value <b>false</b>. |
|
| 178 | + * @return boolean |
|
| 179 | + */ |
|
| 180 | + public function ignoresThrowable() |
|
| 181 | + { |
|
| 182 | + return false; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * The {@link $locationInfo} option takes a boolean value. By default, |
|
| 187 | - * it is set to false which means there will be no location |
|
| 188 | - * information output by this layout. If the the option is set to |
|
| 189 | - * true, then the file name and line number of the statement at the |
|
| 190 | - * origin of the log statement will be output. |
|
| 191 | - */ |
|
| 192 | - public function setLocationInfo($flag) |
|
| 193 | - { |
|
| 194 | - $this->locationInfo = LoggerOptionConverter::toBoolean($flag, true); |
|
| 195 | - } |
|
| 185 | + /** |
|
| 186 | + * The {@link $locationInfo} option takes a boolean value. By default, |
|
| 187 | + * it is set to false which means there will be no location |
|
| 188 | + * information output by this layout. If the the option is set to |
|
| 189 | + * true, then the file name and line number of the statement at the |
|
| 190 | + * origin of the log statement will be output. |
|
| 191 | + */ |
|
| 192 | + public function setLocationInfo($flag) |
|
| 193 | + { |
|
| 194 | + $this->locationInfo = LoggerOptionConverter::toBoolean($flag, true); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * @param boolean |
|
| 199 | - */ |
|
| 200 | - public function setLog4jNamespace($flag) |
|
| 201 | - { |
|
| 202 | - $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, true); |
|
| 203 | - } |
|
| 197 | + /** |
|
| 198 | + * @param boolean |
|
| 199 | + */ |
|
| 200 | + public function setLog4jNamespace($flag) |
|
| 201 | + { |
|
| 202 | + $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, true); |
|
| 203 | + } |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | ?> |
| 207 | 207 | \ No newline at end of file |