@@ -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 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $appenders = array(); |
| 100 | 100 | |
| 101 | - foreach($properties as $key => $value) { |
|
| 101 | + foreach ($properties as $key => $value) { |
|
| 102 | 102 | // Parse loggers |
| 103 | 103 | if ($this->beginsWith($key, self::LOGGER_PREFIX)) { |
| 104 | 104 | $name = substr($key, strlen(self::LOGGER_PREFIX)); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | // The remaining values are appender references |
| 151 | 151 | $appenders = array(); |
| 152 | - while($appender = array_shift($parts)) { |
|
| 152 | + while ($appender = array_shift($parts)) { |
|
| 153 | 153 | $appender = trim($appender); |
| 154 | 154 | if (!empty($appender)) { |
| 155 | 155 | $appenders[] = trim($appender); |
@@ -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 |
@@ -91,26 +91,26 @@ discard block |
||
| 91 | 91 | public function __construct(array $data = array()) |
| 92 | 92 | { |
| 93 | 93 | if (empty($data)) { |
| 94 | - if($this->getApiConfig() === null) |
|
| 94 | + if ($this->getApiConfig() === null) |
|
| 95 | 95 | { |
| 96 | 96 | $this->apiConfig = new Payone_Api_Config(); |
| 97 | 97 | } |
| 98 | - if($this->getTransactionStatusConfig() === null) |
|
| 98 | + if ($this->getTransactionStatusConfig() === null) |
|
| 99 | 99 | { |
| 100 | 100 | $this->transactionStatusConfig = new Payone_TransactionStatus_Config(); |
| 101 | 101 | } |
| 102 | - if($this->getSessionStatusConfig() === null) |
|
| 102 | + if ($this->getSessionStatusConfig() === null) |
|
| 103 | 103 | { |
| 104 | 104 | $this->sessionStatusConfig = new Payone_SessionStatus_Config(); |
| 105 | 105 | } |
| 106 | 106 | $this->config = $this->getDefaultConfigData(); |
| 107 | 107 | } |
| 108 | 108 | else { |
| 109 | - if(array_key_exists('api', $data)) |
|
| 109 | + if (array_key_exists('api', $data)) |
|
| 110 | 110 | $this->setApiConfig($data['api']); |
| 111 | - if(array_key_exists('transaction_status',$data)) |
|
| 111 | + if (array_key_exists('transaction_status', $data)) |
|
| 112 | 112 | $this->setTransactionStatusConfig($data['transaction_status']); |
| 113 | - if(array_key_exists('session_status',$data)) |
|
| 113 | + if (array_key_exists('session_status', $data)) |
|
| 114 | 114 | $this->setSessionStatusConfig($data['session_status']); |
| 115 | 115 | $this->config = $data; |
| 116 | 116 | } |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | // Disassemble key, extracting the first node of the string: |
| 165 | 165 | $explodedKey = explode(self::KEY_SEPARATOR, $key); |
| 166 | 166 | $currentKey = array_shift($explodedKey); |
| 167 | - $newKey = implode(self::KEY_SEPARATOR,$explodedKey); |
|
| 167 | + $newKey = implode(self::KEY_SEPARATOR, $explodedKey); |
|
| 168 | 168 | |
| 169 | 169 | /** @var $object Payone_Config_Abstract */ |
| 170 | 170 | $object = $tree[$currentKey]; |
| 171 | - $object->setValue($newKey,$value); |
|
| 171 | + $object->setValue($newKey, $value); |
|
| 172 | 172 | return TRUE; |
| 173 | 173 | } |
| 174 | 174 | else { |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | // Disassemble key, extracting the first node of the string: |
| 201 | 201 | $explodedKey = explode(self::KEY_SEPARATOR, $key); |
| 202 | 202 | $currentKey = array_shift($explodedKey); |
| 203 | - $newKey = implode(self::KEY_SEPARATOR,$explodedKey); |
|
| 203 | + $newKey = implode(self::KEY_SEPARATOR, $explodedKey); |
|
| 204 | 204 | |
| 205 | 205 | /** @var $object Payone_Config_Abstract */ |
| 206 | 206 | $object = $tree[$currentKey]; |
@@ -104,14 +104,16 @@ discard block |
||
| 104 | 104 | $this->sessionStatusConfig = new Payone_SessionStatus_Config(); |
| 105 | 105 | } |
| 106 | 106 | $this->config = $this->getDefaultConfigData(); |
| 107 | - } |
|
| 108 | - else { |
|
| 109 | - if(array_key_exists('api', $data)) |
|
| 110 | - $this->setApiConfig($data['api']); |
|
| 111 | - if(array_key_exists('transaction_status',$data)) |
|
| 112 | - $this->setTransactionStatusConfig($data['transaction_status']); |
|
| 113 | - if(array_key_exists('session_status',$data)) |
|
| 114 | - $this->setSessionStatusConfig($data['session_status']); |
|
| 107 | + } else { |
|
| 108 | + if(array_key_exists('api', $data)) { |
|
| 109 | + $this->setApiConfig($data['api']); |
|
| 110 | + } |
|
| 111 | + if(array_key_exists('transaction_status',$data)) { |
|
| 112 | + $this->setTransactionStatusConfig($data['transaction_status']); |
|
| 113 | + } |
|
| 114 | + if(array_key_exists('session_status',$data)) { |
|
| 115 | + $this->setSessionStatusConfig($data['session_status']); |
|
| 116 | + } |
|
| 115 | 117 | $this->config = $data; |
| 116 | 118 | } |
| 117 | 119 | } |
@@ -170,8 +172,7 @@ discard block |
||
| 170 | 172 | $object = $tree[$currentKey]; |
| 171 | 173 | $object->setValue($newKey,$value); |
| 172 | 174 | return TRUE; |
| 173 | - } |
|
| 174 | - else { |
|
| 175 | + } else { |
|
| 175 | 176 | // Set value (can overwrite an existing value) |
| 176 | 177 | $tree[$key] = $value; |
| 177 | 178 | // Exit recursion, Success! |
@@ -205,11 +206,9 @@ discard block |
||
| 205 | 206 | /** @var $object Payone_Config_Abstract */ |
| 206 | 207 | $object = $tree[$currentKey]; |
| 207 | 208 | return $object->getValue($newKey); |
| 208 | - } |
|
| 209 | - elseif (is_array($tree) and array_key_exists($key, $tree)) { |
|
| 209 | + } elseif (is_array($tree) and array_key_exists($key, $tree)) { |
|
| 210 | 210 | return $tree[$key]; // Exit recursion, Success! |
| 211 | - } |
|
| 212 | - else { |
|
| 211 | + } else { |
|
| 213 | 212 | return NULL; // Exit recursion, unsuccessful |
| 214 | 213 | } |
| 215 | 214 | } |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | { |
| 105 | 105 | $remoteAddr = $_SERVER['REMOTE_ADDR']; |
| 106 | 106 | if ($this->getProxyCheckEnabled() == 1) { |
| 107 | - if(array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { |
|
| 107 | + if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { |
|
| 108 | 108 | $proxy = $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 109 | 109 | if (!empty($proxy)) { |
| 110 | 110 | $proxyIps = explode(',', $proxy); |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | /** |
| 627 | 627 | * @param string $clearing_bankaccount |
| 628 | 628 | */ |
| 629 | - public function setClearingBankaccount( $clearing_bankaccount) |
|
| 629 | + public function setClearingBankaccount($clearing_bankaccount) |
|
| 630 | 630 | { |
| 631 | 631 | $this->clearing_bankaccount = $clearing_bankaccount; |
| 632 | 632 | } |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | /** |
| 643 | 643 | * @param string $clearing_bankaccountholder |
| 644 | 644 | */ |
| 645 | - public function setClearingBankaccountholder( $clearing_bankaccountholder) |
|
| 645 | + public function setClearingBankaccountholder($clearing_bankaccountholder) |
|
| 646 | 646 | { |
| 647 | 647 | $this->clearing_bankaccountholder = $clearing_bankaccountholder; |
| 648 | 648 | } |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | /** |
| 659 | 659 | * @param string $clearing_bankbic |
| 660 | 660 | */ |
| 661 | - public function setClearingBankbic( $clearing_bankbic) |
|
| 661 | + public function setClearingBankbic($clearing_bankbic) |
|
| 662 | 662 | { |
| 663 | 663 | $this->clearing_bankbic = $clearing_bankbic; |
| 664 | 664 | } |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | /** |
| 675 | 675 | * @param string $clearing_bankcity |
| 676 | 676 | */ |
| 677 | - public function setClearingBankcity( $clearing_bankcity) |
|
| 677 | + public function setClearingBankcity($clearing_bankcity) |
|
| 678 | 678 | { |
| 679 | 679 | $this->clearing_bankcity = $clearing_bankcity; |
| 680 | 680 | } |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | /** |
| 691 | 691 | * @param string $clearing_bankcode |
| 692 | 692 | */ |
| 693 | - public function setClearingBankcode( $clearing_bankcode) |
|
| 693 | + public function setClearingBankcode($clearing_bankcode) |
|
| 694 | 694 | { |
| 695 | 695 | $this->clearing_bankcode = $clearing_bankcode; |
| 696 | 696 | } |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | /** |
| 707 | 707 | * @param string $clearing_bankcountry |
| 708 | 708 | */ |
| 709 | - public function setClearingBankcountry( $clearing_bankcountry) |
|
| 709 | + public function setClearingBankcountry($clearing_bankcountry) |
|
| 710 | 710 | { |
| 711 | 711 | $this->clearing_bankcountry = $clearing_bankcountry; |
| 712 | 712 | } |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | /** |
| 723 | 723 | * @param string $clearing_bankiban |
| 724 | 724 | */ |
| 725 | - public function setClearingBankiban( $clearing_bankiban) |
|
| 725 | + public function setClearingBankiban($clearing_bankiban) |
|
| 726 | 726 | { |
| 727 | 727 | $this->clearing_bankiban = $clearing_bankiban; |
| 728 | 728 | } |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | /** |
| 739 | 739 | * @param string $clearing_bankname |
| 740 | 740 | */ |
| 741 | - public function setClearingBankname( $clearing_bankname) |
|
| 741 | + public function setClearingBankname($clearing_bankname) |
|
| 742 | 742 | { |
| 743 | 743 | $this->clearing_bankname = $clearing_bankname; |
| 744 | 744 | } |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | /** |
| 755 | 755 | * @param string $clearing_duedate |
| 756 | 756 | */ |
| 757 | - public function setClearingDuedate( $clearing_duedate) |
|
| 757 | + public function setClearingDuedate($clearing_duedate) |
|
| 758 | 758 | { |
| 759 | 759 | $this->clearing_duedate = $clearing_duedate; |
| 760 | 760 | } |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | /** |
| 771 | 771 | * @param string $clearing_instructionnote |
| 772 | 772 | */ |
| 773 | - public function setClearingInstructionnote( $clearing_instructionnote) |
|
| 773 | + public function setClearingInstructionnote($clearing_instructionnote) |
|
| 774 | 774 | { |
| 775 | 775 | $this->clearing_instructionnote = $clearing_instructionnote; |
| 776 | 776 | } |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | /** |
| 787 | 787 | * @param string $clearing_legalnote |
| 788 | 788 | */ |
| 789 | - public function setClearingLegalnote( $clearing_legalnote) |
|
| 789 | + public function setClearingLegalnote($clearing_legalnote) |
|
| 790 | 790 | { |
| 791 | 791 | $this->clearing_legalnote = $clearing_legalnote; |
| 792 | 792 | } |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | /** |
| 803 | 803 | * @param string $clearing_reference |
| 804 | 804 | */ |
| 805 | - public function setClearingReference( $clearing_reference) |
|
| 805 | + public function setClearingReference($clearing_reference) |
|
| 806 | 806 | { |
| 807 | 807 | $this->clearing_reference = $clearing_reference; |
| 808 | 808 | } |
@@ -42,6 +42,6 @@ |
||
| 42 | 42 | const REMINDER = 'reminder'; |
| 43 | 43 | const VAUTHORIZATION = 'vauthorization'; |
| 44 | 44 | const VSETTLEMENT = 'vsettlement'; |
| 45 | - const TRANSFER= 'transfer'; |
|
| 46 | - const INVOICE= 'invoice'; |
|
| 45 | + const TRANSFER = 'transfer'; |
|
| 46 | + const INVOICE = 'invoice'; |
|
| 47 | 47 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | // |
| 98 | 98 | $response = new Payone_TransactionStatus_Response('TSOK'); |
| 99 | 99 | |
| 100 | - if($request->getClearingtype() == 'cc') { |
|
| 100 | + if ($request->getClearingtype() == 'cc') { |
|
| 101 | 101 | $this->_handleTransactionId($request); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $oFactory = new Payone_Core_Model_Factory(); |
| 117 | 117 | $oTransaction = $oFactory->getModelTransaction(); |
| 118 | 118 | $oTransaction->load($oRequest->getReference(), 'reference'); |
| 119 | - if($oTransaction->getFrontendApiCall() == 1 && !$oTransaction->getTxid()) { |
|
| 119 | + if ($oTransaction->getFrontendApiCall() == 1 && !$oTransaction->getTxid()) { |
|
| 120 | 120 | $oTransaction->setTxid($oRequest->getTxid()); |
| 121 | 121 | $oTransaction->save(); |
| 122 | 122 | } |
@@ -75,8 +75,7 @@ |
||
| 75 | 75 | $response = $this->getMapperResponse()->map($responseRaw); |
| 76 | 76 | |
| 77 | 77 | $this->protocol($request, $response); |
| 78 | - } |
|
| 79 | - catch (Exception $e) { |
|
| 78 | + } catch (Exception $e) { |
|
| 80 | 79 | $this->protocolException($e, $request); |
| 81 | 80 | throw $e; |
| 82 | 81 | } |