@@ -29,25 +29,25 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Payone_Log4php_LoggerPatternConverterMDC extends Payone_Log4php_LoggerPatternConverter { |
| 31 | 31 | |
| 32 | - private $key; |
|
| 32 | + private $key; |
|
| 33 | 33 | |
| 34 | - public function activateOptions() { |
|
| 35 | - if (isset($this->option) && $this->option !== '') { |
|
| 36 | - $this->key = $this->option; |
|
| 37 | - } |
|
| 38 | - } |
|
| 34 | + public function activateOptions() { |
|
| 35 | + if (isset($this->option) && $this->option !== '') { |
|
| 36 | + $this->key = $this->option; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 41 | - if (isset($this->key)) { |
|
| 42 | - return $event->getMDC($this->key); |
|
| 43 | - } else { |
|
| 44 | - $buff = array(); |
|
| 45 | - $map = $event->getMDCMap(); |
|
| 46 | - foreach($map as $key => $value) { |
|
| 47 | - $buff []= "$key=$value"; |
|
| 48 | - } |
|
| 49 | - return implode(', ', $buff); |
|
| 50 | - } |
|
| 51 | - } |
|
| 40 | + public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 41 | + if (isset($this->key)) { |
|
| 42 | + return $event->getMDC($this->key); |
|
| 43 | + } else { |
|
| 44 | + $buff = array(); |
|
| 45 | + $map = $event->getMDCMap(); |
|
| 46 | + foreach($map as $key => $value) { |
|
| 47 | + $buff []= "$key=$value"; |
|
| 48 | + } |
|
| 49 | + return implode(', ', $buff); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | - |
|
| 54 | 53 | \ No newline at end of file |
| 54 | + |
|
| 55 | 55 | \ No newline at end of file |
@@ -32,24 +32,24 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class Payone_Log4php_LoggerLayoutSerialized extends Payone_Log4php_LoggerLayout { |
| 34 | 34 | |
| 35 | - /** Whether to include the event's location information (slow). */ |
|
| 36 | - protected $locationInfo = false; |
|
| 35 | + /** Whether to include the event's location information (slow). */ |
|
| 36 | + protected $locationInfo = false; |
|
| 37 | 37 | |
| 38 | - /** Sets the location information flag. */ |
|
| 39 | - public function setLocationInfo($value) { |
|
| 40 | - $this->setBoolean('locationInfo', $value); |
|
| 41 | - } |
|
| 38 | + /** Sets the location information flag. */ |
|
| 39 | + public function setLocationInfo($value) { |
|
| 40 | + $this->setBoolean('locationInfo', $value); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** Returns the location information flag. */ |
|
| 44 | - public function getLocationInfo() { |
|
| 45 | - return $this->locationInfo; |
|
| 46 | - } |
|
| 43 | + /** Returns the location information flag. */ |
|
| 44 | + public function getLocationInfo() { |
|
| 45 | + return $this->locationInfo; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function format(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 49 | - // If required, initialize the location data |
|
| 50 | - if($this->locationInfo) { |
|
| 51 | - $event->getLocationInformation(); |
|
| 52 | - } |
|
| 53 | - return serialize($event) . PHP_EOL; |
|
| 54 | - } |
|
| 48 | + public function format(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 49 | + // If required, initialize the location data |
|
| 50 | + if($this->locationInfo) { |
|
| 51 | + $event->getLocationInformation(); |
|
| 52 | + } |
|
| 53 | + return serialize($event) . PHP_EOL; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -28,27 +28,27 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class Payone_Log4php_LoggerFormattingInfo { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Minimal output length. If output is shorter than this value, it will be |
|
| 33 | - * padded with spaces. |
|
| 34 | - */ |
|
| 35 | - public $min = 0; |
|
| 31 | + /** |
|
| 32 | + * Minimal output length. If output is shorter than this value, it will be |
|
| 33 | + * padded with spaces. |
|
| 34 | + */ |
|
| 35 | + public $min = 0; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Maximum output length. If output is longer than this value, it will be |
|
| 39 | - * trimmed. |
|
| 40 | - */ |
|
| 41 | - public $max = PHP_INT_MAX; |
|
| 37 | + /** |
|
| 38 | + * Maximum output length. If output is longer than this value, it will be |
|
| 39 | + * trimmed. |
|
| 40 | + */ |
|
| 41 | + public $max = PHP_INT_MAX; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Whether to pad the string from the left. If set to false, the string |
|
| 45 | - * will be padded from the right. |
|
| 46 | - */ |
|
| 47 | - public $padLeft = true; |
|
| 43 | + /** |
|
| 44 | + * Whether to pad the string from the left. If set to false, the string |
|
| 45 | + * will be padded from the right. |
|
| 46 | + */ |
|
| 47 | + public $padLeft = true; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Whether to trim the string from the left. If set to false, the string |
|
| 51 | - * will be trimmed from the right. |
|
| 52 | - */ |
|
| 53 | - public $trimLeft = false; |
|
| 49 | + /** |
|
| 50 | + * Whether to trim the string from the left. If set to false, the string |
|
| 51 | + * will be trimmed from the right. |
|
| 52 | + */ |
|
| 53 | + public $trimLeft = false; |
|
| 54 | 54 | } |
@@ -27,8 +27,8 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class Payone_Log4php_LoggerPatternConverterRelative extends Payone_Log4php_LoggerPatternConverter { |
| 29 | 29 | |
| 30 | - public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 31 | - $ts = $event->getTimeStamp() - $event->getStartTime(); |
|
| 32 | - return number_format($ts, 4); |
|
| 33 | - } |
|
| 30 | + public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 31 | + $ts = $event->getTimeStamp() - $event->getStartTime(); |
|
| 32 | + return number_format($ts, 4); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -32,267 +32,267 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class Payone_Log4php_LoggerConfigurationAdapterINI implements Payone_Log4php_LoggerConfigurationAdapter { |
| 34 | 34 | |
| 35 | - /** Name to assign to the root logger. */ |
|
| 36 | - const ROOT_LOGGER_NAME = "root"; |
|
| 35 | + /** Name to assign to the root logger. */ |
|
| 36 | + const ROOT_LOGGER_NAME = "root"; |
|
| 37 | 37 | |
| 38 | - /** Prefix used for defining logger additivity. */ |
|
| 39 | - const ADDITIVITY_PREFIX = "log4php.additivity."; |
|
| 38 | + /** Prefix used for defining logger additivity. */ |
|
| 39 | + const ADDITIVITY_PREFIX = "log4php.additivity."; |
|
| 40 | 40 | |
| 41 | - /** Prefix used for defining logger threshold. */ |
|
| 42 | - const THRESHOLD_PREFIX = "log4php.threshold"; |
|
| 41 | + /** Prefix used for defining logger threshold. */ |
|
| 42 | + const THRESHOLD_PREFIX = "log4php.threshold"; |
|
| 43 | 43 | |
| 44 | - /** Prefix used for defining the root logger. */ |
|
| 45 | - const ROOT_LOGGER_PREFIX = "log4php.rootLogger"; |
|
| 44 | + /** Prefix used for defining the root logger. */ |
|
| 45 | + const ROOT_LOGGER_PREFIX = "log4php.rootLogger"; |
|
| 46 | 46 | |
| 47 | - /** Prefix used for defining a logger. */ |
|
| 48 | - const LOGGER_PREFIX = "log4php.logger."; |
|
| 47 | + /** Prefix used for defining a logger. */ |
|
| 48 | + const LOGGER_PREFIX = "log4php.logger."; |
|
| 49 | 49 | |
| 50 | - /** Prefix used for defining an appender. */ |
|
| 51 | - const APPENDER_PREFIX = "log4php.appender."; |
|
| 50 | + /** Prefix used for defining an appender. */ |
|
| 51 | + const APPENDER_PREFIX = "log4php.appender."; |
|
| 52 | 52 | |
| 53 | - /** Prefix used for defining a renderer. */ |
|
| 54 | - const RENDERER_PREFIX = "log4php.renderer."; |
|
| 53 | + /** Prefix used for defining a renderer. */ |
|
| 54 | + const RENDERER_PREFIX = "log4php.renderer."; |
|
| 55 | 55 | |
| 56 | - /** Holds the configuration. */ |
|
| 57 | - private $config = array(); |
|
| 56 | + /** Holds the configuration. */ |
|
| 57 | + private $config = array(); |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Loads and parses the INI configuration file. |
|
| 61 | - * |
|
| 62 | - * @param string $url Path to the config file. |
|
| 63 | - * @throws LoggerException |
|
| 64 | - */ |
|
| 65 | - private function load($url) { |
|
| 66 | - if (!file_exists($url)) { |
|
| 67 | - throw new Payone_Log4php_LoggerException("File [$url] does not exist."); |
|
| 68 | - } |
|
| 59 | + /** |
|
| 60 | + * Loads and parses the INI configuration file. |
|
| 61 | + * |
|
| 62 | + * @param string $url Path to the config file. |
|
| 63 | + * @throws LoggerException |
|
| 64 | + */ |
|
| 65 | + private function load($url) { |
|
| 66 | + if (!file_exists($url)) { |
|
| 67 | + throw new Payone_Log4php_LoggerException("File [$url] does not exist."); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - $properties = @parse_ini_file($url, true); |
|
| 71 | - if ($properties === false) { |
|
| 72 | - $error = error_get_last(); |
|
| 73 | - throw new Payone_Log4php_LoggerException("Error parsing configuration file: {$error['message']}"); |
|
| 74 | - } |
|
| 70 | + $properties = @parse_ini_file($url, true); |
|
| 71 | + if ($properties === false) { |
|
| 72 | + $error = error_get_last(); |
|
| 73 | + throw new Payone_Log4php_LoggerException("Error parsing configuration file: {$error['message']}"); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return $properties; |
|
| 77 | - } |
|
| 76 | + return $properties; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Converts the provided INI configuration file to a PHP array config. |
|
| 81 | - * |
|
| 82 | - * @param string $path Path to the config file. |
|
| 83 | - * @throws LoggerException If the file cannot be loaded or parsed. |
|
| 84 | - */ |
|
| 85 | - public function convert($path) { |
|
| 86 | - // Load the configuration |
|
| 87 | - $properties = $this->load($path); |
|
| 79 | + /** |
|
| 80 | + * Converts the provided INI configuration file to a PHP array config. |
|
| 81 | + * |
|
| 82 | + * @param string $path Path to the config file. |
|
| 83 | + * @throws LoggerException If the file cannot be loaded or parsed. |
|
| 84 | + */ |
|
| 85 | + public function convert($path) { |
|
| 86 | + // Load the configuration |
|
| 87 | + $properties = $this->load($path); |
|
| 88 | 88 | |
| 89 | - // Parse threshold |
|
| 90 | - if (isset($properties[self::THRESHOLD_PREFIX])) { |
|
| 91 | - $this->config['threshold'] = $properties[self::THRESHOLD_PREFIX]; |
|
| 92 | - } |
|
| 89 | + // Parse threshold |
|
| 90 | + if (isset($properties[self::THRESHOLD_PREFIX])) { |
|
| 91 | + $this->config['threshold'] = $properties[self::THRESHOLD_PREFIX]; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - // Parse root logger |
|
| 95 | - if (isset($properties[self::ROOT_LOGGER_PREFIX])) { |
|
| 96 | - $this->parseLogger($properties[self::ROOT_LOGGER_PREFIX], self::ROOT_LOGGER_NAME); |
|
| 97 | - } |
|
| 94 | + // Parse root logger |
|
| 95 | + if (isset($properties[self::ROOT_LOGGER_PREFIX])) { |
|
| 96 | + $this->parseLogger($properties[self::ROOT_LOGGER_PREFIX], self::ROOT_LOGGER_NAME); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - $appenders = array(); |
|
| 99 | + $appenders = array(); |
|
| 100 | 100 | |
| 101 | - foreach($properties as $key => $value) { |
|
| 102 | - // Parse loggers |
|
| 103 | - if ($this->beginsWith($key, self::LOGGER_PREFIX)) { |
|
| 104 | - $name = substr($key, strlen(self::LOGGER_PREFIX)); |
|
| 105 | - $this->parseLogger($value, $name); |
|
| 106 | - } |
|
| 101 | + foreach($properties as $key => $value) { |
|
| 102 | + // Parse loggers |
|
| 103 | + if ($this->beginsWith($key, self::LOGGER_PREFIX)) { |
|
| 104 | + $name = substr($key, strlen(self::LOGGER_PREFIX)); |
|
| 105 | + $this->parseLogger($value, $name); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - // Parse additivity |
|
| 109 | - if ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) { |
|
| 110 | - $name = substr($key, strlen(self::ADDITIVITY_PREFIX)); |
|
| 111 | - $this->config['loggers'][$name]['additivity'] = $value; |
|
| 112 | - } |
|
| 108 | + // Parse additivity |
|
| 109 | + if ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) { |
|
| 110 | + $name = substr($key, strlen(self::ADDITIVITY_PREFIX)); |
|
| 111 | + $this->config['loggers'][$name]['additivity'] = $value; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - // Parse appenders |
|
| 115 | - else if ($this->beginsWith($key, self::APPENDER_PREFIX)) { |
|
| 116 | - $this->parseAppender($key, $value); |
|
| 117 | - } |
|
| 114 | + // Parse appenders |
|
| 115 | + else if ($this->beginsWith($key, self::APPENDER_PREFIX)) { |
|
| 116 | + $this->parseAppender($key, $value); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - // Parse renderers |
|
| 120 | - else if ($this->beginsWith($key, self::RENDERER_PREFIX)) { |
|
| 121 | - $this->parseRenderer($key, $value); |
|
| 122 | - } |
|
| 123 | - } |
|
| 119 | + // Parse renderers |
|
| 120 | + else if ($this->beginsWith($key, self::RENDERER_PREFIX)) { |
|
| 121 | + $this->parseRenderer($key, $value); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - return $this->config; |
|
| 126 | - } |
|
| 125 | + return $this->config; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Parses a logger definition. |
|
| 131 | - * |
|
| 132 | - * Loggers are defined in the following manner: |
|
| 133 | - * <pre> |
|
| 134 | - * log4php.logger.<name> = [<level>], [<appender-ref>, <appender-ref>, ...] |
|
| 135 | - * </pre> |
|
| 136 | - * |
|
| 137 | - * @param string $value The configuration value (level and appender-refs). |
|
| 138 | - * @param string $name Logger name. |
|
| 139 | - */ |
|
| 140 | - private function parseLogger($value, $name) { |
|
| 141 | - // Value is divided by commas |
|
| 142 | - $parts = explode(',', $value); |
|
| 143 | - if (empty($value) || empty($parts)) { |
|
| 144 | - return; |
|
| 145 | - } |
|
| 129 | + /** |
|
| 130 | + * Parses a logger definition. |
|
| 131 | + * |
|
| 132 | + * Loggers are defined in the following manner: |
|
| 133 | + * <pre> |
|
| 134 | + * log4php.logger.<name> = [<level>], [<appender-ref>, <appender-ref>, ...] |
|
| 135 | + * </pre> |
|
| 136 | + * |
|
| 137 | + * @param string $value The configuration value (level and appender-refs). |
|
| 138 | + * @param string $name Logger name. |
|
| 139 | + */ |
|
| 140 | + private function parseLogger($value, $name) { |
|
| 141 | + // Value is divided by commas |
|
| 142 | + $parts = explode(',', $value); |
|
| 143 | + if (empty($value) || empty($parts)) { |
|
| 144 | + return; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - // The first value is the logger level |
|
| 148 | - $level = array_shift($parts); |
|
| 147 | + // The first value is the logger level |
|
| 148 | + $level = array_shift($parts); |
|
| 149 | 149 | |
| 150 | - // The remaining values are appender references |
|
| 151 | - $appenders = array(); |
|
| 152 | - while($appender = array_shift($parts)) { |
|
| 153 | - $appender = trim($appender); |
|
| 154 | - if (!empty($appender)) { |
|
| 155 | - $appenders[] = trim($appender); |
|
| 156 | - } |
|
| 157 | - } |
|
| 150 | + // The remaining values are appender references |
|
| 151 | + $appenders = array(); |
|
| 152 | + while($appender = array_shift($parts)) { |
|
| 153 | + $appender = trim($appender); |
|
| 154 | + if (!empty($appender)) { |
|
| 155 | + $appenders[] = trim($appender); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - // Find the target configuration |
|
| 160 | - if ($name == self::ROOT_LOGGER_NAME) { |
|
| 161 | - $this->config['rootLogger']['level'] = trim($level); |
|
| 162 | - $this->config['rootLogger']['appenders'] = $appenders; |
|
| 163 | - } else { |
|
| 164 | - $this->config['loggers'][$name]['level'] = trim($level); |
|
| 165 | - $this->config['loggers'][$name]['appenders'] = $appenders; |
|
| 166 | - } |
|
| 167 | - } |
|
| 159 | + // Find the target configuration |
|
| 160 | + if ($name == self::ROOT_LOGGER_NAME) { |
|
| 161 | + $this->config['rootLogger']['level'] = trim($level); |
|
| 162 | + $this->config['rootLogger']['appenders'] = $appenders; |
|
| 163 | + } else { |
|
| 164 | + $this->config['loggers'][$name]['level'] = trim($level); |
|
| 165 | + $this->config['loggers'][$name]['appenders'] = $appenders; |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * Parses an configuration line pertaining to an appender. |
|
| 171 | - * |
|
| 172 | - * Parses the following patterns: |
|
| 173 | - * |
|
| 174 | - * Appender class: |
|
| 175 | - * <pre> |
|
| 176 | - * log4php.appender.<name> = <class> |
|
| 177 | - * </pre> |
|
| 178 | - * |
|
| 179 | - * Appender parameter: |
|
| 180 | - * <pre> |
|
| 181 | - * log4php.appender.<name>.<param> = <value> |
|
| 182 | - * </pre> |
|
| 183 | - * |
|
| 184 | - * Appender threshold: |
|
| 185 | - * <pre> |
|
| 186 | - * log4php.appender.<name>.threshold = <level> |
|
| 187 | - * </pre> |
|
| 188 | - * |
|
| 189 | - * Appender layout: |
|
| 190 | - * <pre> |
|
| 191 | - * log4php.appender.<name>.layout = <layoutClass> |
|
| 192 | - * </pre> |
|
| 193 | - * |
|
| 194 | - * Layout parameter: |
|
| 195 | - * <pre> |
|
| 196 | - * log4php.appender.<name>.layout.<param> = <value> |
|
| 197 | - * </pre> |
|
| 198 | - * |
|
| 199 | - * For example, a full appender config might look like: |
|
| 200 | - * <pre> |
|
| 201 | - * log4php.appender.myAppender = Payone_Log4php_LoggerAppenderConsole |
|
| 202 | - * log4php.appender.myAppender.threshold = info |
|
| 203 | - * log4php.appender.myAppender.target = stdout |
|
| 204 | - * log4php.appender.myAppender.layout = LoggerLayoutPattern |
|
| 205 | - * log4php.appender.myAppender.layout.conversionPattern = "%d %c: %m%n" |
|
| 206 | - * </pre> |
|
| 207 | - * |
|
| 208 | - * After parsing all these options, the following configuration can be |
|
| 209 | - * found under $this->config['appenders']['myAppender']: |
|
| 210 | - * <pre> |
|
| 211 | - * array( |
|
| 212 | - * 'class' => Payone_Log4php_LoggerAppenderConsole, |
|
| 213 | - * 'threshold' => info, |
|
| 214 | - * 'params' => array( |
|
| 215 | - * 'target' => 'stdout' |
|
| 216 | - * ), |
|
| 217 | - * 'layout' => array( |
|
| 218 | - * 'class' => 'LoggerAppenderConsole', |
|
| 219 | - * 'params' => array( |
|
| 220 | - * 'conversionPattern' => '%d %c: %m%n' |
|
| 221 | - * ) |
|
| 222 | - * ) |
|
| 223 | - * ) |
|
| 224 | - * </pre> |
|
| 225 | - * |
|
| 226 | - * @param string $key |
|
| 227 | - * @param string $value |
|
| 228 | - */ |
|
| 229 | - private function parseAppender($key, $value) { |
|
| 169 | + /** |
|
| 170 | + * Parses an configuration line pertaining to an appender. |
|
| 171 | + * |
|
| 172 | + * Parses the following patterns: |
|
| 173 | + * |
|
| 174 | + * Appender class: |
|
| 175 | + * <pre> |
|
| 176 | + * log4php.appender.<name> = <class> |
|
| 177 | + * </pre> |
|
| 178 | + * |
|
| 179 | + * Appender parameter: |
|
| 180 | + * <pre> |
|
| 181 | + * log4php.appender.<name>.<param> = <value> |
|
| 182 | + * </pre> |
|
| 183 | + * |
|
| 184 | + * Appender threshold: |
|
| 185 | + * <pre> |
|
| 186 | + * log4php.appender.<name>.threshold = <level> |
|
| 187 | + * </pre> |
|
| 188 | + * |
|
| 189 | + * Appender layout: |
|
| 190 | + * <pre> |
|
| 191 | + * log4php.appender.<name>.layout = <layoutClass> |
|
| 192 | + * </pre> |
|
| 193 | + * |
|
| 194 | + * Layout parameter: |
|
| 195 | + * <pre> |
|
| 196 | + * log4php.appender.<name>.layout.<param> = <value> |
|
| 197 | + * </pre> |
|
| 198 | + * |
|
| 199 | + * For example, a full appender config might look like: |
|
| 200 | + * <pre> |
|
| 201 | + * log4php.appender.myAppender = Payone_Log4php_LoggerAppenderConsole |
|
| 202 | + * log4php.appender.myAppender.threshold = info |
|
| 203 | + * log4php.appender.myAppender.target = stdout |
|
| 204 | + * log4php.appender.myAppender.layout = LoggerLayoutPattern |
|
| 205 | + * log4php.appender.myAppender.layout.conversionPattern = "%d %c: %m%n" |
|
| 206 | + * </pre> |
|
| 207 | + * |
|
| 208 | + * After parsing all these options, the following configuration can be |
|
| 209 | + * found under $this->config['appenders']['myAppender']: |
|
| 210 | + * <pre> |
|
| 211 | + * array( |
|
| 212 | + * 'class' => Payone_Log4php_LoggerAppenderConsole, |
|
| 213 | + * 'threshold' => info, |
|
| 214 | + * 'params' => array( |
|
| 215 | + * 'target' => 'stdout' |
|
| 216 | + * ), |
|
| 217 | + * 'layout' => array( |
|
| 218 | + * 'class' => 'LoggerAppenderConsole', |
|
| 219 | + * 'params' => array( |
|
| 220 | + * 'conversionPattern' => '%d %c: %m%n' |
|
| 221 | + * ) |
|
| 222 | + * ) |
|
| 223 | + * ) |
|
| 224 | + * </pre> |
|
| 225 | + * |
|
| 226 | + * @param string $key |
|
| 227 | + * @param string $value |
|
| 228 | + */ |
|
| 229 | + private function parseAppender($key, $value) { |
|
| 230 | 230 | |
| 231 | - // Remove the appender prefix from key |
|
| 232 | - $subKey = substr($key, strlen(self::APPENDER_PREFIX)); |
|
| 231 | + // Remove the appender prefix from key |
|
| 232 | + $subKey = substr($key, strlen(self::APPENDER_PREFIX)); |
|
| 233 | 233 | |
| 234 | - // Divide the string by dots |
|
| 235 | - $parts = explode('.', $subKey); |
|
| 236 | - $count = count($parts); |
|
| 234 | + // Divide the string by dots |
|
| 235 | + $parts = explode('.', $subKey); |
|
| 236 | + $count = count($parts); |
|
| 237 | 237 | |
| 238 | - // The first part is always the appender name |
|
| 239 | - $name = trim($parts[0]); |
|
| 238 | + // The first part is always the appender name |
|
| 239 | + $name = trim($parts[0]); |
|
| 240 | 240 | |
| 241 | - // Only one part - this line defines the appender class |
|
| 242 | - if ($count == 1) { |
|
| 243 | - $this->config['appenders'][$name]['class'] = $value; |
|
| 244 | - return; |
|
| 245 | - } |
|
| 241 | + // Only one part - this line defines the appender class |
|
| 242 | + if ($count == 1) { |
|
| 243 | + $this->config['appenders'][$name]['class'] = $value; |
|
| 244 | + return; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - // Two parts - either a parameter, a threshold or layout class |
|
| 248 | - else if ($count == 2) { |
|
| 247 | + // Two parts - either a parameter, a threshold or layout class |
|
| 248 | + else if ($count == 2) { |
|
| 249 | 249 | |
| 250 | - if ($parts[1] == 'layout') { |
|
| 251 | - $this->config['appenders'][$name]['layout']['class'] = $value; |
|
| 252 | - return; |
|
| 253 | - } else if ($parts[1] == 'threshold') { |
|
| 254 | - $this->config['appenders'][$name]['threshold'] = $value; |
|
| 255 | - return; |
|
| 256 | - } else { |
|
| 257 | - $this->config['appenders'][$name]['params'][$parts[1]] = $value; |
|
| 258 | - return; |
|
| 259 | - } |
|
| 260 | - } |
|
| 250 | + if ($parts[1] == 'layout') { |
|
| 251 | + $this->config['appenders'][$name]['layout']['class'] = $value; |
|
| 252 | + return; |
|
| 253 | + } else if ($parts[1] == 'threshold') { |
|
| 254 | + $this->config['appenders'][$name]['threshold'] = $value; |
|
| 255 | + return; |
|
| 256 | + } else { |
|
| 257 | + $this->config['appenders'][$name]['params'][$parts[1]] = $value; |
|
| 258 | + return; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - // Three parts - this can only be a layout parameter |
|
| 263 | - else if ($count == 3) { |
|
| 264 | - if ($parts[1] == 'layout') { |
|
| 265 | - $this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value; |
|
| 266 | - return; |
|
| 267 | - } |
|
| 268 | - } |
|
| 262 | + // Three parts - this can only be a layout parameter |
|
| 263 | + else if ($count == 3) { |
|
| 264 | + if ($parts[1] == 'layout') { |
|
| 265 | + $this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value; |
|
| 266 | + return; |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping."); |
|
| 271 | - } |
|
| 270 | + trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping."); |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - /** |
|
| 274 | - * Parses a renderer definition. |
|
| 275 | - * |
|
| 276 | - * Renderers are defined as: |
|
| 277 | - * <pre> |
|
| 278 | - * log4php.renderer.<renderedClass> = <renderingClass> |
|
| 279 | - * </pre> |
|
| 280 | - * |
|
| 281 | - * @param string $key log4php.renderer.<renderedClass> |
|
| 282 | - * @param string $value <renderingClass> |
|
| 283 | - */ |
|
| 284 | - private function parseRenderer($key, $value) { |
|
| 285 | - // Remove the appender prefix from key |
|
| 286 | - $renderedClass = substr($key, strlen(self::APPENDER_PREFIX)); |
|
| 287 | - $renderingClass = $value; |
|
| 273 | + /** |
|
| 274 | + * Parses a renderer definition. |
|
| 275 | + * |
|
| 276 | + * Renderers are defined as: |
|
| 277 | + * <pre> |
|
| 278 | + * log4php.renderer.<renderedClass> = <renderingClass> |
|
| 279 | + * </pre> |
|
| 280 | + * |
|
| 281 | + * @param string $key log4php.renderer.<renderedClass> |
|
| 282 | + * @param string $value <renderingClass> |
|
| 283 | + */ |
|
| 284 | + private function parseRenderer($key, $value) { |
|
| 285 | + // Remove the appender prefix from key |
|
| 286 | + $renderedClass = substr($key, strlen(self::APPENDER_PREFIX)); |
|
| 287 | + $renderingClass = $value; |
|
| 288 | 288 | |
| 289 | - $this->config['renderers'][] = compact('renderedClass', 'renderingClass'); |
|
| 290 | - } |
|
| 289 | + $this->config['renderers'][] = compact('renderedClass', 'renderingClass'); |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - /** Helper method. Returns true if $str begins with $sub. */ |
|
| 293 | - private function beginsWith($str, $sub) { |
|
| 294 | - return (strncmp($str, $sub, strlen($sub)) == 0); |
|
| 295 | - } |
|
| 292 | + /** Helper method. Returns true if $str begins with $sub. */ |
|
| 293 | + private function beginsWith($str, $sub) { |
|
| 294 | + return (strncmp($str, $sub, strlen($sub)) == 0); |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | 297 | |
| 298 | 298 | } |
@@ -33,224 +33,224 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class Payone_Log4php_LoggerLevel { |
| 35 | 35 | |
| 36 | - const OFF = 2147483647; |
|
| 37 | - const FATAL = 50000; |
|
| 38 | - const ERROR = 40000; |
|
| 39 | - const WARN = 30000; |
|
| 40 | - const INFO = 20000; |
|
| 41 | - const DEBUG = 10000; |
|
| 42 | - const TRACE = 5000; |
|
| 43 | - const ALL = -2147483647; |
|
| 36 | + const OFF = 2147483647; |
|
| 37 | + const FATAL = 50000; |
|
| 38 | + const ERROR = 40000; |
|
| 39 | + const WARN = 30000; |
|
| 40 | + const INFO = 20000; |
|
| 41 | + const DEBUG = 10000; |
|
| 42 | + const TRACE = 5000; |
|
| 43 | + const ALL = -2147483647; |
|
| 44 | 44 | |
| 45 | - /** Integer level value. */ |
|
| 46 | - private $level; |
|
| 45 | + /** Integer level value. */ |
|
| 46 | + private $level; |
|
| 47 | 47 | |
| 48 | - /** Contains a list of instantiated levels. */ |
|
| 49 | - private static $levelMap; |
|
| 48 | + /** Contains a list of instantiated levels. */ |
|
| 49 | + private static $levelMap; |
|
| 50 | 50 | |
| 51 | - /** String representation of the level. */ |
|
| 52 | - private $levelStr; |
|
| 51 | + /** String representation of the level. */ |
|
| 52 | + private $levelStr; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Equivalent syslog level. |
|
| 56 | - * @var integer |
|
| 57 | - */ |
|
| 58 | - private $syslogEquivalent; |
|
| 54 | + /** |
|
| 55 | + * Equivalent syslog level. |
|
| 56 | + * @var integer |
|
| 57 | + */ |
|
| 58 | + private $syslogEquivalent; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Constructor |
|
| 62 | - * |
|
| 63 | - * @param integer $level |
|
| 64 | - * @param string $levelStr |
|
| 65 | - * @param integer $syslogEquivalent |
|
| 66 | - */ |
|
| 67 | - private function __construct($level, $levelStr, $syslogEquivalent) { |
|
| 68 | - $this->level = $level; |
|
| 69 | - $this->levelStr = $levelStr; |
|
| 70 | - $this->syslogEquivalent = $syslogEquivalent; |
|
| 71 | - } |
|
| 60 | + /** |
|
| 61 | + * Constructor |
|
| 62 | + * |
|
| 63 | + * @param integer $level |
|
| 64 | + * @param string $levelStr |
|
| 65 | + * @param integer $syslogEquivalent |
|
| 66 | + */ |
|
| 67 | + private function __construct($level, $levelStr, $syslogEquivalent) { |
|
| 68 | + $this->level = $level; |
|
| 69 | + $this->levelStr = $levelStr; |
|
| 70 | + $this->syslogEquivalent = $syslogEquivalent; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Compares two logger levels. |
|
| 75 | - * |
|
| 76 | - * @param LoggerLevels $other |
|
| 77 | - * @return boolean |
|
| 78 | - */ |
|
| 79 | - public function equals($other) { |
|
| 80 | - if($other instanceof Payone_Log4php_LoggerLevel) { |
|
| 81 | - if($this->level == $other->level) { |
|
| 82 | - return true; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - return false; |
|
| 86 | - } |
|
| 87 | - } |
|
| 73 | + /** |
|
| 74 | + * Compares two logger levels. |
|
| 75 | + * |
|
| 76 | + * @param LoggerLevels $other |
|
| 77 | + * @return boolean |
|
| 78 | + */ |
|
| 79 | + public function equals($other) { |
|
| 80 | + if($other instanceof Payone_Log4php_LoggerLevel) { |
|
| 81 | + if($this->level == $other->level) { |
|
| 82 | + return true; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + return false; |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Returns an Off Level |
|
| 91 | - * @return Payone_Log4php_LoggerLevel |
|
| 92 | - */ |
|
| 93 | - public static function getLevelOff() { |
|
| 94 | - if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::OFF])) { |
|
| 95 | - self::$levelMap[Payone_Log4php_LoggerLevel::OFF] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::OFF, 'OFF', LOG_ALERT); |
|
| 96 | - } |
|
| 97 | - return self::$levelMap[Payone_Log4php_LoggerLevel::OFF]; |
|
| 98 | - } |
|
| 89 | + /** |
|
| 90 | + * Returns an Off Level |
|
| 91 | + * @return Payone_Log4php_LoggerLevel |
|
| 92 | + */ |
|
| 93 | + public static function getLevelOff() { |
|
| 94 | + if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::OFF])) { |
|
| 95 | + self::$levelMap[Payone_Log4php_LoggerLevel::OFF] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::OFF, 'OFF', LOG_ALERT); |
|
| 96 | + } |
|
| 97 | + return self::$levelMap[Payone_Log4php_LoggerLevel::OFF]; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Returns a Fatal Level |
|
| 102 | - * @return Payone_Log4php_LoggerLevel |
|
| 103 | - */ |
|
| 104 | - public static function getLevelFatal() { |
|
| 105 | - if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::FATAL])) { |
|
| 106 | - self::$levelMap[Payone_Log4php_LoggerLevel::FATAL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::FATAL, 'FATAL', LOG_ALERT); |
|
| 107 | - } |
|
| 108 | - return self::$levelMap[Payone_Log4php_LoggerLevel::FATAL]; |
|
| 109 | - } |
|
| 100 | + /** |
|
| 101 | + * Returns a Fatal Level |
|
| 102 | + * @return Payone_Log4php_LoggerLevel |
|
| 103 | + */ |
|
| 104 | + public static function getLevelFatal() { |
|
| 105 | + if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::FATAL])) { |
|
| 106 | + self::$levelMap[Payone_Log4php_LoggerLevel::FATAL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::FATAL, 'FATAL', LOG_ALERT); |
|
| 107 | + } |
|
| 108 | + return self::$levelMap[Payone_Log4php_LoggerLevel::FATAL]; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Returns an Error Level |
|
| 113 | - * @return Payone_Log4php_LoggerLevel |
|
| 114 | - */ |
|
| 115 | - public static function getLevelError() { |
|
| 116 | - if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ERROR])) { |
|
| 117 | - self::$levelMap[Payone_Log4php_LoggerLevel::ERROR] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ERROR, 'ERROR', LOG_ERR); |
|
| 118 | - } |
|
| 119 | - return self::$levelMap[Payone_Log4php_LoggerLevel::ERROR]; |
|
| 120 | - } |
|
| 111 | + /** |
|
| 112 | + * Returns an Error Level |
|
| 113 | + * @return Payone_Log4php_LoggerLevel |
|
| 114 | + */ |
|
| 115 | + public static function getLevelError() { |
|
| 116 | + if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ERROR])) { |
|
| 117 | + self::$levelMap[Payone_Log4php_LoggerLevel::ERROR] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ERROR, 'ERROR', LOG_ERR); |
|
| 118 | + } |
|
| 119 | + return self::$levelMap[Payone_Log4php_LoggerLevel::ERROR]; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Returns a Warn Level |
|
| 124 | - * @return Payone_Log4php_LoggerLevel |
|
| 125 | - */ |
|
| 126 | - public static function getLevelWarn() { |
|
| 127 | - if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::WARN])) { |
|
| 128 | - self::$levelMap[Payone_Log4php_LoggerLevel::WARN] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::WARN, 'WARN', LOG_WARNING); |
|
| 129 | - } |
|
| 130 | - return self::$levelMap[Payone_Log4php_LoggerLevel::WARN]; |
|
| 131 | - } |
|
| 122 | + /** |
|
| 123 | + * Returns a Warn Level |
|
| 124 | + * @return Payone_Log4php_LoggerLevel |
|
| 125 | + */ |
|
| 126 | + public static function getLevelWarn() { |
|
| 127 | + if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::WARN])) { |
|
| 128 | + self::$levelMap[Payone_Log4php_LoggerLevel::WARN] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::WARN, 'WARN', LOG_WARNING); |
|
| 129 | + } |
|
| 130 | + return self::$levelMap[Payone_Log4php_LoggerLevel::WARN]; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Returns an Info Level |
|
| 135 | - * @return Payone_Log4php_LoggerLevel |
|
| 136 | - */ |
|
| 137 | - public static function getLevelInfo() { |
|
| 138 | - if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::INFO])) { |
|
| 139 | - self::$levelMap[Payone_Log4php_LoggerLevel::INFO] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::INFO, 'INFO', LOG_INFO); |
|
| 140 | - } |
|
| 141 | - return self::$levelMap[Payone_Log4php_LoggerLevel::INFO]; |
|
| 142 | - } |
|
| 133 | + /** |
|
| 134 | + * Returns an Info Level |
|
| 135 | + * @return Payone_Log4php_LoggerLevel |
|
| 136 | + */ |
|
| 137 | + public static function getLevelInfo() { |
|
| 138 | + if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::INFO])) { |
|
| 139 | + self::$levelMap[Payone_Log4php_LoggerLevel::INFO] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::INFO, 'INFO', LOG_INFO); |
|
| 140 | + } |
|
| 141 | + return self::$levelMap[Payone_Log4php_LoggerLevel::INFO]; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * Returns a Debug Level |
|
| 146 | - * @return Payone_Log4php_LoggerLevel |
|
| 147 | - */ |
|
| 148 | - public static function getLevelDebug() { |
|
| 149 | - if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG])) { |
|
| 150 | - self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG); |
|
| 151 | - } |
|
| 152 | - return self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG]; |
|
| 153 | - } |
|
| 144 | + /** |
|
| 145 | + * Returns a Debug Level |
|
| 146 | + * @return Payone_Log4php_LoggerLevel |
|
| 147 | + */ |
|
| 148 | + public static function getLevelDebug() { |
|
| 149 | + if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG])) { |
|
| 150 | + self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG); |
|
| 151 | + } |
|
| 152 | + return self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG]; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * Returns a Trace Level |
|
| 157 | - * @return Payone_Log4php_LoggerLevel |
|
| 158 | - */ |
|
| 159 | - public static function getLevelTrace() { |
|
| 160 | - if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::TRACE])) { |
|
| 161 | - self::$levelMap[Payone_Log4php_LoggerLevel::TRACE] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::TRACE, 'TRACE', LOG_DEBUG); |
|
| 162 | - } |
|
| 163 | - return self::$levelMap[Payone_Log4php_LoggerLevel::TRACE]; |
|
| 164 | - } |
|
| 155 | + /** |
|
| 156 | + * Returns a Trace Level |
|
| 157 | + * @return Payone_Log4php_LoggerLevel |
|
| 158 | + */ |
|
| 159 | + public static function getLevelTrace() { |
|
| 160 | + if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::TRACE])) { |
|
| 161 | + self::$levelMap[Payone_Log4php_LoggerLevel::TRACE] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::TRACE, 'TRACE', LOG_DEBUG); |
|
| 162 | + } |
|
| 163 | + return self::$levelMap[Payone_Log4php_LoggerLevel::TRACE]; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * Returns an All Level |
|
| 168 | - * @return Payone_Log4php_LoggerLevel |
|
| 169 | - */ |
|
| 170 | - public static function getLevelAll() { |
|
| 171 | - if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ALL])) { |
|
| 172 | - self::$levelMap[Payone_Log4php_LoggerLevel::ALL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ALL, 'ALL', LOG_DEBUG); |
|
| 173 | - } |
|
| 174 | - return self::$levelMap[Payone_Log4php_LoggerLevel::ALL]; |
|
| 175 | - } |
|
| 166 | + /** |
|
| 167 | + * Returns an All Level |
|
| 168 | + * @return Payone_Log4php_LoggerLevel |
|
| 169 | + */ |
|
| 170 | + public static function getLevelAll() { |
|
| 171 | + if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ALL])) { |
|
| 172 | + self::$levelMap[Payone_Log4php_LoggerLevel::ALL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ALL, 'ALL', LOG_DEBUG); |
|
| 173 | + } |
|
| 174 | + return self::$levelMap[Payone_Log4php_LoggerLevel::ALL]; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Return the syslog equivalent of this priority as an integer. |
|
| 179 | - * @return integer |
|
| 180 | - */ |
|
| 181 | - public function getSyslogEquivalent() { |
|
| 182 | - return $this->syslogEquivalent; |
|
| 183 | - } |
|
| 177 | + /** |
|
| 178 | + * Return the syslog equivalent of this priority as an integer. |
|
| 179 | + * @return integer |
|
| 180 | + */ |
|
| 181 | + public function getSyslogEquivalent() { |
|
| 182 | + return $this->syslogEquivalent; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Returns <i>true</i> if this level has a higher or equal |
|
| 187 | - * level than the level passed as argument, <i>false</i> |
|
| 188 | - * otherwise. |
|
| 189 | - * |
|
| 190 | - * @param Payone_Log4php_LoggerLevel $other |
|
| 191 | - * @return boolean |
|
| 192 | - */ |
|
| 193 | - public function isGreaterOrEqual($other) { |
|
| 194 | - return $this->level >= $other->level; |
|
| 195 | - } |
|
| 185 | + /** |
|
| 186 | + * Returns <i>true</i> if this level has a higher or equal |
|
| 187 | + * level than the level passed as argument, <i>false</i> |
|
| 188 | + * otherwise. |
|
| 189 | + * |
|
| 190 | + * @param Payone_Log4php_LoggerLevel $other |
|
| 191 | + * @return boolean |
|
| 192 | + */ |
|
| 193 | + public function isGreaterOrEqual($other) { |
|
| 194 | + return $this->level >= $other->level; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * Returns the string representation of this level. |
|
| 199 | - * @return string |
|
| 200 | - */ |
|
| 201 | - public function toString() { |
|
| 202 | - return $this->levelStr; |
|
| 203 | - } |
|
| 197 | + /** |
|
| 198 | + * Returns the string representation of this level. |
|
| 199 | + * @return string |
|
| 200 | + */ |
|
| 201 | + public function toString() { |
|
| 202 | + return $this->levelStr; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Returns the string representation of this level. |
|
| 207 | - * @return string |
|
| 208 | - */ |
|
| 209 | - public function __toString() { |
|
| 210 | - return $this->toString(); |
|
| 211 | - } |
|
| 205 | + /** |
|
| 206 | + * Returns the string representation of this level. |
|
| 207 | + * @return string |
|
| 208 | + */ |
|
| 209 | + public function __toString() { |
|
| 210 | + return $this->toString(); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Returns the integer representation of this level. |
|
| 215 | - * @return integer |
|
| 216 | - */ |
|
| 217 | - public function toInt() { |
|
| 218 | - return $this->level; |
|
| 219 | - } |
|
| 213 | + /** |
|
| 214 | + * Returns the integer representation of this level. |
|
| 215 | + * @return integer |
|
| 216 | + */ |
|
| 217 | + public function toInt() { |
|
| 218 | + return $this->level; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - /** |
|
| 222 | - * Convert the input argument to a level. If the conversion fails, then |
|
| 223 | - * this method returns the provided default level. |
|
| 224 | - * |
|
| 225 | - * @param mixed $arg The value to convert to level. |
|
| 226 | - * @param Payone_Log4php_LoggerLevel $default Value to return if conversion is not possible. |
|
| 227 | - * @return Payone_Log4php_LoggerLevel |
|
| 228 | - */ |
|
| 229 | - public static function toLevel($arg, $defaultLevel = null) { |
|
| 230 | - if(is_int($arg)) { |
|
| 231 | - switch($arg) { |
|
| 232 | - case self::ALL: return self::getLevelAll(); |
|
| 233 | - case self::TRACE: return self::getLevelTrace(); |
|
| 234 | - case self::DEBUG: return self::getLevelDebug(); |
|
| 235 | - case self::INFO: return self::getLevelInfo(); |
|
| 236 | - case self::WARN: return self::getLevelWarn(); |
|
| 237 | - case self::ERROR: return self::getLevelError(); |
|
| 238 | - case self::FATAL: return self::getLevelFatal(); |
|
| 239 | - case self::OFF: return self::getLevelOff(); |
|
| 240 | - default: return $defaultLevel; |
|
| 241 | - } |
|
| 242 | - } else { |
|
| 243 | - switch(strtoupper($arg)) { |
|
| 244 | - case 'ALL': return self::getLevelAll(); |
|
| 245 | - case 'TRACE': return self::getLevelTrace(); |
|
| 246 | - case 'DEBUG': return self::getLevelDebug(); |
|
| 247 | - case 'INFO': return self::getLevelInfo(); |
|
| 248 | - case 'WARN': return self::getLevelWarn(); |
|
| 249 | - case 'ERROR': return self::getLevelError(); |
|
| 250 | - case 'FATAL': return self::getLevelFatal(); |
|
| 251 | - case 'OFF': return self::getLevelOff(); |
|
| 252 | - default: return $defaultLevel; |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 221 | + /** |
|
| 222 | + * Convert the input argument to a level. If the conversion fails, then |
|
| 223 | + * this method returns the provided default level. |
|
| 224 | + * |
|
| 225 | + * @param mixed $arg The value to convert to level. |
|
| 226 | + * @param Payone_Log4php_LoggerLevel $default Value to return if conversion is not possible. |
|
| 227 | + * @return Payone_Log4php_LoggerLevel |
|
| 228 | + */ |
|
| 229 | + public static function toLevel($arg, $defaultLevel = null) { |
|
| 230 | + if(is_int($arg)) { |
|
| 231 | + switch($arg) { |
|
| 232 | + case self::ALL: return self::getLevelAll(); |
|
| 233 | + case self::TRACE: return self::getLevelTrace(); |
|
| 234 | + case self::DEBUG: return self::getLevelDebug(); |
|
| 235 | + case self::INFO: return self::getLevelInfo(); |
|
| 236 | + case self::WARN: return self::getLevelWarn(); |
|
| 237 | + case self::ERROR: return self::getLevelError(); |
|
| 238 | + case self::FATAL: return self::getLevelFatal(); |
|
| 239 | + case self::OFF: return self::getLevelOff(); |
|
| 240 | + default: return $defaultLevel; |
|
| 241 | + } |
|
| 242 | + } else { |
|
| 243 | + switch(strtoupper($arg)) { |
|
| 244 | + case 'ALL': return self::getLevelAll(); |
|
| 245 | + case 'TRACE': return self::getLevelTrace(); |
|
| 246 | + case 'DEBUG': return self::getLevelDebug(); |
|
| 247 | + case 'INFO': return self::getLevelInfo(); |
|
| 248 | + case 'WARN': return self::getLevelWarn(); |
|
| 249 | + case 'ERROR': return self::getLevelError(); |
|
| 250 | + case 'FATAL': return self::getLevelFatal(); |
|
| 251 | + case 'OFF': return self::getLevelOff(); |
|
| 252 | + default: return $defaultLevel; |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | 256 | } |
@@ -26,344 +26,344 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class Payone_Log4php_LoggerLoggingEvent { |
| 28 | 28 | |
| 29 | - private static $startTime; |
|
| 29 | + private static $startTime; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var string Fully Qualified Class Name of the calling category class. |
|
| 33 | - */ |
|
| 34 | - private $fqcn; |
|
| 31 | + /** |
|
| 32 | + * @var string Fully Qualified Class Name of the calling category class. |
|
| 33 | + */ |
|
| 34 | + private $fqcn; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var Logger reference |
|
| 38 | - */ |
|
| 39 | - private $logger = null; |
|
| 36 | + /** |
|
| 37 | + * @var Logger reference |
|
| 38 | + */ |
|
| 39 | + private $logger = null; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * The category (logger) name. |
|
| 43 | - * This field will be marked as private in future |
|
| 44 | - * releases. Please do not access it directly. |
|
| 45 | - * Use the {@link getLoggerName()} method instead. |
|
| 46 | - * @deprecated |
|
| 47 | - */ |
|
| 48 | - private $categoryName; |
|
| 41 | + /** |
|
| 42 | + * The category (logger) name. |
|
| 43 | + * This field will be marked as private in future |
|
| 44 | + * releases. Please do not access it directly. |
|
| 45 | + * Use the {@link getLoggerName()} method instead. |
|
| 46 | + * @deprecated |
|
| 47 | + */ |
|
| 48 | + private $categoryName; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Level of the logging event. |
|
| 52 | - * @var Payone_Log4php_LoggerLevel |
|
| 53 | - */ |
|
| 54 | - protected $level; |
|
| 50 | + /** |
|
| 51 | + * Level of the logging event. |
|
| 52 | + * @var Payone_Log4php_LoggerLevel |
|
| 53 | + */ |
|
| 54 | + protected $level; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * The nested diagnostic context (NDC) of logging event. |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 60 | - private $ndc; |
|
| 56 | + /** |
|
| 57 | + * The nested diagnostic context (NDC) of logging event. |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | + private $ndc; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Have we tried to do an NDC lookup? If we did, there is no need |
|
| 64 | - * to do it again. Note that its value is always false when |
|
| 65 | - * serialized. Thus, a receiving SocketNode will never use it's own |
|
| 66 | - * (incorrect) NDC. See also writeObject method. |
|
| 67 | - * @var boolean |
|
| 68 | - */ |
|
| 69 | - private $ndcLookupRequired = true; |
|
| 62 | + /** |
|
| 63 | + * Have we tried to do an NDC lookup? If we did, there is no need |
|
| 64 | + * to do it again. Note that its value is always false when |
|
| 65 | + * serialized. Thus, a receiving SocketNode will never use it's own |
|
| 66 | + * (incorrect) NDC. See also writeObject method. |
|
| 67 | + * @var boolean |
|
| 68 | + */ |
|
| 69 | + private $ndcLookupRequired = true; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Have we tried to do an MDC lookup? If we did, there is no need |
|
| 73 | - * to do it again. Note that its value is always false when |
|
| 74 | - * serialized. See also the getMDC and getMDCCopy methods. |
|
| 75 | - * @var boolean |
|
| 76 | - */ |
|
| 77 | - private $mdcCopyLookupRequired = true; |
|
| 71 | + /** |
|
| 72 | + * Have we tried to do an MDC lookup? If we did, there is no need |
|
| 73 | + * to do it again. Note that its value is always false when |
|
| 74 | + * serialized. See also the getMDC and getMDCCopy methods. |
|
| 75 | + * @var boolean |
|
| 76 | + */ |
|
| 77 | + private $mdcCopyLookupRequired = true; |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @var mixed The application supplied message of logging event. |
|
| 81 | - */ |
|
| 82 | - private $message; |
|
| 79 | + /** |
|
| 80 | + * @var mixed The application supplied message of logging event. |
|
| 81 | + */ |
|
| 82 | + private $message; |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * The application supplied message rendered through the log4php |
|
| 86 | - * objet rendering mechanism. At present renderedMessage == message. |
|
| 87 | - * @var string |
|
| 88 | - */ |
|
| 89 | - private $renderedMessage = null; |
|
| 84 | + /** |
|
| 85 | + * The application supplied message rendered through the log4php |
|
| 86 | + * objet rendering mechanism. At present renderedMessage == message. |
|
| 87 | + * @var string |
|
| 88 | + */ |
|
| 89 | + private $renderedMessage = null; |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * The name of thread in which this logging event was generated. |
|
| 93 | - * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} |
|
| 94 | - * @var mixed |
|
| 95 | - */ |
|
| 96 | - private $threadName = null; |
|
| 91 | + /** |
|
| 92 | + * The name of thread in which this logging event was generated. |
|
| 93 | + * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} |
|
| 94 | + * @var mixed |
|
| 95 | + */ |
|
| 96 | + private $threadName = null; |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * The number of seconds elapsed from 1/1/1970 until logging event |
|
| 100 | - * was created plus microseconds if available. |
|
| 101 | - * @var float |
|
| 102 | - */ |
|
| 103 | - public $timeStamp; |
|
| 98 | + /** |
|
| 99 | + * The number of seconds elapsed from 1/1/1970 until logging event |
|
| 100 | + * was created plus microseconds if available. |
|
| 101 | + * @var float |
|
| 102 | + */ |
|
| 103 | + public $timeStamp; |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * @var Payone_Log4php_LoggerLocationInfo Location information for the caller. |
|
| 107 | - */ |
|
| 108 | - private $locationInfo = null; |
|
| 105 | + /** |
|
| 106 | + * @var Payone_Log4php_LoggerLocationInfo Location information for the caller. |
|
| 107 | + */ |
|
| 108 | + private $locationInfo = null; |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * @var Payone_Log4php_LoggerThrowableInformation log4php internal representation of throwable |
|
| 112 | - */ |
|
| 113 | - private $throwableInfo = null; |
|
| 110 | + /** |
|
| 111 | + * @var Payone_Log4php_LoggerThrowableInformation log4php internal representation of throwable |
|
| 112 | + */ |
|
| 113 | + private $throwableInfo = null; |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Instantiate a LoggingEvent from the supplied parameters. |
|
| 117 | - * |
|
| 118 | - * Except {@link $timeStamp} all the other fields of |
|
| 119 | - * LoggerLoggingEvent are filled when actually needed. |
|
| 120 | - * |
|
| 121 | - * @param string $fqcn name of the caller class. |
|
| 122 | - * @param mixed $logger The {@link Logger} category of this event or the logger name. |
|
| 123 | - * @param Payone_Log4php_LoggerLevel $priority The level of this event. |
|
| 124 | - * @param mixed $message The message of this event. |
|
| 125 | - * @param integer $timeStamp the timestamp of this logging event. |
|
| 126 | - * @param Exception $throwable The throwable associated with logging event |
|
| 127 | - */ |
|
| 128 | - public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null, Exception $throwable = null) { |
|
| 129 | - $this->fqcn = $fqcn; |
|
| 130 | - if($logger instanceof Payone_Log4php_Logger) { |
|
| 131 | - $this->logger = $logger; |
|
| 132 | - $this->categoryName = $logger->getName(); |
|
| 133 | - } else { |
|
| 134 | - $this->categoryName = strval($logger); |
|
| 135 | - } |
|
| 136 | - $this->level = $priority; |
|
| 137 | - $this->message = $message; |
|
| 138 | - if($timeStamp !== null && is_float($timeStamp)) { |
|
| 139 | - $this->timeStamp = $timeStamp; |
|
| 140 | - } else { |
|
| 141 | - $this->timeStamp = microtime(true); |
|
| 142 | - } |
|
| 115 | + /** |
|
| 116 | + * Instantiate a LoggingEvent from the supplied parameters. |
|
| 117 | + * |
|
| 118 | + * Except {@link $timeStamp} all the other fields of |
|
| 119 | + * LoggerLoggingEvent are filled when actually needed. |
|
| 120 | + * |
|
| 121 | + * @param string $fqcn name of the caller class. |
|
| 122 | + * @param mixed $logger The {@link Logger} category of this event or the logger name. |
|
| 123 | + * @param Payone_Log4php_LoggerLevel $priority The level of this event. |
|
| 124 | + * @param mixed $message The message of this event. |
|
| 125 | + * @param integer $timeStamp the timestamp of this logging event. |
|
| 126 | + * @param Exception $throwable The throwable associated with logging event |
|
| 127 | + */ |
|
| 128 | + public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null, Exception $throwable = null) { |
|
| 129 | + $this->fqcn = $fqcn; |
|
| 130 | + if($logger instanceof Payone_Log4php_Logger) { |
|
| 131 | + $this->logger = $logger; |
|
| 132 | + $this->categoryName = $logger->getName(); |
|
| 133 | + } else { |
|
| 134 | + $this->categoryName = strval($logger); |
|
| 135 | + } |
|
| 136 | + $this->level = $priority; |
|
| 137 | + $this->message = $message; |
|
| 138 | + if($timeStamp !== null && is_float($timeStamp)) { |
|
| 139 | + $this->timeStamp = $timeStamp; |
|
| 140 | + } else { |
|
| 141 | + $this->timeStamp = microtime(true); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if ($throwable !== null && $throwable instanceof Exception) { |
|
| 145 | - $this->throwableInfo = new Payone_Log4php_LoggerThrowableInformation($throwable); |
|
| 146 | - } |
|
| 147 | - } |
|
| 144 | + if ($throwable !== null && $throwable instanceof Exception) { |
|
| 145 | + $this->throwableInfo = new Payone_Log4php_LoggerThrowableInformation($throwable); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Returns the full qualified classname. |
|
| 151 | - * TODO: PHP does contain namespaces in 5.3. Those should be returned too, |
|
| 152 | - */ |
|
| 153 | - public function getFullQualifiedClassname() { |
|
| 154 | - return $this->fqcn; |
|
| 155 | - } |
|
| 149 | + /** |
|
| 150 | + * Returns the full qualified classname. |
|
| 151 | + * TODO: PHP does contain namespaces in 5.3. Those should be returned too, |
|
| 152 | + */ |
|
| 153 | + public function getFullQualifiedClassname() { |
|
| 154 | + return $this->fqcn; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - /** |
|
| 158 | - * Set the location information for this logging event. The collected |
|
| 159 | - * information is cached for future use. |
|
| 160 | - * |
|
| 161 | - * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists) |
|
| 162 | - * to collect informations about caller.</p> |
|
| 163 | - * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p> |
|
| 164 | - * @return Payone_Log4php_LoggerLocationInfo |
|
| 165 | - */ |
|
| 166 | - public function getLocationInformation() { |
|
| 167 | - if($this->locationInfo === null) { |
|
| 157 | + /** |
|
| 158 | + * Set the location information for this logging event. The collected |
|
| 159 | + * information is cached for future use. |
|
| 160 | + * |
|
| 161 | + * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists) |
|
| 162 | + * to collect informations about caller.</p> |
|
| 163 | + * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p> |
|
| 164 | + * @return Payone_Log4php_LoggerLocationInfo |
|
| 165 | + */ |
|
| 166 | + public function getLocationInformation() { |
|
| 167 | + if($this->locationInfo === null) { |
|
| 168 | 168 | |
| 169 | - $locationInfo = array(); |
|
| 170 | - $trace = debug_backtrace(); |
|
| 171 | - $prevHop = null; |
|
| 172 | - // make a downsearch to identify the caller |
|
| 173 | - $hop = array_pop($trace); |
|
| 174 | - while($hop !== null) { |
|
| 175 | - if(isset($hop['class'])) { |
|
| 176 | - // we are sometimes in functions = no class available: avoid php warning here |
|
| 177 | - $className = strtolower($hop['class']); |
|
| 178 | - if(!empty($className) and ($className == 'logger' or |
|
| 179 | - strtolower(get_parent_class($className)) == 'logger')) { |
|
| 180 | - $locationInfo['line'] = $hop['line']; |
|
| 181 | - $locationInfo['file'] = $hop['file']; |
|
| 182 | - break; |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - $prevHop = $hop; |
|
| 186 | - $hop = array_pop($trace); |
|
| 187 | - } |
|
| 188 | - $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; |
|
| 189 | - if(isset($prevHop['function']) and |
|
| 190 | - $prevHop['function'] !== 'include' and |
|
| 191 | - $prevHop['function'] !== 'include_once' and |
|
| 192 | - $prevHop['function'] !== 'require' and |
|
| 193 | - $prevHop['function'] !== 'require_once') { |
|
| 169 | + $locationInfo = array(); |
|
| 170 | + $trace = debug_backtrace(); |
|
| 171 | + $prevHop = null; |
|
| 172 | + // make a downsearch to identify the caller |
|
| 173 | + $hop = array_pop($trace); |
|
| 174 | + while($hop !== null) { |
|
| 175 | + if(isset($hop['class'])) { |
|
| 176 | + // we are sometimes in functions = no class available: avoid php warning here |
|
| 177 | + $className = strtolower($hop['class']); |
|
| 178 | + if(!empty($className) and ($className == 'logger' or |
|
| 179 | + strtolower(get_parent_class($className)) == 'logger')) { |
|
| 180 | + $locationInfo['line'] = $hop['line']; |
|
| 181 | + $locationInfo['file'] = $hop['file']; |
|
| 182 | + break; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + $prevHop = $hop; |
|
| 186 | + $hop = array_pop($trace); |
|
| 187 | + } |
|
| 188 | + $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; |
|
| 189 | + if(isset($prevHop['function']) and |
|
| 190 | + $prevHop['function'] !== 'include' and |
|
| 191 | + $prevHop['function'] !== 'include_once' and |
|
| 192 | + $prevHop['function'] !== 'require' and |
|
| 193 | + $prevHop['function'] !== 'require_once') { |
|
| 194 | 194 | |
| 195 | - $locationInfo['function'] = $prevHop['function']; |
|
| 196 | - } else { |
|
| 197 | - $locationInfo['function'] = 'main'; |
|
| 198 | - } |
|
| 195 | + $locationInfo['function'] = $prevHop['function']; |
|
| 196 | + } else { |
|
| 197 | + $locationInfo['function'] = 'main'; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - $this->locationInfo = new Payone_Log4php_LoggerLocationInfo($locationInfo, $this->fqcn); |
|
| 201 | - } |
|
| 202 | - return $this->locationInfo; |
|
| 203 | - } |
|
| 200 | + $this->locationInfo = new Payone_Log4php_LoggerLocationInfo($locationInfo, $this->fqcn); |
|
| 201 | + } |
|
| 202 | + return $this->locationInfo; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Return the level of this event. Use this form instead of directly |
|
| 207 | - * accessing the {@link $level} field. |
|
| 208 | - * @return Payone_Log4php_LoggerLevel |
|
| 209 | - */ |
|
| 210 | - public function getLevel() { |
|
| 211 | - return $this->level; |
|
| 212 | - } |
|
| 205 | + /** |
|
| 206 | + * Return the level of this event. Use this form instead of directly |
|
| 207 | + * accessing the {@link $level} field. |
|
| 208 | + * @return Payone_Log4php_LoggerLevel |
|
| 209 | + */ |
|
| 210 | + public function getLevel() { |
|
| 211 | + return $this->level; |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Returns the logger which created the event. |
|
| 216 | - * @return Logger |
|
| 217 | - */ |
|
| 218 | - public function getLogger() { |
|
| 219 | - return $this->logger; |
|
| 220 | - } |
|
| 214 | + /** |
|
| 215 | + * Returns the logger which created the event. |
|
| 216 | + * @return Logger |
|
| 217 | + */ |
|
| 218 | + public function getLogger() { |
|
| 219 | + return $this->logger; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Return the name of the logger. Use this form instead of directly |
|
| 224 | - * accessing the {@link $categoryName} field. |
|
| 225 | - * @return string |
|
| 226 | - */ |
|
| 227 | - public function getLoggerName() { |
|
| 228 | - return $this->categoryName; |
|
| 229 | - } |
|
| 222 | + /** |
|
| 223 | + * Return the name of the logger. Use this form instead of directly |
|
| 224 | + * accessing the {@link $categoryName} field. |
|
| 225 | + * @return string |
|
| 226 | + */ |
|
| 227 | + public function getLoggerName() { |
|
| 228 | + return $this->categoryName; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - /** |
|
| 232 | - * Return the message for this logging event. |
|
| 233 | - * |
|
| 234 | - * <p>Before serialization, the returned object is the message |
|
| 235 | - * passed by the user to generate the logging event. After |
|
| 236 | - * serialization, the returned value equals the String form of the |
|
| 237 | - * message possibly after object rendering. |
|
| 238 | - * @return mixed |
|
| 239 | - */ |
|
| 240 | - public function getMessage() { |
|
| 241 | - if($this->message !== null) { |
|
| 242 | - return $this->message; |
|
| 243 | - } else { |
|
| 244 | - return $this->getRenderedMessage(); |
|
| 245 | - } |
|
| 246 | - } |
|
| 231 | + /** |
|
| 232 | + * Return the message for this logging event. |
|
| 233 | + * |
|
| 234 | + * <p>Before serialization, the returned object is the message |
|
| 235 | + * passed by the user to generate the logging event. After |
|
| 236 | + * serialization, the returned value equals the String form of the |
|
| 237 | + * message possibly after object rendering. |
|
| 238 | + * @return mixed |
|
| 239 | + */ |
|
| 240 | + public function getMessage() { |
|
| 241 | + if($this->message !== null) { |
|
| 242 | + return $this->message; |
|
| 243 | + } else { |
|
| 244 | + return $this->getRenderedMessage(); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - /** |
|
| 249 | - * This method returns the NDC for this event. It will return the |
|
| 250 | - * correct content even if the event was generated in a different |
|
| 251 | - * thread or even on a different machine. The {@link LoggerNDC::get()} method |
|
| 252 | - * should <b>never</b> be called directly. |
|
| 253 | - * @return string |
|
| 254 | - */ |
|
| 255 | - public function getNDC() { |
|
| 256 | - if($this->ndcLookupRequired) { |
|
| 257 | - $this->ndcLookupRequired = false; |
|
| 258 | - $this->ndc = Payone_Log4php_LoggerNDC::get(); |
|
| 259 | - } |
|
| 260 | - return $this->ndc; |
|
| 261 | - } |
|
| 248 | + /** |
|
| 249 | + * This method returns the NDC for this event. It will return the |
|
| 250 | + * correct content even if the event was generated in a different |
|
| 251 | + * thread or even on a different machine. The {@link LoggerNDC::get()} method |
|
| 252 | + * should <b>never</b> be called directly. |
|
| 253 | + * @return string |
|
| 254 | + */ |
|
| 255 | + public function getNDC() { |
|
| 256 | + if($this->ndcLookupRequired) { |
|
| 257 | + $this->ndcLookupRequired = false; |
|
| 258 | + $this->ndc = Payone_Log4php_LoggerNDC::get(); |
|
| 259 | + } |
|
| 260 | + return $this->ndc; |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - /** |
|
| 264 | - * Returns the the context corresponding to the <code>key</code> |
|
| 265 | - * parameter. |
|
| 266 | - * @return string |
|
| 267 | - */ |
|
| 268 | - public function getMDC($key) { |
|
| 269 | - return Payone_Log4php_LoggerMDC::get($key); |
|
| 270 | - } |
|
| 263 | + /** |
|
| 264 | + * Returns the the context corresponding to the <code>key</code> |
|
| 265 | + * parameter. |
|
| 266 | + * @return string |
|
| 267 | + */ |
|
| 268 | + public function getMDC($key) { |
|
| 269 | + return Payone_Log4php_LoggerMDC::get($key); |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * Returns the entire MDC context. |
|
| 274 | - * @return array |
|
| 275 | - */ |
|
| 276 | - public function getMDCMap () { |
|
| 277 | - return Payone_Log4php_LoggerMDC::getMap(); |
|
| 278 | - } |
|
| 272 | + /** |
|
| 273 | + * Returns the entire MDC context. |
|
| 274 | + * @return array |
|
| 275 | + */ |
|
| 276 | + public function getMDCMap () { |
|
| 277 | + return Payone_Log4php_LoggerMDC::getMap(); |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | - /** |
|
| 281 | - * Render message. |
|
| 282 | - * @return string |
|
| 283 | - */ |
|
| 284 | - public function getRenderedMessage() { |
|
| 285 | - if($this->renderedMessage === null and $this->message !== null) { |
|
| 286 | - if(is_string($this->message)) { |
|
| 287 | - $this->renderedMessage = $this->message; |
|
| 288 | - } else { |
|
| 289 | - $rendererMap = Payone_Log4php_Logger::getHierarchy()->getRendererMap(); |
|
| 290 | - $this->renderedMessage= $rendererMap->findAndRender($this->message); |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - return $this->renderedMessage; |
|
| 294 | - } |
|
| 280 | + /** |
|
| 281 | + * Render message. |
|
| 282 | + * @return string |
|
| 283 | + */ |
|
| 284 | + public function getRenderedMessage() { |
|
| 285 | + if($this->renderedMessage === null and $this->message !== null) { |
|
| 286 | + if(is_string($this->message)) { |
|
| 287 | + $this->renderedMessage = $this->message; |
|
| 288 | + } else { |
|
| 289 | + $rendererMap = Payone_Log4php_Logger::getHierarchy()->getRendererMap(); |
|
| 290 | + $this->renderedMessage= $rendererMap->findAndRender($this->message); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + return $this->renderedMessage; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - /** |
|
| 297 | - * Returns the time when the application started, as a UNIX timestamp |
|
| 298 | - * with microseconds. |
|
| 299 | - * @return float |
|
| 300 | - */ |
|
| 301 | - public static function getStartTime() { |
|
| 302 | - if(!isset(self::$startTime)) { |
|
| 303 | - self::$startTime = microtime(true); |
|
| 304 | - } |
|
| 305 | - return self::$startTime; |
|
| 306 | - } |
|
| 296 | + /** |
|
| 297 | + * Returns the time when the application started, as a UNIX timestamp |
|
| 298 | + * with microseconds. |
|
| 299 | + * @return float |
|
| 300 | + */ |
|
| 301 | + public static function getStartTime() { |
|
| 302 | + if(!isset(self::$startTime)) { |
|
| 303 | + self::$startTime = microtime(true); |
|
| 304 | + } |
|
| 305 | + return self::$startTime; |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * @return float |
|
| 310 | - */ |
|
| 311 | - public function getTimeStamp() { |
|
| 312 | - return $this->timeStamp; |
|
| 313 | - } |
|
| 308 | + /** |
|
| 309 | + * @return float |
|
| 310 | + */ |
|
| 311 | + public function getTimeStamp() { |
|
| 312 | + return $this->timeStamp; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - /** |
|
| 316 | - * Calculates the time of this event. |
|
| 317 | - * @return the time after event starttime when this event has occured |
|
| 318 | - */ |
|
| 319 | - public function getTime() { |
|
| 320 | - $eventTime = $this->getTimeStamp(); |
|
| 321 | - $eventStartTime = Payone_Log4php_LoggerLoggingEvent::getStartTime(); |
|
| 322 | - return number_format(($eventTime - $eventStartTime) * 1000, 0, '', ''); |
|
| 323 | - } |
|
| 315 | + /** |
|
| 316 | + * Calculates the time of this event. |
|
| 317 | + * @return the time after event starttime when this event has occured |
|
| 318 | + */ |
|
| 319 | + public function getTime() { |
|
| 320 | + $eventTime = $this->getTimeStamp(); |
|
| 321 | + $eventStartTime = Payone_Log4php_LoggerLoggingEvent::getStartTime(); |
|
| 322 | + return number_format(($eventTime - $eventStartTime) * 1000, 0, '', ''); |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * @return mixed |
|
| 327 | - */ |
|
| 328 | - public function getThreadName() { |
|
| 329 | - if ($this->threadName === null) { |
|
| 330 | - $this->threadName = (string)getmypid(); |
|
| 331 | - } |
|
| 332 | - return $this->threadName; |
|
| 333 | - } |
|
| 325 | + /** |
|
| 326 | + * @return mixed |
|
| 327 | + */ |
|
| 328 | + public function getThreadName() { |
|
| 329 | + if ($this->threadName === null) { |
|
| 330 | + $this->threadName = (string)getmypid(); |
|
| 331 | + } |
|
| 332 | + return $this->threadName; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * @return mixed LoggerThrowableInformation |
|
| 337 | - */ |
|
| 338 | - public function getThrowableInformation() { |
|
| 339 | - return $this->throwableInfo; |
|
| 340 | - } |
|
| 335 | + /** |
|
| 336 | + * @return mixed LoggerThrowableInformation |
|
| 337 | + */ |
|
| 338 | + public function getThrowableInformation() { |
|
| 339 | + return $this->throwableInfo; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - /** |
|
| 343 | - * Serialize this object |
|
| 344 | - * @return string |
|
| 345 | - */ |
|
| 346 | - public function toString() { |
|
| 347 | - serialize($this); |
|
| 348 | - } |
|
| 342 | + /** |
|
| 343 | + * Serialize this object |
|
| 344 | + * @return string |
|
| 345 | + */ |
|
| 346 | + public function toString() { |
|
| 347 | + serialize($this); |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | - /** |
|
| 351 | - * Avoid serialization of the {@link $logger} object |
|
| 352 | - */ |
|
| 353 | - public function __sleep() { |
|
| 354 | - return array( |
|
| 355 | - 'fqcn', |
|
| 356 | - 'categoryName', |
|
| 357 | - 'level', |
|
| 358 | - 'ndc', |
|
| 359 | - 'ndcLookupRequired', |
|
| 360 | - 'message', |
|
| 361 | - 'renderedMessage', |
|
| 362 | - 'threadName', |
|
| 363 | - 'timeStamp', |
|
| 364 | - 'locationInfo', |
|
| 365 | - ); |
|
| 366 | - } |
|
| 350 | + /** |
|
| 351 | + * Avoid serialization of the {@link $logger} object |
|
| 352 | + */ |
|
| 353 | + public function __sleep() { |
|
| 354 | + return array( |
|
| 355 | + 'fqcn', |
|
| 356 | + 'categoryName', |
|
| 357 | + 'level', |
|
| 358 | + 'ndc', |
|
| 359 | + 'ndcLookupRequired', |
|
| 360 | + 'message', |
|
| 361 | + 'renderedMessage', |
|
| 362 | + 'threadName', |
|
| 363 | + 'timeStamp', |
|
| 364 | + 'locationInfo', |
|
| 365 | + ); |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | 368 | } |
| 369 | 369 | |
@@ -28,15 +28,15 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | interface Payone_Log4php_LoggerConfigurator |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * Configures log4php based on the given configuration. |
|
| 33 | - * |
|
| 34 | - * All configurators implementations must implement this interface. |
|
| 35 | - * |
|
| 36 | - * @param Payone_Log4php_LoggerHierarchy $hierarchy The hierarchy on which to perform |
|
| 37 | - * the configuration. |
|
| 38 | - * @param mixed $input Either path to the config file or the |
|
| 39 | - * configuration as an array. |
|
| 40 | - */ |
|
| 41 | - public function configure(Payone_Log4php_LoggerHierarchy $hierarchy, $input = null); |
|
| 31 | + /** |
|
| 32 | + * Configures log4php based on the given configuration. |
|
| 33 | + * |
|
| 34 | + * All configurators implementations must implement this interface. |
|
| 35 | + * |
|
| 36 | + * @param Payone_Log4php_LoggerHierarchy $hierarchy The hierarchy on which to perform |
|
| 37 | + * the configuration. |
|
| 38 | + * @param mixed $input Either path to the config file or the |
|
| 39 | + * configuration as an array. |
|
| 40 | + */ |
|
| 41 | + public function configure(Payone_Log4php_LoggerHierarchy $hierarchy, $input = null); |
|
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -34,11 +34,11 @@ |
||
| 34 | 34 | { |
| 35 | 35 | protected $request = Payone_Api_Enum_RequestType::VAUTHORIZATION; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Sub account ID |
|
| 39 | - * |
|
| 40 | - * @var int |
|
| 41 | - */ |
|
| 37 | + /** |
|
| 38 | + * Sub account ID |
|
| 39 | + * |
|
| 40 | + * @var int |
|
| 41 | + */ |
|
| 42 | 42 | protected $aid = NULL; |
| 43 | 43 | /** |
| 44 | 44 | * @var string |