@@ -26,51 +26,51 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class Payone_Log4php_LoggerThrowableInformation { |
| 28 | 28 | |
| 29 | - /** @var Exception Throwable to log */ |
|
| 30 | - private $throwable; |
|
| 29 | + /** @var Exception Throwable to log */ |
|
| 30 | + private $throwable; |
|
| 31 | 31 | |
| 32 | - /** @var array Array of throwable messages */ |
|
| 33 | - private $throwableArray; |
|
| 32 | + /** @var array Array of throwable messages */ |
|
| 33 | + private $throwableArray; |
|
| 34 | 34 | |
| 35 | - /** @var Logger reference */ |
|
| 36 | - private $logger; |
|
| 35 | + /** @var Logger reference */ |
|
| 36 | + private $logger; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Create a new instance |
|
| 40 | - * |
|
| 41 | - * @param $throwable - a throwable as a exception |
|
| 42 | - * @param $logger - Logger reference |
|
| 43 | - */ |
|
| 44 | - public function __construct(Exception $throwable) { |
|
| 45 | - $this->throwable = $throwable; |
|
| 46 | - } |
|
| 38 | + /** |
|
| 39 | + * Create a new instance |
|
| 40 | + * |
|
| 41 | + * @param $throwable - a throwable as a exception |
|
| 42 | + * @param $logger - Logger reference |
|
| 43 | + */ |
|
| 44 | + public function __construct(Exception $throwable) { |
|
| 45 | + $this->throwable = $throwable; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Return source exception |
|
| 50 | - * |
|
| 51 | - * @return Exception |
|
| 52 | - */ |
|
| 53 | - public function getThrowable() { |
|
| 54 | - return $this->throwable; |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * Return source exception |
|
| 50 | + * |
|
| 51 | + * @return Exception |
|
| 52 | + */ |
|
| 53 | + public function getThrowable() { |
|
| 54 | + return $this->throwable; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @desc Returns string representation of throwable |
|
| 59 | - * |
|
| 60 | - * @return array |
|
| 61 | - */ |
|
| 62 | - public function getStringRepresentation() { |
|
| 63 | - if (!is_array($this->throwableArray)) { |
|
| 64 | - $renderer = Payone_Log4php_Logger::getHierarchy()->getRendererMap()->getByClassName(get_class($this->throwable)); |
|
| 57 | + /** |
|
| 58 | + * @desc Returns string representation of throwable |
|
| 59 | + * |
|
| 60 | + * @return array |
|
| 61 | + */ |
|
| 62 | + public function getStringRepresentation() { |
|
| 63 | + if (!is_array($this->throwableArray)) { |
|
| 64 | + $renderer = Payone_Log4php_Logger::getHierarchy()->getRendererMap()->getByClassName(get_class($this->throwable)); |
|
| 65 | 65 | |
| 66 | - // TODO: why this? |
|
| 67 | - if ($renderer instanceof Payone_Log4php_LoggerRendererDefault) { |
|
| 68 | - $renderer = new Payone_Log4php_LoggerRendererException(); |
|
| 69 | - } |
|
| 70 | - $this->throwableArray = explode("\n", $renderer->render($this->throwable)); |
|
| 71 | - } |
|
| 66 | + // TODO: why this? |
|
| 67 | + if ($renderer instanceof Payone_Log4php_LoggerRendererDefault) { |
|
| 68 | + $renderer = new Payone_Log4php_LoggerRendererException(); |
|
| 69 | + } |
|
| 70 | + $this->throwableArray = explode("\n", $renderer->render($this->throwable)); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return $this->throwableArray; |
|
| 74 | - } |
|
| 73 | + return $this->throwableArray; |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | ?> |
| 77 | 77 | \ No newline at end of file |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class Payone_Log4php_LoggerPatternConverterMessage extends Payone_Log4php_LoggerPatternConverter { |
| 28 | 28 | |
| 29 | - public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 30 | - return $event->getRenderedMessage(); |
|
| 31 | - } |
|
| 29 | + public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 30 | + return $event->getRenderedMessage(); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -33,206 +33,206 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class Payone_Log4php_LoggerPatternParser { |
| 35 | 35 | |
| 36 | - /** Escape character for conversion words in the conversion pattern. */ |
|
| 37 | - const ESCAPE_CHAR = '%'; |
|
| 36 | + /** Escape character for conversion words in the conversion pattern. */ |
|
| 37 | + const ESCAPE_CHAR = '%'; |
|
| 38 | 38 | |
| 39 | - /** Maps conversion words to relevant converters. */ |
|
| 40 | - private $converterMap; |
|
| 39 | + /** Maps conversion words to relevant converters. */ |
|
| 40 | + private $converterMap; |
|
| 41 | 41 | |
| 42 | - /** Conversion pattern used in layout. */ |
|
| 43 | - private $pattern; |
|
| 42 | + /** Conversion pattern used in layout. */ |
|
| 43 | + private $pattern; |
|
| 44 | 44 | |
| 45 | - /** Regex pattern used for parsing the conversion pattern. */ |
|
| 46 | - private $regex; |
|
| 45 | + /** Regex pattern used for parsing the conversion pattern. */ |
|
| 46 | + private $regex; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * First converter in the chain. |
|
| 50 | - * @var Payone_Log4php_LoggerPatternConverter |
|
| 51 | - */ |
|
| 52 | - private $head; |
|
| 48 | + /** |
|
| 49 | + * First converter in the chain. |
|
| 50 | + * @var Payone_Log4php_LoggerPatternConverter |
|
| 51 | + */ |
|
| 52 | + private $head; |
|
| 53 | 53 | |
| 54 | - /** Last converter in the chain. */ |
|
| 55 | - private $tail; |
|
| 54 | + /** Last converter in the chain. */ |
|
| 55 | + private $tail; |
|
| 56 | 56 | |
| 57 | - public function __construct($pattern, $converterMap) { |
|
| 58 | - $this->pattern = $pattern; |
|
| 59 | - $this->converterMap = $converterMap; |
|
| 57 | + public function __construct($pattern, $converterMap) { |
|
| 58 | + $this->pattern = $pattern; |
|
| 59 | + $this->converterMap = $converterMap; |
|
| 60 | 60 | |
| 61 | - // Construct the regex pattern |
|
| 62 | - $this->regex = |
|
| 63 | - '/' . // Starting regex pattern delimiter |
|
| 64 | - self::ESCAPE_CHAR . // Character which marks the start of the conversion pattern |
|
| 65 | - '(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional) |
|
| 66 | - '(?P<word>[a-zA-Z]+)' . // The conversion word |
|
| 67 | - '(?P<option>{[^}]*})?' . // Conversion option in braces (optional) |
|
| 68 | - '/'; // Ending regex pattern delimiter |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Parses the conversion pattern string, converts it to a chain of pattern |
|
| 73 | - * converters and returns the first converter in the chain. |
|
| 74 | - * |
|
| 75 | - * @return Payone_Log4php_LoggerPatternConverter |
|
| 76 | - */ |
|
| 77 | - public function parse() { |
|
| 61 | + // Construct the regex pattern |
|
| 62 | + $this->regex = |
|
| 63 | + '/' . // Starting regex pattern delimiter |
|
| 64 | + self::ESCAPE_CHAR . // Character which marks the start of the conversion pattern |
|
| 65 | + '(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional) |
|
| 66 | + '(?P<word>[a-zA-Z]+)' . // The conversion word |
|
| 67 | + '(?P<option>{[^}]*})?' . // Conversion option in braces (optional) |
|
| 68 | + '/'; // Ending regex pattern delimiter |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Parses the conversion pattern string, converts it to a chain of pattern |
|
| 73 | + * converters and returns the first converter in the chain. |
|
| 74 | + * |
|
| 75 | + * @return Payone_Log4php_LoggerPatternConverter |
|
| 76 | + */ |
|
| 77 | + public function parse() { |
|
| 78 | 78 | |
| 79 | - // Skip parsing if the pattern is empty |
|
| 80 | - if (empty($this->pattern)) { |
|
| 81 | - $this->addLiteral(''); |
|
| 82 | - return $this->head; |
|
| 83 | - } |
|
| 79 | + // Skip parsing if the pattern is empty |
|
| 80 | + if (empty($this->pattern)) { |
|
| 81 | + $this->addLiteral(''); |
|
| 82 | + return $this->head; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - // Find all conversion words in the conversion pattern |
|
| 86 | - $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE); |
|
| 87 | - if ($count === false) { |
|
| 88 | - $error = error_get_last(); |
|
| 89 | - throw new Payone_Log4php_LoggerException("Failed parsing layotut pattern: {$error['message']}"); |
|
| 90 | - } |
|
| 85 | + // Find all conversion words in the conversion pattern |
|
| 86 | + $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE); |
|
| 87 | + if ($count === false) { |
|
| 88 | + $error = error_get_last(); |
|
| 89 | + throw new Payone_Log4php_LoggerException("Failed parsing layotut pattern: {$error['message']}"); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $prevEnd = 0; |
|
| 92 | + $prevEnd = 0; |
|
| 93 | 93 | |
| 94 | - foreach($matches[0] as $key => $item) { |
|
| 94 | + foreach($matches[0] as $key => $item) { |
|
| 95 | 95 | |
| 96 | - // Locate where the conversion command starts and ends |
|
| 97 | - $length = strlen($item[0]); |
|
| 98 | - $start = $item[1]; |
|
| 99 | - $end = $item[1] + $length; |
|
| 96 | + // Locate where the conversion command starts and ends |
|
| 97 | + $length = strlen($item[0]); |
|
| 98 | + $start = $item[1]; |
|
| 99 | + $end = $item[1] + $length; |
|
| 100 | 100 | |
| 101 | - // Find any literal expressions between matched commands |
|
| 102 | - if ($start > $prevEnd) { |
|
| 103 | - $literal = substr($this->pattern, $prevEnd, $start - $prevEnd); |
|
| 104 | - $this->addLiteral($literal); |
|
| 105 | - } |
|
| 101 | + // Find any literal expressions between matched commands |
|
| 102 | + if ($start > $prevEnd) { |
|
| 103 | + $literal = substr($this->pattern, $prevEnd, $start - $prevEnd); |
|
| 104 | + $this->addLiteral($literal); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // Extract the data from the matched command |
|
| 108 | - $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null; |
|
| 109 | - $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null; |
|
| 110 | - $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null; |
|
| 107 | + // Extract the data from the matched command |
|
| 108 | + $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null; |
|
| 109 | + $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null; |
|
| 110 | + $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null; |
|
| 111 | 111 | |
| 112 | - // Create a converter and add it to the chain |
|
| 113 | - $this->addConverter($word, $modifiers, $option); |
|
| 112 | + // Create a converter and add it to the chain |
|
| 113 | + $this->addConverter($word, $modifiers, $option); |
|
| 114 | 114 | |
| 115 | - $prevEnd = $end; |
|
| 116 | - } |
|
| 115 | + $prevEnd = $end; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - // Add any trailing literals |
|
| 119 | - if ($end < strlen($this->pattern)) { |
|
| 120 | - $literal = substr($this->pattern, $end); |
|
| 121 | - $this->addLiteral($literal); |
|
| 122 | - } |
|
| 118 | + // Add any trailing literals |
|
| 119 | + if ($end < strlen($this->pattern)) { |
|
| 120 | + $literal = substr($this->pattern, $end); |
|
| 121 | + $this->addLiteral($literal); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - return $this->head; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Adds a literal converter to the converter chain. |
|
| 129 | - * @param string $string The string for the literal converter. |
|
| 130 | - */ |
|
| 131 | - private function addLiteral($string) { |
|
| 132 | - $converter = new Payone_Log4php_LoggerPatternConverterLiteral($string); |
|
| 133 | - $this->addToChain($converter); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Adds a non-literal converter to the converter chain. |
|
| 138 | - * |
|
| 139 | - * @param string $word The conversion word, used to determine which |
|
| 140 | - * converter will be used. |
|
| 141 | - * @param string $modifiers Formatting modifiers. |
|
| 142 | - * @param string $option Option to pass to the converter. |
|
| 143 | - */ |
|
| 144 | - private function addConverter($word, $modifiers, $option) { |
|
| 145 | - $formattingInfo = $this->parseModifiers($modifiers); |
|
| 146 | - $option = trim($option, "{} "); |
|
| 124 | + return $this->head; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Adds a literal converter to the converter chain. |
|
| 129 | + * @param string $string The string for the literal converter. |
|
| 130 | + */ |
|
| 131 | + private function addLiteral($string) { |
|
| 132 | + $converter = new Payone_Log4php_LoggerPatternConverterLiteral($string); |
|
| 133 | + $this->addToChain($converter); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Adds a non-literal converter to the converter chain. |
|
| 138 | + * |
|
| 139 | + * @param string $word The conversion word, used to determine which |
|
| 140 | + * converter will be used. |
|
| 141 | + * @param string $modifiers Formatting modifiers. |
|
| 142 | + * @param string $option Option to pass to the converter. |
|
| 143 | + */ |
|
| 144 | + private function addConverter($word, $modifiers, $option) { |
|
| 145 | + $formattingInfo = $this->parseModifiers($modifiers); |
|
| 146 | + $option = trim($option, "{} "); |
|
| 147 | 147 | |
| 148 | - if (isset($this->converterMap[$word])) { |
|
| 149 | - $converter = $this->getConverter($word, $formattingInfo, $option); |
|
| 150 | - $this->addToChain($converter); |
|
| 151 | - } else { |
|
| 152 | - trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING); |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Determines which converter to use based on the conversion word. Creates |
|
| 158 | - * an instance of the converter using the provided formatting info and |
|
| 159 | - * option and returns it. |
|
| 160 | - * |
|
| 161 | - * @param string $word The conversion word. |
|
| 162 | - * @param Payone_Log4php_LoggerFormattingInfo $info Formatting info. |
|
| 163 | - * @param string $option Converter option. |
|
| 164 | - * |
|
| 165 | - * @throws LoggerException |
|
| 166 | - * |
|
| 167 | - * @return Payone_Log4php_LoggerPatternConverter |
|
| 168 | - */ |
|
| 169 | - private function getConverter($word, $info, $option) { |
|
| 170 | - if (!isset($this->converterMap[$word])) { |
|
| 171 | - throw new Payone_Log4php_LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword."); |
|
| 172 | - } |
|
| 148 | + if (isset($this->converterMap[$word])) { |
|
| 149 | + $converter = $this->getConverter($word, $formattingInfo, $option); |
|
| 150 | + $this->addToChain($converter); |
|
| 151 | + } else { |
|
| 152 | + trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Determines which converter to use based on the conversion word. Creates |
|
| 158 | + * an instance of the converter using the provided formatting info and |
|
| 159 | + * option and returns it. |
|
| 160 | + * |
|
| 161 | + * @param string $word The conversion word. |
|
| 162 | + * @param Payone_Log4php_LoggerFormattingInfo $info Formatting info. |
|
| 163 | + * @param string $option Converter option. |
|
| 164 | + * |
|
| 165 | + * @throws LoggerException |
|
| 166 | + * |
|
| 167 | + * @return Payone_Log4php_LoggerPatternConverter |
|
| 168 | + */ |
|
| 169 | + private function getConverter($word, $info, $option) { |
|
| 170 | + if (!isset($this->converterMap[$word])) { |
|
| 171 | + throw new Payone_Log4php_LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword."); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - $converterClass = $this->converterMap[$word]; |
|
| 175 | - if(!class_exists($converterClass)) { |
|
| 176 | - throw new Payone_Log4php_LoggerException("Class '$converterClass' does not exist."); |
|
| 177 | - } |
|
| 174 | + $converterClass = $this->converterMap[$word]; |
|
| 175 | + if(!class_exists($converterClass)) { |
|
| 176 | + throw new Payone_Log4php_LoggerException("Class '$converterClass' does not exist."); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - $converter = new $converterClass($info, $option); |
|
| 180 | - if(!($converter instanceof Payone_Log4php_LoggerPatternConverter)) { |
|
| 181 | - throw new Payone_Log4php_LoggerException("Class '$converterClass' is not an instance of Payone_Log4php_LoggerPatternConverter."); |
|
| 182 | - } |
|
| 179 | + $converter = new $converterClass($info, $option); |
|
| 180 | + if(!($converter instanceof Payone_Log4php_LoggerPatternConverter)) { |
|
| 181 | + throw new Payone_Log4php_LoggerException("Class '$converterClass' is not an instance of Payone_Log4php_LoggerPatternConverter."); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - return $converter; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** Adds a converter to the chain and updates $head and $tail pointers. */ |
|
| 188 | - private function addToChain(LoggerPatternConverter $converter) { |
|
| 189 | - if (!isset($this->head)) { |
|
| 190 | - $this->head = $converter; |
|
| 191 | - $this->tail = $this->head; |
|
| 192 | - } else { |
|
| 193 | - $this->tail->next = $converter; |
|
| 194 | - $this->tail = $this->tail->next; |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Parses the formatting modifiers and produces the corresponding |
|
| 200 | - * LoggerFormattingInfo object. |
|
| 201 | - * |
|
| 202 | - * @param string $modifier |
|
| 203 | - * @return Payone_Log4php_LoggerFormattingInfo |
|
| 204 | - * @throws LoggerException |
|
| 205 | - */ |
|
| 206 | - private function parseModifiers($modifiers) { |
|
| 207 | - $info = new Payone_Log4php_LoggerFormattingInfo(); |
|
| 208 | - |
|
| 209 | - // If no modifiers are given, return default values |
|
| 210 | - if (empty($modifiers)) { |
|
| 211 | - return $info; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - // Validate |
|
| 215 | - $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/'; |
|
| 216 | - if (!preg_match($pattern, $modifiers)) { |
|
| 217 | - trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING); |
|
| 218 | - return $info; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - $parts = explode('.', $modifiers); |
|
| 222 | - |
|
| 223 | - if (!empty($parts[0])) { |
|
| 224 | - $minPart = (integer) $parts[0]; |
|
| 225 | - $info->min = abs($minPart); |
|
| 226 | - $info->padLeft = ($minPart > 0); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - if (!empty($parts[1])) { |
|
| 230 | - $maxPart = (integer) $parts[1]; |
|
| 231 | - $info->max = abs($maxPart); |
|
| 232 | - $info->trimLeft = ($maxPart > 0); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - return $info; |
|
| 236 | - } |
|
| 184 | + return $converter; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** Adds a converter to the chain and updates $head and $tail pointers. */ |
|
| 188 | + private function addToChain(LoggerPatternConverter $converter) { |
|
| 189 | + if (!isset($this->head)) { |
|
| 190 | + $this->head = $converter; |
|
| 191 | + $this->tail = $this->head; |
|
| 192 | + } else { |
|
| 193 | + $this->tail->next = $converter; |
|
| 194 | + $this->tail = $this->tail->next; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Parses the formatting modifiers and produces the corresponding |
|
| 200 | + * LoggerFormattingInfo object. |
|
| 201 | + * |
|
| 202 | + * @param string $modifier |
|
| 203 | + * @return Payone_Log4php_LoggerFormattingInfo |
|
| 204 | + * @throws LoggerException |
|
| 205 | + */ |
|
| 206 | + private function parseModifiers($modifiers) { |
|
| 207 | + $info = new Payone_Log4php_LoggerFormattingInfo(); |
|
| 208 | + |
|
| 209 | + // If no modifiers are given, return default values |
|
| 210 | + if (empty($modifiers)) { |
|
| 211 | + return $info; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + // Validate |
|
| 215 | + $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/'; |
|
| 216 | + if (!preg_match($pattern, $modifiers)) { |
|
| 217 | + trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING); |
|
| 218 | + return $info; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + $parts = explode('.', $modifiers); |
|
| 222 | + |
|
| 223 | + if (!empty($parts[0])) { |
|
| 224 | + $minPart = (integer) $parts[0]; |
|
| 225 | + $info->min = abs($minPart); |
|
| 226 | + $info->padLeft = ($minPart > 0); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + if (!empty($parts[1])) { |
|
| 230 | + $maxPart = (integer) $parts[1]; |
|
| 231 | + $info->max = abs($maxPart); |
|
| 232 | + $info->trimLeft = ($maxPart > 0); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + return $info; |
|
| 236 | + } |
|
| 237 | 237 | } |
| 238 | 238 | |
@@ -41,45 +41,45 @@ |
||
| 41 | 41 | * @subpackage appenders |
| 42 | 42 | */ |
| 43 | 43 | class Payone_Log4php_LoggerAppenderEcho extends Payone_Log4php_LoggerAppender { |
| 44 | - /** boolean used internally to mark first append */ |
|
| 45 | - protected $firstAppend = true; |
|
| 44 | + /** boolean used internally to mark first append */ |
|
| 45 | + protected $firstAppend = true; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * If set to true, a <br /> element will be inserted before each line |
|
| 49 | - * break in the logged message. Default value is false. @var boolean |
|
| 50 | - */ |
|
| 51 | - protected $htmlLineBreaks = false; |
|
| 47 | + /** |
|
| 48 | + * If set to true, a <br /> element will be inserted before each line |
|
| 49 | + * break in the logged message. Default value is false. @var boolean |
|
| 50 | + */ |
|
| 51 | + protected $htmlLineBreaks = false; |
|
| 52 | 52 | |
| 53 | - public function close() { |
|
| 54 | - if($this->closed != true) { |
|
| 55 | - if(!$this->firstAppend) { |
|
| 56 | - echo $this->layout->getFooter(); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - $this->closed = true; |
|
| 60 | - } |
|
| 53 | + public function close() { |
|
| 54 | + if($this->closed != true) { |
|
| 55 | + if(!$this->firstAppend) { |
|
| 56 | + echo $this->layout->getFooter(); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + $this->closed = true; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 63 | - if($this->layout !== null) { |
|
| 64 | - if($this->firstAppend) { |
|
| 65 | - echo $this->layout->getHeader(); |
|
| 66 | - $this->firstAppend = false; |
|
| 67 | - } |
|
| 68 | - $text = $this->layout->format($event); |
|
| 62 | + public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 63 | + if($this->layout !== null) { |
|
| 64 | + if($this->firstAppend) { |
|
| 65 | + echo $this->layout->getHeader(); |
|
| 66 | + $this->firstAppend = false; |
|
| 67 | + } |
|
| 68 | + $text = $this->layout->format($event); |
|
| 69 | 69 | |
| 70 | - if ($this->htmlLineBreaks) { |
|
| 71 | - $text = nl2br($text); |
|
| 72 | - } |
|
| 73 | - echo $text; |
|
| 74 | - } |
|
| 75 | - } |
|
| 70 | + if ($this->htmlLineBreaks) { |
|
| 71 | + $text = nl2br($text); |
|
| 72 | + } |
|
| 73 | + echo $text; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - public function setHtmlLineBreaks($value) { |
|
| 78 | - $this->setBoolean('htmlLineBreaks', $value); |
|
| 79 | - } |
|
| 77 | + public function setHtmlLineBreaks($value) { |
|
| 78 | + $this->setBoolean('htmlLineBreaks', $value); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - public function getHtmlLineBreaks() { |
|
| 82 | - return $this->htmlLineBreaks; |
|
| 83 | - } |
|
| 81 | + public function getHtmlLineBreaks() { |
|
| 82 | + return $this->htmlLineBreaks; |
|
| 83 | + } |
|
| 84 | 84 | } |
| 85 | 85 | |
@@ -43,14 +43,14 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class Payone_Log4php_LoggerFilterDenyAll extends Payone_Log4php_LoggerFilter { |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Always returns the integer constant {@link LoggerFilter::DENY} |
|
| 48 | - * regardless of the {@link LoggerLoggingEvent} parameter. |
|
| 49 | - * |
|
| 50 | - * @param Payone_Log4php_LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter. |
|
| 51 | - * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY} |
|
| 52 | - */ |
|
| 53 | - public function decide(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 54 | - return Payone_Log4php_LoggerFilter::DENY; |
|
| 55 | - } |
|
| 46 | + /** |
|
| 47 | + * Always returns the integer constant {@link LoggerFilter::DENY} |
|
| 48 | + * regardless of the {@link LoggerLoggingEvent} parameter. |
|
| 49 | + * |
|
| 50 | + * @param Payone_Log4php_LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter. |
|
| 51 | + * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY} |
|
| 52 | + */ |
|
| 53 | + public function decide(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 54 | + return Payone_Log4php_LoggerFilter::DENY; |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -55,72 +55,72 @@ |
||
| 55 | 55 | */ |
| 56 | 56 | abstract class Payone_Log4php_LoggerFilter extends Payone_Log4php_LoggerConfigurable { |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * The log event must be logged immediately without consulting with |
|
| 60 | - * the remaining filters, if any, in the chain. |
|
| 61 | - */ |
|
| 62 | - const ACCEPT = 1; |
|
| 58 | + /** |
|
| 59 | + * The log event must be logged immediately without consulting with |
|
| 60 | + * the remaining filters, if any, in the chain. |
|
| 61 | + */ |
|
| 62 | + const ACCEPT = 1; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * This filter is neutral with respect to the log event. The |
|
| 66 | - * remaining filters, if any, should be consulted for a final decision. |
|
| 67 | - */ |
|
| 68 | - const NEUTRAL = 0; |
|
| 64 | + /** |
|
| 65 | + * This filter is neutral with respect to the log event. The |
|
| 66 | + * remaining filters, if any, should be consulted for a final decision. |
|
| 67 | + */ |
|
| 68 | + const NEUTRAL = 0; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * The log event must be dropped immediately without consulting |
|
| 72 | - * with the remaining filters, if any, in the chain. |
|
| 73 | - */ |
|
| 74 | - const DENY = -1; |
|
| 70 | + /** |
|
| 71 | + * The log event must be dropped immediately without consulting |
|
| 72 | + * with the remaining filters, if any, in the chain. |
|
| 73 | + */ |
|
| 74 | + const DENY = -1; |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain. |
|
| 78 | - */ |
|
| 79 | - protected $next; |
|
| 76 | + /** |
|
| 77 | + * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain. |
|
| 78 | + */ |
|
| 79 | + protected $next; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Usually filters options become active when set. We provide a |
|
| 83 | - * default do-nothing implementation for convenience. |
|
| 84 | - */ |
|
| 85 | - public function activateOptions() { |
|
| 86 | - } |
|
| 81 | + /** |
|
| 82 | + * Usually filters options become active when set. We provide a |
|
| 83 | + * default do-nothing implementation for convenience. |
|
| 84 | + */ |
|
| 85 | + public function activateOptions() { |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Decide what to do. |
|
| 90 | - * <p>If the decision is {@link LoggerFilter::DENY}, then the event will be |
|
| 91 | - * dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next |
|
| 92 | - * filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then |
|
| 93 | - * the event will be logged without consulting with other filters in |
|
| 94 | - * the chain. |
|
| 95 | - * |
|
| 96 | - * @param Payone_Log4php_LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon. |
|
| 97 | - * @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT} |
|
| 98 | - */ |
|
| 99 | - public function decide(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 100 | - return self::NEUTRAL; |
|
| 101 | - } |
|
| 88 | + /** |
|
| 89 | + * Decide what to do. |
|
| 90 | + * <p>If the decision is {@link LoggerFilter::DENY}, then the event will be |
|
| 91 | + * dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next |
|
| 92 | + * filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then |
|
| 93 | + * the event will be logged without consulting with other filters in |
|
| 94 | + * the chain. |
|
| 95 | + * |
|
| 96 | + * @param Payone_Log4php_LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon. |
|
| 97 | + * @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT} |
|
| 98 | + */ |
|
| 99 | + public function decide(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 100 | + return self::NEUTRAL; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Adds a new filter to the filter chain this filter is a part of. |
|
| 105 | - * If this filter has already and follow up filter, the param filter |
|
| 106 | - * is passed on until it is the last filter in chain. |
|
| 107 | - * |
|
| 108 | - * @param $filter - the filter to add to this chain |
|
| 109 | - */ |
|
| 110 | - public function addNext($filter) { |
|
| 111 | - if($this->next !== null) { |
|
| 112 | - $this->next->addNext($filter); |
|
| 113 | - } else { |
|
| 114 | - $this->next = $filter; |
|
| 115 | - } |
|
| 116 | - } |
|
| 103 | + /** |
|
| 104 | + * Adds a new filter to the filter chain this filter is a part of. |
|
| 105 | + * If this filter has already and follow up filter, the param filter |
|
| 106 | + * is passed on until it is the last filter in chain. |
|
| 107 | + * |
|
| 108 | + * @param $filter - the filter to add to this chain |
|
| 109 | + */ |
|
| 110 | + public function addNext($filter) { |
|
| 111 | + if($this->next !== null) { |
|
| 112 | + $this->next->addNext($filter); |
|
| 113 | + } else { |
|
| 114 | + $this->next = $filter; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Returns the next filter in this chain |
|
| 120 | - * @return the next filter |
|
| 121 | - */ |
|
| 122 | - public function getNext() { |
|
| 123 | - return $this->next; |
|
| 124 | - } |
|
| 118 | + /** |
|
| 119 | + * Returns the next filter in this chain |
|
| 120 | + * @return the next filter |
|
| 121 | + */ |
|
| 122 | + public function getNext() { |
|
| 123 | + return $this->next; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | } |
@@ -29,5 +29,5 @@ |
||
| 29 | 29 | * @subpackage pattern |
| 30 | 30 | */ |
| 31 | 31 | class Payone_Log4php_LoggerPatternConverterEnvironment extends Payone_Log4php_LoggerPatternConverterSuperglobal { |
| 32 | - protected $name = '_ENV'; |
|
| 32 | + protected $name = '_ENV'; |
|
| 33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
| 29 | 29 | * @subpackage pattern |
| 30 | 30 | */ |
| 31 | 31 | class Payone_Log4php_LoggerPatternConverterCookie extends Payone_Log4php_LoggerPatternConverterSuperglobal { |
| 32 | - protected $name = '_COOKIE'; |
|
| 32 | + protected $name = '_COOKIE'; |
|
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -39,18 +39,18 @@ |
||
| 39 | 39 | * @subpackage layouts |
| 40 | 40 | */ |
| 41 | 41 | class Payone_Log4php_LoggerLayoutSimple extends Payone_Log4php_LoggerLayout { |
| 42 | - /** |
|
| 43 | - * Returns the log statement in a format consisting of the |
|
| 44 | - * <b>level</b>, followed by " - " and then the |
|
| 45 | - * <b>message</b>. For example, |
|
| 46 | - * <samp> INFO - "A message" </samp> |
|
| 47 | - * |
|
| 48 | - * @param Payone_Log4php_LoggerLoggingEvent $event |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - public function format(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 52 | - $level = $event->getLevel(); |
|
| 53 | - $message = $event->getRenderedMessage(); |
|
| 54 | - return "$level - $message" . PHP_EOL; |
|
| 55 | - } |
|
| 42 | + /** |
|
| 43 | + * Returns the log statement in a format consisting of the |
|
| 44 | + * <b>level</b>, followed by " - " and then the |
|
| 45 | + * <b>message</b>. For example, |
|
| 46 | + * <samp> INFO - "A message" </samp> |
|
| 47 | + * |
|
| 48 | + * @param Payone_Log4php_LoggerLoggingEvent $event |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + public function format(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 52 | + $level = $event->getLevel(); |
|
| 53 | + $message = $event->getRenderedMessage(); |
|
| 54 | + return "$level - $message" . PHP_EOL; |
|
| 55 | + } |
|
| 56 | 56 | } |