@@ -74,6 +74,9 @@ discard block |
||
| 74 | 74 | return $header; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | + /** |
|
| 78 | + * @param string[] $lines |
|
| 79 | + */ |
|
| 77 | 80 | function _lines($lines, $prefix = ' ', $encode = true) |
| 78 | 81 | { |
| 79 | 82 | if ($encode) { |
@@ -141,6 +144,9 @@ discard block |
||
| 141 | 144 | return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; |
| 142 | 145 | } |
| 143 | 146 | |
| 147 | + /** |
|
| 148 | + * @param string $string |
|
| 149 | + */ |
|
| 144 | 150 | function _splitOnWords($string, $newlineEscape = "\n") |
| 145 | 151 | { |
| 146 | 152 | // Ignore \0; otherwise the while loop will never finish. |
@@ -129,13 +129,13 @@ |
||
| 129 | 129 | * preserve whitespace as well. Therefore we split on words, |
| 130 | 130 | * but include all blocks of whitespace in the wordlist. */ |
| 131 | 131 | $diff = new Text_Diff('native', |
| 132 | - array($this->_splitOnWords($text1, $nl), |
|
| 132 | + array($this->_splitOnWords($text1, $nl), |
|
| 133 | 133 | $this->_splitOnWords($text2, $nl))); |
| 134 | 134 | |
| 135 | 135 | /* Get the diff in inline format. */ |
| 136 | 136 | $renderer = new Text_Diff_Renderer_inline |
| 137 | 137 | (array_merge($this->getParams(), |
| 138 | - array('split_level' => 'words'))); |
|
| 138 | + array('split_level' => 'words'))); |
|
| 139 | 139 | |
| 140 | 140 | /* Run the diff and get the output. */ |
| 141 | 141 | return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | if ($this->_split_level == 'words') { |
| 84 | 84 | return implode('', $lines); |
| 85 | 85 | } else { |
| 86 | - return implode("\n", $lines) . "\n"; |
|
| 86 | + return implode("\n", $lines)."\n"; |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | function _added($lines) |
| 91 | 91 | { |
| 92 | 92 | array_walk($lines, array(&$this, '_encode')); |
| 93 | - $lines[0] = $this->_ins_prefix . $lines[0]; |
|
| 93 | + $lines[0] = $this->_ins_prefix.$lines[0]; |
|
| 94 | 94 | $lines[count($lines) - 1] .= $this->_ins_suffix; |
| 95 | 95 | return $this->_lines($lines, ' ', false); |
| 96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | function _deleted($lines, $words = false) |
| 99 | 99 | { |
| 100 | 100 | array_walk($lines, array(&$this, '_encode')); |
| 101 | - $lines[0] = $this->_del_prefix . $lines[0]; |
|
| 101 | + $lines[0] = $this->_del_prefix.$lines[0]; |
|
| 102 | 102 | $lines[count($lines) - 1] .= $this->_del_suffix; |
| 103 | 103 | return $this->_lines($lines, ' ', false); |
| 104 | 104 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $orig[0] = substr($orig[0], 1); |
| 117 | 117 | $final[0] = substr($final[0], 1); |
| 118 | 118 | } |
| 119 | - return $prefix . $this->_deleted($orig) . $this->_added($final); |
|
| 119 | + return $prefix.$this->_deleted($orig).$this->_added($final); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $text1 = implode("\n", $orig); |
@@ -133,12 +133,11 @@ discard block |
||
| 133 | 133 | $this->_splitOnWords($text2, $nl))); |
| 134 | 134 | |
| 135 | 135 | /* Get the diff in inline format. */ |
| 136 | - $renderer = new Text_Diff_Renderer_inline |
|
| 137 | - (array_merge($this->getParams(), |
|
| 136 | + $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(), |
|
| 138 | 137 | array('split_level' => 'words'))); |
| 139 | 138 | |
| 140 | 139 | /* Run the diff and get the output. */ |
| 141 | - return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; |
|
| 140 | + return str_replace($nl, "\n", $renderer->render($diff))."\n"; |
|
| 142 | 141 | } |
| 143 | 142 | |
| 144 | 143 | function _splitOnWords($string, $newlineEscape = "\n") |
@@ -180,6 +180,7 @@ discard block |
||
| 180 | 180 | * @access private |
| 181 | 181 | * @param string Login |
| 182 | 182 | * @param integer Key |
| 183 | + * @param integer $key |
|
| 183 | 184 | * @return string |
| 184 | 185 | */ |
| 185 | 186 | function _xor($login, $key) |
@@ -208,6 +209,7 @@ discard block |
||
| 208 | 209 | * @access private |
| 209 | 210 | * @param string Login |
| 210 | 211 | * @param integer Key |
| 212 | + * @param integer $key |
|
| 211 | 213 | * @return string |
| 212 | 214 | */ |
| 213 | 215 | function _rotx($login, $key) |
@@ -241,6 +243,7 @@ discard block |
||
| 241 | 243 | * @access private |
| 242 | 244 | * @param string Login |
| 243 | 245 | * @param integer Key |
| 246 | + * @param integer $key |
|
| 244 | 247 | * @return string |
| 245 | 248 | */ |
| 246 | 249 | function _rotxpp($login, $key) |
@@ -274,6 +277,7 @@ discard block |
||
| 274 | 277 | * @access private |
| 275 | 278 | * @param string Login |
| 276 | 279 | * @param integer Key |
| 280 | + * @param integer $key |
|
| 277 | 281 | * @return string |
| 278 | 282 | */ |
| 279 | 283 | function _rotxmm($login, $key) |
@@ -306,6 +310,7 @@ discard block |
||
| 306 | 310 | * @access private |
| 307 | 311 | * @param string Login |
| 308 | 312 | * @param integer Key |
| 313 | + * @param integer $key |
|
| 309 | 314 | * @return string |
| 310 | 315 | */ |
| 311 | 316 | function _asciiRotx($login, $key) |
@@ -340,6 +345,7 @@ discard block |
||
| 340 | 345 | * @access private |
| 341 | 346 | * @param string Login |
| 342 | 347 | * @param integer Key |
| 348 | + * @param integer $key |
|
| 343 | 349 | * @return string |
| 344 | 350 | */ |
| 345 | 351 | function _asciiRotxpp($login, $key) |
@@ -374,6 +380,7 @@ discard block |
||
| 374 | 380 | * @access private |
| 375 | 381 | * @param string Login |
| 376 | 382 | * @param integer Key |
| 383 | + * @param integer $key |
|
| 377 | 384 | * @return string |
| 378 | 385 | */ |
| 379 | 386 | function _asciiRotxmm($login, $key) |
@@ -430,6 +437,7 @@ discard block |
||
| 430 | 437 | * |
| 431 | 438 | * @access private |
| 432 | 439 | * @param integer Length of the password |
| 440 | + * @param integer $length |
|
| 433 | 441 | * @return string Returns the password |
| 434 | 442 | */ |
| 435 | 443 | function _createPronounceable($length) |
@@ -475,6 +483,8 @@ discard block |
||
| 475 | 483 | * @param string Character which could be use in the |
| 476 | 484 | * unpronounceable password ex : 'ABCDEFG' |
| 477 | 485 | * or numeric, alphabetical or alphanumeric. |
| 486 | + * @param integer $length |
|
| 487 | + * @param string $chars |
|
| 478 | 488 | * @return string Returns the password |
| 479 | 489 | */ |
| 480 | 490 | function _createUnpronounceable($length, $chars) |
@@ -441,17 +441,17 @@ discard block |
||
| 441 | 441 | * List of vowels and vowel sounds |
| 442 | 442 | */ |
| 443 | 443 | $v = array('a', 'e', 'i', 'o', 'u', 'ae', 'ou', 'io', |
| 444 | - 'ea', 'ou', 'ia', 'ai' |
|
| 445 | - ); |
|
| 444 | + 'ea', 'ou', 'ia', 'ai' |
|
| 445 | + ); |
|
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * List of consonants and consonant sounds |
| 449 | 449 | */ |
| 450 | 450 | $c = array('b', 'c', 'd', 'g', 'h', 'j', 'k', 'l', 'm', |
| 451 | - 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', |
|
| 452 | - 'tr', 'cr', 'fr', 'dr', 'wr', 'pr', 'th', |
|
| 453 | - 'ch', 'ph', 'st', 'sl', 'cl' |
|
| 454 | - ); |
|
| 451 | + 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', |
|
| 452 | + 'tr', 'cr', 'fr', 'dr', 'wr', 'pr', 'th', |
|
| 453 | + 'ch', 'ph', 'st', 'sl', 'cl' |
|
| 454 | + ); |
|
| 455 | 455 | |
| 456 | 456 | $v_count = 12; |
| 457 | 457 | $c_count = 29; |
@@ -484,50 +484,50 @@ discard block |
||
| 484 | 484 | /** |
| 485 | 485 | * List of character which could be use in the password |
| 486 | 486 | */ |
| 487 | - switch($chars) { |
|
| 487 | + switch($chars) { |
|
| 488 | 488 | |
| 489 | - case 'alphanumeric': |
|
| 489 | + case 'alphanumeric': |
|
| 490 | 490 | $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
| 491 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 62; |
|
| 492 | - break; |
|
| 491 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 62; |
|
| 492 | + break; |
|
| 493 | 493 | |
| 494 | - case 'alphabetical': |
|
| 494 | + case 'alphabetical': |
|
| 495 | 495 | $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
| 496 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 52; |
|
| 497 | - break; |
|
| 496 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 52; |
|
| 497 | + break; |
|
| 498 | 498 | |
| 499 | - case 'numeric': |
|
| 499 | + case 'numeric': |
|
| 500 | 500 | $chars = '0123456789'; |
| 501 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 10; |
|
| 502 | - break; |
|
| 501 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 10; |
|
| 502 | + break; |
|
| 503 | 503 | |
| 504 | - case '': |
|
| 504 | + case '': |
|
| 505 | 505 | $chars = '_#@%&ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
| 506 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 67; |
|
| 507 | - break; |
|
| 506 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 67; |
|
| 507 | + break; |
|
| 508 | 508 | |
| 509 | - default: |
|
| 509 | + default: |
|
| 510 | 510 | /** |
| 511 | 511 | * Some characters shouldn't be used |
| 512 | 512 | */ |
| 513 | 513 | $chars = trim($chars); |
| 514 | - $chars = str_replace(array('+', '|', '$', '^', '/', '\\', ','), '', $chars); |
|
| 515 | - |
|
| 516 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = strlen($chars); |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - /** |
|
| 520 | - * Generate password |
|
| 521 | - */ |
|
| 522 | - for ($i = 0; $i < $length; $i++) { |
|
| 523 | - $num = mt_rand(0, $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] - 1); |
|
| 524 | - $password .= $chars{$num}; |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - /** |
|
| 528 | - * Return password |
|
| 529 | - */ |
|
| 530 | - return $password; |
|
| 514 | + $chars = str_replace(array('+', '|', '$', '^', '/', '\\', ','), '', $chars); |
|
| 515 | + |
|
| 516 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = strlen($chars); |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + /** |
|
| 520 | + * Generate password |
|
| 521 | + */ |
|
| 522 | + for ($i = 0; $i < $length; $i++) { |
|
| 523 | + $num = mt_rand(0, $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] - 1); |
|
| 524 | + $password .= $chars{$num}; |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + /** |
|
| 528 | + * Return password |
|
| 529 | + */ |
|
| 530 | + return $password; |
|
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | ?> |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | function create($length = 10, $type = 'pronounceable', $chars = '') |
| 56 | 56 | { |
| 57 | 57 | switch ($type) { |
| 58 | - case 'unpronounceable' : |
|
| 59 | - return Text_Password::_createUnpronounceable($length, $chars); |
|
| 58 | + case 'unpronounceable' : |
|
| 59 | + return Text_Password::_createUnpronounceable($length, $chars); |
|
| 60 | 60 | |
| 61 | - case 'pronounceable' : |
|
| 62 | - default : |
|
| 63 | - return Text_Password::_createPronounceable($length); |
|
| 61 | + case 'pronounceable' : |
|
| 62 | + default : |
|
| 63 | + return Text_Password::_createPronounceable($length); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -110,35 +110,35 @@ discard block |
||
| 110 | 110 | function createFromLogin($login, $type, $key = 0) |
| 111 | 111 | { |
| 112 | 112 | switch ($type) { |
| 113 | - case 'reverse': |
|
| 114 | - return strrev($login); |
|
| 113 | + case 'reverse': |
|
| 114 | + return strrev($login); |
|
| 115 | 115 | |
| 116 | - case 'shuffle': |
|
| 117 | - return Text_Password::_shuffle($login); |
|
| 116 | + case 'shuffle': |
|
| 117 | + return Text_Password::_shuffle($login); |
|
| 118 | 118 | |
| 119 | - case 'xor': |
|
| 120 | - return Text_Password::_xor($login, $key); |
|
| 119 | + case 'xor': |
|
| 120 | + return Text_Password::_xor($login, $key); |
|
| 121 | 121 | |
| 122 | - case 'rot13': |
|
| 123 | - return str_rot13($login); |
|
| 122 | + case 'rot13': |
|
| 123 | + return str_rot13($login); |
|
| 124 | 124 | |
| 125 | - case 'rotx': |
|
| 126 | - return Text_Password::_rotx($login, $key); |
|
| 125 | + case 'rotx': |
|
| 126 | + return Text_Password::_rotx($login, $key); |
|
| 127 | 127 | |
| 128 | - case 'rotx++': |
|
| 129 | - return Text_Password::_rotxpp($login, $key); |
|
| 128 | + case 'rotx++': |
|
| 129 | + return Text_Password::_rotxpp($login, $key); |
|
| 130 | 130 | |
| 131 | - case 'rotx--': |
|
| 132 | - return Text_Password::_rotxmm($login, $key); |
|
| 131 | + case 'rotx--': |
|
| 132 | + return Text_Password::_rotxmm($login, $key); |
|
| 133 | 133 | |
| 134 | - case 'ascii_rotx': |
|
| 135 | - return Text_Password::_asciiRotx($login, $key); |
|
| 134 | + case 'ascii_rotx': |
|
| 135 | + return Text_Password::_asciiRotx($login, $key); |
|
| 136 | 136 | |
| 137 | - case 'ascii_rotx++': |
|
| 138 | - return Text_Password::_asciiRotxpp($login, $key); |
|
| 137 | + case 'ascii_rotx++': |
|
| 138 | + return Text_Password::_asciiRotxpp($login, $key); |
|
| 139 | 139 | |
| 140 | - case 'ascii_rotx--': |
|
| 141 | - return Text_Password::_asciiRotxmm($login, $key); |
|
| 140 | + case 'ascii_rotx--': |
|
| 141 | + return Text_Password::_asciiRotxmm($login, $key); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -320,11 +320,11 @@ discard block |
||
| 320 | 320 | $next += 255; |
| 321 | 321 | } |
| 322 | 322 | switch ($next) { // delete white space |
| 323 | - case 0x09: |
|
| 324 | - case 0x20: |
|
| 325 | - case 0x0A: |
|
| 326 | - case 0x0D: |
|
| 327 | - $next++; |
|
| 323 | + case 0x09: |
|
| 324 | + case 0x20: |
|
| 325 | + case 0x0A: |
|
| 326 | + case 0x0D: |
|
| 327 | + $next++; |
|
| 328 | 328 | } |
| 329 | 329 | $tmp .= chr($next); |
| 330 | 330 | } |
@@ -354,11 +354,11 @@ discard block |
||
| 354 | 354 | $next += 255; |
| 355 | 355 | } |
| 356 | 356 | switch ($next) { // delete white space |
| 357 | - case 0x09: |
|
| 358 | - case 0x20: |
|
| 359 | - case 0x0A: |
|
| 360 | - case 0x0D: |
|
| 361 | - $next++; |
|
| 357 | + case 0x09: |
|
| 358 | + case 0x20: |
|
| 359 | + case 0x0A: |
|
| 360 | + case 0x0D: |
|
| 361 | + $next++; |
|
| 362 | 362 | } |
| 363 | 363 | $tmp .= chr($next); |
| 364 | 364 | } |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | $next += 255; |
| 389 | 389 | } |
| 390 | 390 | switch ($next) { // delete white space |
| 391 | - case 0x09: |
|
| 392 | - case 0x20: |
|
| 393 | - case 0x0A: |
|
| 394 | - case 0x0D: |
|
| 395 | - $next++; |
|
| 391 | + case 0x09: |
|
| 392 | + case 0x20: |
|
| 393 | + case 0x0A: |
|
| 394 | + case 0x0D: |
|
| 395 | + $next++; |
|
| 396 | 396 | } |
| 397 | 397 | $tmp .= chr($next); |
| 398 | 398 | } |
@@ -486,34 +486,34 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | switch($chars) { |
| 488 | 488 | |
| 489 | - case 'alphanumeric': |
|
| 490 | - $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 491 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 62; |
|
| 492 | - break; |
|
| 489 | + case 'alphanumeric': |
|
| 490 | + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 491 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 62; |
|
| 492 | + break; |
|
| 493 | 493 | |
| 494 | - case 'alphabetical': |
|
| 495 | - $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
|
| 496 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 52; |
|
| 497 | - break; |
|
| 494 | + case 'alphabetical': |
|
| 495 | + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
|
| 496 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 52; |
|
| 497 | + break; |
|
| 498 | 498 | |
| 499 | - case 'numeric': |
|
| 500 | - $chars = '0123456789'; |
|
| 501 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 10; |
|
| 502 | - break; |
|
| 499 | + case 'numeric': |
|
| 500 | + $chars = '0123456789'; |
|
| 501 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 10; |
|
| 502 | + break; |
|
| 503 | 503 | |
| 504 | - case '': |
|
| 505 | - $chars = '_#@%&ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 506 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 67; |
|
| 507 | - break; |
|
| 504 | + case '': |
|
| 505 | + $chars = '_#@%&ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 506 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = 67; |
|
| 507 | + break; |
|
| 508 | 508 | |
| 509 | - default: |
|
| 510 | - /** |
|
| 509 | + default: |
|
| 510 | + /** |
|
| 511 | 511 | * Some characters shouldn't be used |
| 512 | 512 | */ |
| 513 | - $chars = trim($chars); |
|
| 514 | - $chars = str_replace(array('+', '|', '$', '^', '/', '\\', ','), '', $chars); |
|
| 513 | + $chars = trim($chars); |
|
| 514 | + $chars = str_replace(array('+', '|', '$', '^', '/', '\\', ','), '', $chars); |
|
| 515 | 515 | |
| 516 | - $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = strlen($chars); |
|
| 516 | + $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = strlen($chars); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | $GLOBALS['_Text_Password_NumberOfPossibleCharacters'] = $v_count + $c_count; |
| 460 | 460 | |
| 461 | 461 | for ($i = 0; $i < $length; $i++) { |
| 462 | - $retVal .= $c[mt_rand(0, $c_count-1)] . $v[mt_rand(0, $v_count-1)]; |
|
| 462 | + $retVal .= $c[mt_rand(0, $c_count - 1)].$v[mt_rand(0, $v_count - 1)]; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | return substr($retVal, 0, $length); |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | /** |
| 485 | 485 | * List of character which could be use in the password |
| 486 | 486 | */ |
| 487 | - switch($chars) { |
|
| 487 | + switch ($chars) { |
|
| 488 | 488 | |
| 489 | 489 | case 'alphanumeric': |
| 490 | 490 | $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
@@ -115,7 +115,7 @@ |
||
| 115 | 115 | * Setup db connection. |
| 116 | 116 | * Based on defined options, this method connects to db defined in {@link $dsn} |
| 117 | 117 | * and creates a {@link $table} table if {@link $createTable} is true. |
| 118 | - * @return boolean true if all ok. |
|
| 118 | + * @return boolean|null true if all ok. |
|
| 119 | 119 | */ |
| 120 | 120 | function activateOptions() |
| 121 | 121 | { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | /** A docblok to make phpdoc happy */ |
| 22 | -require_once(ADODB_DIR . '/adodb.inc.php'); |
|
| 22 | +require_once(ADODB_DIR.'/adodb.inc.php'); |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * Appends log events to a db table using adodb class. |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | function activateOptions() |
| 121 | 121 | { |
| 122 | 122 | $this->db = &ADONewConnection($this->type); |
| 123 | - if (! $this->db->PConnect($this->host, $this->user, $this->password, $this->database)) { |
|
| 123 | + if (!$this->db->PConnect($this->host, $this->user, $this->password, $this->database)) { |
|
| 124 | 124 | $this->db = null; |
| 125 | 125 | $this->closed = true; |
| 126 | 126 | $this->canAppend = false; |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | $this->layout->setConversionPattern($this->getSql()); |
| 132 | 132 | |
| 133 | 133 | // test if log table exists |
| 134 | - $sql = 'select * from ' . $this->table . ' where 1 = 0'; |
|
| 134 | + $sql = 'select * from '.$this->table.' where 1 = 0'; |
|
| 135 | 135 | $dbrs = $this->db->Execute($sql); |
| 136 | 136 | if ($dbrs == false and $this->getCreateTable()) { |
| 137 | 137 | $query = "CREATE TABLE {$this->table} (timestamp varchar(32),logger varchar(32),level varchar(32),message varchar(64),thread varchar(32),file varchar(64),line varchar(4) );"; |
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | $result = $this->db->Execute($query); |
| 141 | - if (! $result) { |
|
| 141 | + if (!$result) { |
|
| 142 | 142 | $this->canAppend = false; |
| 143 | 143 | return; |
| 144 | 144 | } |
@@ -155,8 +155,9 @@ |
||
| 155 | 155 | |
| 156 | 156 | function close() |
| 157 | 157 | { |
| 158 | - if ($this->db !== null) |
|
| 159 | - $this->db->Close(); |
|
| 158 | + if ($this->db !== null) { |
|
| 159 | + $this->db->Close(); |
|
| 160 | + } |
|
| 160 | 161 | $this->closed = true; |
| 161 | 162 | } |
| 162 | 163 | |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | - * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | - * this work for additional information regarding copyright ownership. |
|
| 6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | - * (the "License"); you may not use this file except in compliance with |
|
| 8 | - * the License. You may obtain a copy of the License at |
|
| 9 | - * |
|
| 10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | - * |
|
| 12 | - * Unless required by applicable law or agreed to in writing, software |
|
| 13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | - * See the License for the specific language governing permissions and |
|
| 16 | - * limitations under the License. |
|
| 17 | - * |
|
| 18 | - * @package log4php |
|
| 19 | - */ |
|
| 3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | + * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | + * this work for additional information regarding copyright ownership. |
|
| 6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | + * (the "License"); you may not use this file except in compliance with |
|
| 8 | + * the License. You may obtain a copy of the License at |
|
| 9 | + * |
|
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | + * |
|
| 12 | + * Unless required by applicable law or agreed to in writing, software |
|
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | + * See the License for the specific language governing permissions and |
|
| 16 | + * limitations under the License. |
|
| 17 | + * |
|
| 18 | + * @package log4php |
|
| 19 | + */ |
|
| 20 | 20 | |
| 21 | 21 | /** A docblok to make phpdoc happy */ |
| 22 | 22 | require_once(ADODB_DIR . '/adodb.inc.php'); |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | $this->db = &ADONewConnection($this->type); |
| 123 | 123 | if (! $this->db->PConnect($this->host, $this->user, $this->password, $this->database)) { |
| 124 | - $this->db = null; |
|
| 125 | - $this->closed = true; |
|
| 126 | - $this->canAppend = false; |
|
| 127 | - return; |
|
| 124 | + $this->db = null; |
|
| 125 | + $this->closed = true; |
|
| 126 | + $this->canAppend = false; |
|
| 127 | + return; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | $this->layout = LoggerReflectionUtils::createObject('LoggerLayoutPattern'); |
@@ -151,10 +151,16 @@ |
||
| 151 | 151 | return $this->append; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | + /** |
|
| 155 | + * @param boolean $flag |
|
| 156 | + */ |
|
| 154 | 157 | public function setAppend($flag) { |
| 155 | 158 | $this->append = LoggerOptionConverter::toBoolean($flag, true); |
| 156 | 159 | } |
| 157 | 160 | |
| 161 | + /** |
|
| 162 | + * @param string $fileName |
|
| 163 | + */ |
|
| 158 | 164 | public function setFileName($fileName) { |
| 159 | 165 | $this->fileName = $fileName; |
| 160 | 166 | } |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | public function activateOptions() { |
| 68 | 68 | $fileName = $this->getFile(); |
| 69 | 69 | |
| 70 | - if(!is_file($fileName)) { |
|
| 70 | + if (!is_file($fileName)) { |
|
| 71 | 71 | $dir = dirname($fileName); |
| 72 | - if(!is_dir($dir)) { |
|
| 72 | + if (!is_dir($dir)) { |
|
| 73 | 73 | mkdir($dir, 0777, true); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
| 78 | - if($this->fp) { |
|
| 79 | - if(flock($this->fp, LOCK_EX)) { |
|
| 80 | - if($this->getAppend()) { |
|
| 77 | + $this->fp = fopen($fileName, ($this->getAppend() ? 'a' : 'w')); |
|
| 78 | + if ($this->fp) { |
|
| 79 | + if (flock($this->fp, LOCK_EX)) { |
|
| 80 | + if ($this->getAppend()) { |
|
| 81 | 81 | fseek($this->fp, 0, SEEK_END); |
| 82 | 82 | } |
| 83 | 83 | fwrite($this->fp, $this->layout->getHeader()); |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | public function close() { |
| 96 | - if($this->closed != true) { |
|
| 97 | - if($this->fp and $this->layout !== null) { |
|
| 98 | - if(flock($this->fp, LOCK_EX)) { |
|
| 96 | + if ($this->closed != true) { |
|
| 97 | + if ($this->fp and $this->layout !== null) { |
|
| 98 | + if (flock($this->fp, LOCK_EX)) { |
|
| 99 | 99 | fwrite($this->fp, $this->layout->getFooter()); |
| 100 | 100 | flock($this->fp, LOCK_UN); |
| 101 | 101 | } |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public function append(LoggerLoggingEvent $event) { |
| 109 | - if($this->fp and $this->layout !== null) { |
|
| 110 | - if(flock($this->fp, LOCK_EX)) { |
|
| 109 | + if ($this->fp and $this->layout !== null) { |
|
| 110 | + if (flock($this->fp, LOCK_EX)) { |
|
| 111 | 111 | fwrite($this->fp, $this->layout->format($event)); |
| 112 | 112 | flock($this->fp, LOCK_UN); |
| 113 | 113 | } else { |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function setFile() { |
| 129 | 129 | $numargs = func_num_args(); |
| 130 | - $args = func_get_args(); |
|
| 130 | + $args = func_get_args(); |
|
| 131 | 131 | |
| 132 | - if($numargs == 1 and is_string($args[0])) { |
|
| 132 | + if ($numargs == 1 and is_string($args[0])) { |
|
| 133 | 133 | $this->setFileName($args[0]); |
| 134 | - } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
| 134 | + } else if ($numargs >= 2 and is_string($args[0]) and is_bool($args[1])) { |
|
| 135 | 135 | $this->setFile($args[0]); |
| 136 | 136 | $this->setAppend($args[1]); |
| 137 | 137 | } |
@@ -42,129 +42,129 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | class LoggerAppenderFile extends LoggerAppender { |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var boolean if {@link $file} exists, appends events. |
|
| 47 | - */ |
|
| 48 | - private $append = true; |
|
| 49 | - /** |
|
| 50 | - * @var string the file name used to append events |
|
| 51 | - */ |
|
| 52 | - protected $fileName; |
|
| 53 | - /** |
|
| 54 | - * @var mixed file resource |
|
| 55 | - */ |
|
| 56 | - protected $fp = false; |
|
| 45 | + /** |
|
| 46 | + * @var boolean if {@link $file} exists, appends events. |
|
| 47 | + */ |
|
| 48 | + private $append = true; |
|
| 49 | + /** |
|
| 50 | + * @var string the file name used to append events |
|
| 51 | + */ |
|
| 52 | + protected $fileName; |
|
| 53 | + /** |
|
| 54 | + * @var mixed file resource |
|
| 55 | + */ |
|
| 56 | + protected $fp = false; |
|
| 57 | 57 | |
| 58 | - public function __construct($name = '') { |
|
| 59 | - parent::__construct($name); |
|
| 60 | - $this->requiresLayout = true; |
|
| 61 | - } |
|
| 58 | + public function __construct($name = '') { |
|
| 59 | + parent::__construct($name); |
|
| 60 | + $this->requiresLayout = true; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function __destruct() { |
|
| 64 | - $this->close(); |
|
| 65 | - } |
|
| 63 | + public function __destruct() { |
|
| 64 | + $this->close(); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public function activateOptions() { |
|
| 68 | - $fileName = $this->getFile(); |
|
| 67 | + public function activateOptions() { |
|
| 68 | + $fileName = $this->getFile(); |
|
| 69 | 69 | |
| 70 | - if(!is_file($fileName)) { |
|
| 71 | - $dir = dirname($fileName); |
|
| 72 | - if(!is_dir($dir)) { |
|
| 73 | - mkdir($dir, 0777, true); |
|
| 74 | - } |
|
| 75 | - } |
|
| 70 | + if(!is_file($fileName)) { |
|
| 71 | + $dir = dirname($fileName); |
|
| 72 | + if(!is_dir($dir)) { |
|
| 73 | + mkdir($dir, 0777, true); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
| 78 | - if($this->fp) { |
|
| 79 | - if(flock($this->fp, LOCK_EX)) { |
|
| 80 | - if($this->getAppend()) { |
|
| 81 | - fseek($this->fp, 0, SEEK_END); |
|
| 82 | - } |
|
| 83 | - fwrite($this->fp, $this->layout->getHeader()); |
|
| 84 | - flock($this->fp, LOCK_UN); |
|
| 85 | - $this->closed = false; |
|
| 86 | - } else { |
|
| 87 | - // TODO: should we take some action in this case? |
|
| 88 | - $this->closed = true; |
|
| 89 | - } |
|
| 90 | - } else { |
|
| 91 | - $this->closed = true; |
|
| 92 | - } |
|
| 93 | - } |
|
| 77 | + $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
| 78 | + if($this->fp) { |
|
| 79 | + if(flock($this->fp, LOCK_EX)) { |
|
| 80 | + if($this->getAppend()) { |
|
| 81 | + fseek($this->fp, 0, SEEK_END); |
|
| 82 | + } |
|
| 83 | + fwrite($this->fp, $this->layout->getHeader()); |
|
| 84 | + flock($this->fp, LOCK_UN); |
|
| 85 | + $this->closed = false; |
|
| 86 | + } else { |
|
| 87 | + // TODO: should we take some action in this case? |
|
| 88 | + $this->closed = true; |
|
| 89 | + } |
|
| 90 | + } else { |
|
| 91 | + $this->closed = true; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - public function close() { |
|
| 96 | - if($this->closed != true) { |
|
| 97 | - if($this->fp and $this->layout !== null) { |
|
| 98 | - if(flock($this->fp, LOCK_EX)) { |
|
| 99 | - fwrite($this->fp, $this->layout->getFooter()); |
|
| 100 | - flock($this->fp, LOCK_UN); |
|
| 101 | - } |
|
| 102 | - fclose($this->fp); |
|
| 103 | - } |
|
| 104 | - $this->closed = true; |
|
| 105 | - } |
|
| 106 | - } |
|
| 95 | + public function close() { |
|
| 96 | + if($this->closed != true) { |
|
| 97 | + if($this->fp and $this->layout !== null) { |
|
| 98 | + if(flock($this->fp, LOCK_EX)) { |
|
| 99 | + fwrite($this->fp, $this->layout->getFooter()); |
|
| 100 | + flock($this->fp, LOCK_UN); |
|
| 101 | + } |
|
| 102 | + fclose($this->fp); |
|
| 103 | + } |
|
| 104 | + $this->closed = true; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - public function append(LoggerLoggingEvent $event) { |
|
| 109 | - if($this->fp and $this->layout !== null) { |
|
| 110 | - if(flock($this->fp, LOCK_EX)) { |
|
| 111 | - fwrite($this->fp, $this->layout->format($event)); |
|
| 112 | - flock($this->fp, LOCK_UN); |
|
| 113 | - } else { |
|
| 114 | - $this->closed = true; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - } |
|
| 108 | + public function append(LoggerLoggingEvent $event) { |
|
| 109 | + if($this->fp and $this->layout !== null) { |
|
| 110 | + if(flock($this->fp, LOCK_EX)) { |
|
| 111 | + fwrite($this->fp, $this->layout->format($event)); |
|
| 112 | + flock($this->fp, LOCK_UN); |
|
| 113 | + } else { |
|
| 114 | + $this->closed = true; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Sets and opens the file where the log output will go. |
|
| 121 | - * |
|
| 122 | - * This is an overloaded method. It can be called with: |
|
| 123 | - * - setFile(string $fileName) to set filename. |
|
| 124 | - * - setFile(string $fileName, boolean $append) to set filename and append. |
|
| 125 | - * |
|
| 126 | - * TODO: remove overloading. Use only file as alias to filename |
|
| 127 | - */ |
|
| 128 | - public function setFile() { |
|
| 129 | - $numargs = func_num_args(); |
|
| 130 | - $args = func_get_args(); |
|
| 119 | + /** |
|
| 120 | + * Sets and opens the file where the log output will go. |
|
| 121 | + * |
|
| 122 | + * This is an overloaded method. It can be called with: |
|
| 123 | + * - setFile(string $fileName) to set filename. |
|
| 124 | + * - setFile(string $fileName, boolean $append) to set filename and append. |
|
| 125 | + * |
|
| 126 | + * TODO: remove overloading. Use only file as alias to filename |
|
| 127 | + */ |
|
| 128 | + public function setFile() { |
|
| 129 | + $numargs = func_num_args(); |
|
| 130 | + $args = func_get_args(); |
|
| 131 | 131 | |
| 132 | - if($numargs == 1 and is_string($args[0])) { |
|
| 133 | - $this->setFileName($args[0]); |
|
| 134 | - } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
| 135 | - $this->setFile($args[0]); |
|
| 136 | - $this->setAppend($args[1]); |
|
| 137 | - } |
|
| 138 | - } |
|
| 132 | + if($numargs == 1 and is_string($args[0])) { |
|
| 133 | + $this->setFileName($args[0]); |
|
| 134 | + } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
| 135 | + $this->setFile($args[0]); |
|
| 136 | + $this->setAppend($args[1]); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * @return string |
|
| 142 | - */ |
|
| 143 | - public function getFile() { |
|
| 144 | - return $this->getFileName(); |
|
| 145 | - } |
|
| 140 | + /** |
|
| 141 | + * @return string |
|
| 142 | + */ |
|
| 143 | + public function getFile() { |
|
| 144 | + return $this->getFileName(); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * @return boolean |
|
| 149 | - */ |
|
| 150 | - public function getAppend() { |
|
| 151 | - return $this->append; |
|
| 152 | - } |
|
| 147 | + /** |
|
| 148 | + * @return boolean |
|
| 149 | + */ |
|
| 150 | + public function getAppend() { |
|
| 151 | + return $this->append; |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - public function setAppend($flag) { |
|
| 155 | - $this->append = LoggerOptionConverter::toBoolean($flag, true); |
|
| 156 | - } |
|
| 154 | + public function setAppend($flag) { |
|
| 155 | + $this->append = LoggerOptionConverter::toBoolean($flag, true); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - public function setFileName($fileName) { |
|
| 159 | - $this->fileName = $fileName; |
|
| 160 | - } |
|
| 158 | + public function setFileName($fileName) { |
|
| 159 | + $this->fileName = $fileName; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * @return string |
|
| 164 | - */ |
|
| 165 | - public function getFileName() { |
|
| 166 | - return $this->fileName; |
|
| 167 | - } |
|
| 162 | + /** |
|
| 163 | + * @return string |
|
| 164 | + */ |
|
| 165 | + public function getFileName() { |
|
| 166 | + return $this->fileName; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | 169 | |
| 170 | 170 | } |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * Returns the value of the MaxBackupIndex option. |
| 95 | - * @return integer |
|
| 95 | + * @return string |
|
| 96 | 96 | */ |
| 97 | 97 | private function getExpandedFileName() { |
| 98 | 98 | return $this->expandedFileName; |
@@ -48,183 +48,183 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | class LoggerAppenderRollingFile extends LoggerAppenderFile { |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Set the maximum size that the output file is allowed to reach |
|
| 53 | - * before being rolled over to backup files. |
|
| 54 | - * |
|
| 55 | - * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
| 56 | - * long integer in the range 0 - 2^63. You can specify the value |
|
| 57 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 58 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
| 59 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 60 | - * as 10240.</p> |
|
| 61 | - * <p>The default maximum file size is 10MB.</p> |
|
| 62 | - * |
|
| 63 | - * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
| 64 | - * |
|
| 65 | - * @var integer |
|
| 66 | - */ |
|
| 67 | - private $maxFileSize = 10485760; |
|
| 51 | + /** |
|
| 52 | + * Set the maximum size that the output file is allowed to reach |
|
| 53 | + * before being rolled over to backup files. |
|
| 54 | + * |
|
| 55 | + * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
| 56 | + * long integer in the range 0 - 2^63. You can specify the value |
|
| 57 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 58 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
| 59 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 60 | + * as 10240.</p> |
|
| 61 | + * <p>The default maximum file size is 10MB.</p> |
|
| 62 | + * |
|
| 63 | + * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
| 64 | + * |
|
| 65 | + * @var integer |
|
| 66 | + */ |
|
| 67 | + private $maxFileSize = 10485760; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Set the maximum number of backup files to keep around. |
|
| 71 | - * |
|
| 72 | - * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
| 73 | - * files are kept before the oldest is erased. This option takes |
|
| 74 | - * a positive integer value. If set to zero, then there will be no |
|
| 75 | - * backup files and the log file will be truncated when it reaches |
|
| 76 | - * MaxFileSize.</p> |
|
| 77 | - * <p>There is one backup file by default.</p> |
|
| 78 | - * |
|
| 79 | - * @var integer |
|
| 80 | - */ |
|
| 81 | - private $maxBackupIndex = 1; |
|
| 69 | + /** |
|
| 70 | + * Set the maximum number of backup files to keep around. |
|
| 71 | + * |
|
| 72 | + * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
| 73 | + * files are kept before the oldest is erased. This option takes |
|
| 74 | + * a positive integer value. If set to zero, then there will be no |
|
| 75 | + * backup files and the log file will be truncated when it reaches |
|
| 76 | + * MaxFileSize.</p> |
|
| 77 | + * <p>There is one backup file by default.</p> |
|
| 78 | + * |
|
| 79 | + * @var integer |
|
| 80 | + */ |
|
| 81 | + private $maxBackupIndex = 1; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @var string the filename expanded |
|
| 85 | - * @access private |
|
| 86 | - */ |
|
| 87 | - private $expandedFileName = null; |
|
| 83 | + /** |
|
| 84 | + * @var string the filename expanded |
|
| 85 | + * @access private |
|
| 86 | + */ |
|
| 87 | + private $expandedFileName = null; |
|
| 88 | 88 | |
| 89 | - public function __destruct() { |
|
| 90 | - parent::__destruct(); |
|
| 91 | - } |
|
| 89 | + public function __destruct() { |
|
| 90 | + parent::__destruct(); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Returns the value of the MaxBackupIndex option. |
|
| 95 | - * @return integer |
|
| 96 | - */ |
|
| 97 | - private function getExpandedFileName() { |
|
| 98 | - return $this->expandedFileName; |
|
| 99 | - } |
|
| 93 | + /** |
|
| 94 | + * Returns the value of the MaxBackupIndex option. |
|
| 95 | + * @return integer |
|
| 96 | + */ |
|
| 97 | + private function getExpandedFileName() { |
|
| 98 | + return $this->expandedFileName; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Get the maximum size that the output file is allowed to reach |
|
| 103 | - * before being rolled over to backup files. |
|
| 104 | - * @return integer |
|
| 105 | - */ |
|
| 106 | - private function getMaximumFileSize() { |
|
| 107 | - return $this->maxFileSize; |
|
| 108 | - } |
|
| 101 | + /** |
|
| 102 | + * Get the maximum size that the output file is allowed to reach |
|
| 103 | + * before being rolled over to backup files. |
|
| 104 | + * @return integer |
|
| 105 | + */ |
|
| 106 | + private function getMaximumFileSize() { |
|
| 107 | + return $this->maxFileSize; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Implements the usual roll over behaviour. |
|
| 112 | - * |
|
| 113 | - * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
| 114 | - * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
| 115 | - * |
|
| 116 | - * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
| 117 | - */ |
|
| 118 | - private function rollOver() { |
|
| 119 | - // If maxBackups <= 0, then there is no file renaming to be done. |
|
| 120 | - if($this->maxBackupIndex > 0) { |
|
| 121 | - $fileName = $this->getExpandedFileName(); |
|
| 122 | - // Delete the oldest file, to keep Windows happy. |
|
| 123 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 124 | - if(is_writable($file)) |
|
| 125 | - unlink($file); |
|
| 126 | - // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
| 127 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 128 | - $file = $fileName . "." . $i; |
|
| 129 | - if(is_readable($file)) { |
|
| 130 | - $target = $fileName . '.' . ($i + 1); |
|
| 131 | - rename($file, $target); |
|
| 132 | - } |
|
| 133 | - } |
|
| 110 | + /** |
|
| 111 | + * Implements the usual roll over behaviour. |
|
| 112 | + * |
|
| 113 | + * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
| 114 | + * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
| 115 | + * |
|
| 116 | + * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
| 117 | + */ |
|
| 118 | + private function rollOver() { |
|
| 119 | + // If maxBackups <= 0, then there is no file renaming to be done. |
|
| 120 | + if($this->maxBackupIndex > 0) { |
|
| 121 | + $fileName = $this->getExpandedFileName(); |
|
| 122 | + // Delete the oldest file, to keep Windows happy. |
|
| 123 | + $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 124 | + if(is_writable($file)) |
|
| 125 | + unlink($file); |
|
| 126 | + // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
| 127 | + for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 128 | + $file = $fileName . "." . $i; |
|
| 129 | + if(is_readable($file)) { |
|
| 130 | + $target = $fileName . '.' . ($i + 1); |
|
| 131 | + rename($file, $target); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - $this->close(); |
|
| 135 | + $this->close(); |
|
| 136 | 136 | |
| 137 | - // Rename fileName to fileName.1 |
|
| 138 | - $target = $fileName . ".1"; |
|
| 139 | - $file = $fileName; |
|
| 140 | - rename($file, $target); |
|
| 141 | - } |
|
| 137 | + // Rename fileName to fileName.1 |
|
| 138 | + $target = $fileName . ".1"; |
|
| 139 | + $file = $fileName; |
|
| 140 | + rename($file, $target); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - //unset($this->fp); |
|
| 144 | - $this->activateOptions(); |
|
| 145 | - $this->setFile($fileName, false); |
|
| 146 | - } |
|
| 143 | + //unset($this->fp); |
|
| 144 | + $this->activateOptions(); |
|
| 145 | + $this->setFile($fileName, false); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - public function setFileName($fileName) { |
|
| 149 | - $this->fileName = $fileName; |
|
| 150 | - // As LoggerAppenderFile does not create the directory, it has to exist. |
|
| 151 | - // realpath() fails if the argument does not exist so the filename is separated. |
|
| 152 | - $this->expandedFileName = realpath(dirname($fileName)); |
|
| 153 | - if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
| 154 | - $this->expandedFileName .= '/'.basename($fileName); |
|
| 155 | - } |
|
| 148 | + public function setFileName($fileName) { |
|
| 149 | + $this->fileName = $fileName; |
|
| 150 | + // As LoggerAppenderFile does not create the directory, it has to exist. |
|
| 151 | + // realpath() fails if the argument does not exist so the filename is separated. |
|
| 152 | + $this->expandedFileName = realpath(dirname($fileName)); |
|
| 153 | + if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
| 154 | + $this->expandedFileName .= '/'.basename($fileName); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Set the maximum number of backup files to keep around. |
|
| 160 | - * |
|
| 161 | - * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
| 162 | - * files are kept before the oldest is erased. This option takes |
|
| 163 | - * a positive integer value. If set to zero, then there will be no |
|
| 164 | - * backup files and the log file will be truncated when it reaches |
|
| 165 | - * MaxFileSize. |
|
| 166 | - * |
|
| 167 | - * @param mixed $maxBackups |
|
| 168 | - */ |
|
| 169 | - public function setMaxBackupIndex($maxBackups) { |
|
| 170 | - if(is_numeric($maxBackups)) { |
|
| 171 | - $this->maxBackupIndex = abs((int)$maxBackups); |
|
| 172 | - } |
|
| 173 | - } |
|
| 158 | + /** |
|
| 159 | + * Set the maximum number of backup files to keep around. |
|
| 160 | + * |
|
| 161 | + * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
| 162 | + * files are kept before the oldest is erased. This option takes |
|
| 163 | + * a positive integer value. If set to zero, then there will be no |
|
| 164 | + * backup files and the log file will be truncated when it reaches |
|
| 165 | + * MaxFileSize. |
|
| 166 | + * |
|
| 167 | + * @param mixed $maxBackups |
|
| 168 | + */ |
|
| 169 | + public function setMaxBackupIndex($maxBackups) { |
|
| 170 | + if(is_numeric($maxBackups)) { |
|
| 171 | + $this->maxBackupIndex = abs((int)$maxBackups); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Set the maximum size that the output file is allowed to reach |
|
| 177 | - * before being rolled over to backup files. |
|
| 178 | - * |
|
| 179 | - * @param mixed $maxFileSize |
|
| 180 | - * @see setMaxFileSize() |
|
| 181 | - * @deprecated |
|
| 182 | - */ |
|
| 183 | - public function setMaximumFileSize($maxFileSize) { |
|
| 184 | - return $this->setMaxFileSize($maxFileSize); |
|
| 185 | - } |
|
| 175 | + /** |
|
| 176 | + * Set the maximum size that the output file is allowed to reach |
|
| 177 | + * before being rolled over to backup files. |
|
| 178 | + * |
|
| 179 | + * @param mixed $maxFileSize |
|
| 180 | + * @see setMaxFileSize() |
|
| 181 | + * @deprecated |
|
| 182 | + */ |
|
| 183 | + public function setMaximumFileSize($maxFileSize) { |
|
| 184 | + return $this->setMaxFileSize($maxFileSize); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * Set the maximum size that the output file is allowed to reach |
|
| 189 | - * before being rolled over to backup files. |
|
| 190 | - * <p>In configuration files, the <b>MaxFileSize</b> option takes an |
|
| 191 | - * long integer in the range 0 - 2^63. You can specify the value |
|
| 192 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 193 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
| 194 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 195 | - * as 10240. |
|
| 196 | - * |
|
| 197 | - * @param mixed $value |
|
| 198 | - * @return the actual file size set |
|
| 199 | - */ |
|
| 200 | - public function setMaxFileSize($value) { |
|
| 201 | - $maxFileSize = null; |
|
| 202 | - $numpart = substr($value,0, strlen($value) -2); |
|
| 203 | - $suffix = strtoupper(substr($value, -2)); |
|
| 187 | + /** |
|
| 188 | + * Set the maximum size that the output file is allowed to reach |
|
| 189 | + * before being rolled over to backup files. |
|
| 190 | + * <p>In configuration files, the <b>MaxFileSize</b> option takes an |
|
| 191 | + * long integer in the range 0 - 2^63. You can specify the value |
|
| 192 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 193 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
| 194 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 195 | + * as 10240. |
|
| 196 | + * |
|
| 197 | + * @param mixed $value |
|
| 198 | + * @return the actual file size set |
|
| 199 | + */ |
|
| 200 | + public function setMaxFileSize($value) { |
|
| 201 | + $maxFileSize = null; |
|
| 202 | + $numpart = substr($value,0, strlen($value) -2); |
|
| 203 | + $suffix = strtoupper(substr($value, -2)); |
|
| 204 | 204 | |
| 205 | - switch($suffix) { |
|
| 206 | - case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
| 207 | - case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
| 208 | - case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
| 209 | - default: |
|
| 210 | - if(is_numeric($value)) { |
|
| 211 | - $maxFileSize = (int)$value; |
|
| 212 | - } |
|
| 213 | - } |
|
| 205 | + switch($suffix) { |
|
| 206 | + case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
| 207 | + case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
| 208 | + case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
| 209 | + default: |
|
| 210 | + if(is_numeric($value)) { |
|
| 211 | + $maxFileSize = (int)$value; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if($maxFileSize !== null) { |
|
| 216 | - $this->maxFileSize = abs($maxFileSize); |
|
| 217 | - } |
|
| 218 | - return $this->maxFileSize; |
|
| 219 | - } |
|
| 215 | + if($maxFileSize !== null) { |
|
| 216 | + $this->maxFileSize = abs($maxFileSize); |
|
| 217 | + } |
|
| 218 | + return $this->maxFileSize; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - /** |
|
| 222 | - * @param LoggerLoggingEvent $event |
|
| 223 | - */ |
|
| 224 | - public function append(LoggerLoggingEvent $event) { |
|
| 225 | - parent::append($event); |
|
| 226 | - if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
| 227 | - $this->rollOver(); |
|
| 228 | - } |
|
| 229 | - } |
|
| 221 | + /** |
|
| 222 | + * @param LoggerLoggingEvent $event |
|
| 223 | + */ |
|
| 224 | + public function append(LoggerLoggingEvent $event) { |
|
| 225 | + parent::append($event); |
|
| 226 | + if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
| 227 | + $this->rollOver(); |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | 230 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @var integer |
| 80 | 80 | */ |
| 81 | - private $maxBackupIndex = 1; |
|
| 81 | + private $maxBackupIndex = 1; |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @var string the filename expanded |
@@ -117,17 +117,17 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | private function rollOver() { |
| 119 | 119 | // If maxBackups <= 0, then there is no file renaming to be done. |
| 120 | - if($this->maxBackupIndex > 0) { |
|
| 120 | + if ($this->maxBackupIndex > 0) { |
|
| 121 | 121 | $fileName = $this->getExpandedFileName(); |
| 122 | 122 | // Delete the oldest file, to keep Windows happy. |
| 123 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 124 | - if(is_writable($file)) |
|
| 123 | + $file = $fileName.'.'.$this->maxBackupIndex; |
|
| 124 | + if (is_writable($file)) |
|
| 125 | 125 | unlink($file); |
| 126 | 126 | // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
| 127 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 128 | - $file = $fileName . "." . $i; |
|
| 129 | - if(is_readable($file)) { |
|
| 130 | - $target = $fileName . '.' . ($i + 1); |
|
| 127 | + for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 128 | + $file = $fileName.".".$i; |
|
| 129 | + if (is_readable($file)) { |
|
| 130 | + $target = $fileName.'.'.($i + 1); |
|
| 131 | 131 | rename($file, $target); |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $this->close(); |
| 136 | 136 | |
| 137 | 137 | // Rename fileName to fileName.1 |
| 138 | - $target = $fileName . ".1"; |
|
| 138 | + $target = $fileName.".1"; |
|
| 139 | 139 | $file = $fileName; |
| 140 | 140 | rename($file, $target); |
| 141 | 141 | } |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | * @param mixed $maxBackups |
| 168 | 168 | */ |
| 169 | 169 | public function setMaxBackupIndex($maxBackups) { |
| 170 | - if(is_numeric($maxBackups)) { |
|
| 171 | - $this->maxBackupIndex = abs((int)$maxBackups); |
|
| 170 | + if (is_numeric($maxBackups)) { |
|
| 171 | + $this->maxBackupIndex = abs((int) $maxBackups); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -199,20 +199,20 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | public function setMaxFileSize($value) { |
| 201 | 201 | $maxFileSize = null; |
| 202 | - $numpart = substr($value,0, strlen($value) -2); |
|
| 202 | + $numpart = substr($value, 0, strlen($value) - 2); |
|
| 203 | 203 | $suffix = strtoupper(substr($value, -2)); |
| 204 | 204 | |
| 205 | - switch($suffix) { |
|
| 206 | - case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
| 207 | - case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
| 208 | - case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
| 205 | + switch ($suffix) { |
|
| 206 | + case 'KB': $maxFileSize = (int) ((int) $numpart * 1024); break; |
|
| 207 | + case 'MB': $maxFileSize = (int) ((int) $numpart * 1024 * 1024); break; |
|
| 208 | + case 'GB': $maxFileSize = (int) ((int) $numpart * 1024 * 1024 * 1024); break; |
|
| 209 | 209 | default: |
| 210 | - if(is_numeric($value)) { |
|
| 211 | - $maxFileSize = (int)$value; |
|
| 210 | + if (is_numeric($value)) { |
|
| 211 | + $maxFileSize = (int) $value; |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if($maxFileSize !== null) { |
|
| 215 | + if ($maxFileSize !== null) { |
|
| 216 | 216 | $this->maxFileSize = abs($maxFileSize); |
| 217 | 217 | } |
| 218 | 218 | return $this->maxFileSize; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function append(LoggerLoggingEvent $event) { |
| 225 | 225 | parent::append($event); |
| 226 | - if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
| 226 | + if (ftell($this->fp) > $this->getMaximumFileSize()) { |
|
| 227 | 227 | $this->rollOver(); |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -121,8 +121,9 @@ discard block |
||
| 121 | 121 | $fileName = $this->getExpandedFileName(); |
| 122 | 122 | // Delete the oldest file, to keep Windows happy. |
| 123 | 123 | $file = $fileName . '.' . $this->maxBackupIndex; |
| 124 | - if(is_writable($file)) |
|
| 125 | - unlink($file); |
|
| 124 | + if(is_writable($file)) { |
|
| 125 | + unlink($file); |
|
| 126 | + } |
|
| 126 | 127 | // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
| 127 | 128 | for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
| 128 | 129 | $file = $fileName . "." . $i; |
@@ -150,7 +151,9 @@ discard block |
||
| 150 | 151 | // As LoggerAppenderFile does not create the directory, it has to exist. |
| 151 | 152 | // realpath() fails if the argument does not exist so the filename is separated. |
| 152 | 153 | $this->expandedFileName = realpath(dirname($fileName)); |
| 153 | - if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
| 154 | + if ($this->expandedFileName === false) { |
|
| 155 | + throw new Exception("Directory of $fileName does not exist!"); |
|
| 156 | + } |
|
| 154 | 157 | $this->expandedFileName .= '/'.basename($fileName); |
| 155 | 158 | } |
| 156 | 159 | |
@@ -225,6 +225,7 @@ |
||
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * @param mixed |
| 228 | + * @param boolean $flag |
|
| 228 | 229 | */ |
| 229 | 230 | public function setUseXml($flag) { |
| 230 | 231 | $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
@@ -46,215 +46,215 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | class LoggerAppenderSocket extends LoggerAppender { |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var mixed socket connection resource |
|
| 51 | - * @access private |
|
| 52 | - */ |
|
| 53 | - private $sp = false; |
|
| 49 | + /** |
|
| 50 | + * @var mixed socket connection resource |
|
| 51 | + * @access private |
|
| 52 | + */ |
|
| 53 | + private $sp = false; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Target host. On how to define remote hostaname see |
|
| 57 | - * {@link PHP_MANUAL#fsockopen} |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 60 | - private $remoteHost = ''; |
|
| 55 | + /** |
|
| 56 | + * Target host. On how to define remote hostaname see |
|
| 57 | + * {@link PHP_MANUAL#fsockopen} |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | + private $remoteHost = ''; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @var integer the network port. |
|
| 64 | - */ |
|
| 65 | - private $port = 4446; |
|
| 62 | + /** |
|
| 63 | + * @var integer the network port. |
|
| 64 | + */ |
|
| 65 | + private $port = 4446; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @var boolean get event's location info. |
|
| 69 | - */ |
|
| 70 | - private $locationInfo = false; |
|
| 67 | + /** |
|
| 68 | + * @var boolean get event's location info. |
|
| 69 | + */ |
|
| 70 | + private $locationInfo = false; |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @var integer connection timeout |
|
| 74 | - */ |
|
| 75 | - private $timeout = 30; |
|
| 72 | + /** |
|
| 73 | + * @var integer connection timeout |
|
| 74 | + */ |
|
| 75 | + private $timeout = 30; |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @var boolean output events via {@link LoggerXmlLayout} |
|
| 79 | - */ |
|
| 80 | - private $useXml = false; |
|
| 77 | + /** |
|
| 78 | + * @var boolean output events via {@link LoggerXmlLayout} |
|
| 79 | + */ |
|
| 80 | + private $useXml = false; |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @var boolean forward this option to {@link LoggerXmlLayout}. |
|
| 84 | - * Ignored if {@link $useXml} is <i>false</i>. |
|
| 85 | - */ |
|
| 86 | - private $log4jNamespace = false; |
|
| 82 | + /** |
|
| 83 | + * @var boolean forward this option to {@link LoggerXmlLayout}. |
|
| 84 | + * Ignored if {@link $useXml} is <i>false</i>. |
|
| 85 | + */ |
|
| 86 | + private $log4jNamespace = false; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @var LoggerXmlLayout |
|
| 90 | - * @access private |
|
| 91 | - */ |
|
| 92 | - private $xmlLayout = null; |
|
| 88 | + /** |
|
| 89 | + * @var LoggerXmlLayout |
|
| 90 | + * @access private |
|
| 91 | + */ |
|
| 92 | + private $xmlLayout = null; |
|
| 93 | 93 | |
| 94 | - /** @var indiciates if this appender should run in dry mode */ |
|
| 95 | - private $dry = false; |
|
| 94 | + /** @var indiciates if this appender should run in dry mode */ |
|
| 95 | + private $dry = false; |
|
| 96 | 96 | |
| 97 | - public function __destruct() { |
|
| 98 | - $this->close(); |
|
| 99 | - } |
|
| 97 | + public function __destruct() { |
|
| 98 | + $this->close(); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Create a socket connection using defined parameters |
|
| 103 | - */ |
|
| 104 | - public function activateOptions() { |
|
| 105 | - if(!$this->dry) { |
|
| 106 | - $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
|
| 107 | - if ($this->sp === false) { |
|
| 108 | - throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - if($this->getUseXml()) { |
|
| 112 | - $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
|
| 113 | - if($this->xmlLayout === null) { |
|
| 114 | - $this->setUseXml(false); |
|
| 115 | - } else { |
|
| 116 | - $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
|
| 117 | - $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace()); |
|
| 118 | - $this->xmlLayout->activateOptions(); |
|
| 119 | - } |
|
| 120 | - } |
|
| 101 | + /** |
|
| 102 | + * Create a socket connection using defined parameters |
|
| 103 | + */ |
|
| 104 | + public function activateOptions() { |
|
| 105 | + if(!$this->dry) { |
|
| 106 | + $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
|
| 107 | + if ($this->sp === false) { |
|
| 108 | + throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + if($this->getUseXml()) { |
|
| 112 | + $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
|
| 113 | + if($this->xmlLayout === null) { |
|
| 114 | + $this->setUseXml(false); |
|
| 115 | + } else { |
|
| 116 | + $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
|
| 117 | + $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace()); |
|
| 118 | + $this->xmlLayout->activateOptions(); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | 121 | $this->closed = false; |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - public function close() { |
|
| 125 | - if($this->closed != true) { |
|
| 126 | - if(!$this->dry and $this->sp !== false) { |
|
| 127 | - fclose($this->sp); |
|
| 128 | - } |
|
| 129 | - $this->closed = true; |
|
| 130 | - } |
|
| 131 | - } |
|
| 124 | + public function close() { |
|
| 125 | + if($this->closed != true) { |
|
| 126 | + if(!$this->dry and $this->sp !== false) { |
|
| 127 | + fclose($this->sp); |
|
| 128 | + } |
|
| 129 | + $this->closed = true; |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - public function setDry($dry) { |
|
| 134 | - $this->dry = $dry; |
|
| 135 | - } |
|
| 133 | + public function setDry($dry) { |
|
| 134 | + $this->dry = $dry; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * @return string |
|
| 139 | - */ |
|
| 140 | - public function getHostname() { |
|
| 141 | - return $this->getRemoteHost(); |
|
| 142 | - } |
|
| 137 | + /** |
|
| 138 | + * @return string |
|
| 139 | + */ |
|
| 140 | + public function getHostname() { |
|
| 141 | + return $this->getRemoteHost(); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * @return boolean |
|
| 146 | - */ |
|
| 147 | - public function getLocationInfo() { |
|
| 148 | - return $this->locationInfo; |
|
| 149 | - } |
|
| 144 | + /** |
|
| 145 | + * @return boolean |
|
| 146 | + */ |
|
| 147 | + public function getLocationInfo() { |
|
| 148 | + return $this->locationInfo; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * @return boolean |
|
| 153 | - */ |
|
| 154 | - public function getLog4jNamespace() { |
|
| 155 | - return $this->log4jNamespace; |
|
| 156 | - } |
|
| 151 | + /** |
|
| 152 | + * @return boolean |
|
| 153 | + */ |
|
| 154 | + public function getLog4jNamespace() { |
|
| 155 | + return $this->log4jNamespace; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * @return integer |
|
| 160 | - */ |
|
| 161 | - public function getPort() { |
|
| 162 | - return $this->port; |
|
| 163 | - } |
|
| 158 | + /** |
|
| 159 | + * @return integer |
|
| 160 | + */ |
|
| 161 | + public function getPort() { |
|
| 162 | + return $this->port; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - public function getRemoteHost() { |
|
| 166 | - return $this->remoteHost; |
|
| 167 | - } |
|
| 165 | + public function getRemoteHost() { |
|
| 166 | + return $this->remoteHost; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * @return integer |
|
| 171 | - */ |
|
| 172 | - public function getTimeout() { |
|
| 173 | - return $this->timeout; |
|
| 174 | - } |
|
| 169 | + /** |
|
| 170 | + * @return integer |
|
| 171 | + */ |
|
| 172 | + public function getTimeout() { |
|
| 173 | + return $this->timeout; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * @var boolean |
|
| 178 | - */ |
|
| 179 | - public function getUseXml() { |
|
| 180 | - return $this->useXml; |
|
| 181 | - } |
|
| 176 | + /** |
|
| 177 | + * @var boolean |
|
| 178 | + */ |
|
| 179 | + public function getUseXml() { |
|
| 180 | + return $this->useXml; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - public function reset() { |
|
| 184 | - $this->close(); |
|
| 185 | - parent::reset(); |
|
| 186 | - } |
|
| 183 | + public function reset() { |
|
| 184 | + $this->close(); |
|
| 185 | + parent::reset(); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * @param mixed |
|
| 190 | - */ |
|
| 191 | - public function setLocationInfo($flag) { |
|
| 192 | - $this->locationInfo = LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo()); |
|
| 193 | - } |
|
| 188 | + /** |
|
| 189 | + * @param mixed |
|
| 190 | + */ |
|
| 191 | + public function setLocationInfo($flag) { |
|
| 192 | + $this->locationInfo = LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo()); |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * @param mixed |
|
| 197 | - */ |
|
| 198 | - public function setLog4jNamespace($flag) { |
|
| 199 | - $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace()); |
|
| 200 | - } |
|
| 195 | + /** |
|
| 196 | + * @param mixed |
|
| 197 | + */ |
|
| 198 | + public function setLog4jNamespace($flag) { |
|
| 199 | + $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace()); |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - /** |
|
| 203 | - * @param integer |
|
| 204 | - */ |
|
| 205 | - public function setPort($port) { |
|
| 206 | - $port = LoggerOptionConverter::toInt($port, 0); |
|
| 207 | - if($port > 0 and $port < 65535) { |
|
| 208 | - $this->port = $port; |
|
| 209 | - } |
|
| 210 | - } |
|
| 202 | + /** |
|
| 203 | + * @param integer |
|
| 204 | + */ |
|
| 205 | + public function setPort($port) { |
|
| 206 | + $port = LoggerOptionConverter::toInt($port, 0); |
|
| 207 | + if($port > 0 and $port < 65535) { |
|
| 208 | + $this->port = $port; |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * @param string |
|
| 214 | - */ |
|
| 215 | - public function setRemoteHost($hostname) { |
|
| 216 | - $this->remoteHost = $hostname; |
|
| 217 | - } |
|
| 212 | + /** |
|
| 213 | + * @param string |
|
| 214 | + */ |
|
| 215 | + public function setRemoteHost($hostname) { |
|
| 216 | + $this->remoteHost = $hostname; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * @param integer |
|
| 221 | - */ |
|
| 222 | - public function setTimeout($timeout) { |
|
| 223 | - $this->timeout = LoggerOptionConverter::toInt($timeout, $this->getTimeout()); |
|
| 224 | - } |
|
| 219 | + /** |
|
| 220 | + * @param integer |
|
| 221 | + */ |
|
| 222 | + public function setTimeout($timeout) { |
|
| 223 | + $this->timeout = LoggerOptionConverter::toInt($timeout, $this->getTimeout()); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * @param mixed |
|
| 228 | - */ |
|
| 229 | - public function setUseXml($flag) { |
|
| 230 | - $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
|
| 231 | - } |
|
| 226 | + /** |
|
| 227 | + * @param mixed |
|
| 228 | + */ |
|
| 229 | + public function setUseXml($flag) { |
|
| 230 | + $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - public function append(LoggerLoggingEvent $event) { |
|
| 234 | - if($this->sp || $this->dry) { |
|
| 235 | - if($this->getLocationInfo()) { |
|
| 236 | - $event->getLocationInformation(); |
|
| 237 | - } |
|
| 233 | + public function append(LoggerLoggingEvent $event) { |
|
| 234 | + if($this->sp || $this->dry) { |
|
| 235 | + if($this->getLocationInfo()) { |
|
| 236 | + $event->getLocationInformation(); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - if(!$this->getUseXml()) { |
|
| 240 | - $sEvent = serialize($event); |
|
| 241 | - if(!$this->dry) { |
|
| 242 | - fwrite($this->sp, $sEvent, strlen($sEvent)); |
|
| 243 | - } else { |
|
| 244 | - echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
|
| 245 | - } |
|
| 246 | - } else { |
|
| 247 | - if(!$this->dry) { |
|
| 248 | - fwrite($this->sp, $this->xmlLayout->format($event)); |
|
| 249 | - } else { |
|
| 250 | - echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
|
| 251 | - } |
|
| 252 | - } |
|
| 239 | + if(!$this->getUseXml()) { |
|
| 240 | + $sEvent = serialize($event); |
|
| 241 | + if(!$this->dry) { |
|
| 242 | + fwrite($this->sp, $sEvent, strlen($sEvent)); |
|
| 243 | + } else { |
|
| 244 | + echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
|
| 245 | + } |
|
| 246 | + } else { |
|
| 247 | + if(!$this->dry) { |
|
| 248 | + fwrite($this->sp, $this->xmlLayout->format($event)); |
|
| 249 | + } else { |
|
| 250 | + echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - // not sure about it... |
|
| 255 | - if(!$this->dry) { |
|
| 256 | - fflush($this->sp); |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 254 | + // not sure about it... |
|
| 255 | + if(!$this->dry) { |
|
| 256 | + fflush($this->sp); |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | } |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | * Create a socket connection using defined parameters |
| 103 | 103 | */ |
| 104 | 104 | public function activateOptions() { |
| 105 | - if(!$this->dry) { |
|
| 105 | + if (!$this->dry) { |
|
| 106 | 106 | $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
| 107 | 107 | if ($this->sp === false) { |
| 108 | 108 | throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | - if($this->getUseXml()) { |
|
| 111 | + if ($this->getUseXml()) { |
|
| 112 | 112 | $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
| 113 | - if($this->xmlLayout === null) { |
|
| 113 | + if ($this->xmlLayout === null) { |
|
| 114 | 114 | $this->setUseXml(false); |
| 115 | 115 | } else { |
| 116 | 116 | $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public function close() { |
| 125 | - if($this->closed != true) { |
|
| 126 | - if(!$this->dry and $this->sp !== false) { |
|
| 125 | + if ($this->closed != true) { |
|
| 126 | + if (!$this->dry and $this->sp !== false) { |
|
| 127 | 127 | fclose($this->sp); |
| 128 | 128 | } |
| 129 | 129 | $this->closed = true; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function setPort($port) { |
| 206 | 206 | $port = LoggerOptionConverter::toInt($port, 0); |
| 207 | - if($port > 0 and $port < 65535) { |
|
| 207 | + if ($port > 0 and $port < 65535) { |
|
| 208 | 208 | $this->port = $port; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -231,20 +231,20 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | public function append(LoggerLoggingEvent $event) { |
| 234 | - if($this->sp || $this->dry) { |
|
| 235 | - if($this->getLocationInfo()) { |
|
| 234 | + if ($this->sp || $this->dry) { |
|
| 235 | + if ($this->getLocationInfo()) { |
|
| 236 | 236 | $event->getLocationInformation(); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - if(!$this->getUseXml()) { |
|
| 239 | + if (!$this->getUseXml()) { |
|
| 240 | 240 | $sEvent = serialize($event); |
| 241 | - if(!$this->dry) { |
|
| 241 | + if (!$this->dry) { |
|
| 242 | 242 | fwrite($this->sp, $sEvent, strlen($sEvent)); |
| 243 | 243 | } else { |
| 244 | 244 | echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
| 245 | 245 | } |
| 246 | 246 | } else { |
| 247 | - if(!$this->dry) { |
|
| 247 | + if (!$this->dry) { |
|
| 248 | 248 | fwrite($this->sp, $this->xmlLayout->format($event)); |
| 249 | 249 | } else { |
| 250 | 250 | echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // not sure about it... |
| 255 | - if(!$this->dry) { |
|
| 255 | + if (!$this->dry) { |
|
| 256 | 256 | fflush($this->sp); |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -279,7 +279,6 @@ |
||
| 279 | 279 | * |
| 280 | 280 | * @param string $url The name of the configuration file where the |
| 281 | 281 | * configuration information is stored. |
| 282 | - * @param LoggerHierarchy $repository the repository to apply the configuration |
|
| 283 | 282 | */ |
| 284 | 283 | public function configure(LoggerHierarchy $hierarchy, $url = '') { |
| 285 | 284 | $properties = @parse_ini_file($url); |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | - * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | - * this work for additional information regarding copyright ownership. |
|
| 6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | - * (the "License"); you may not use this file except in compliance with |
|
| 8 | - * the License. You may obtain a copy of the License at |
|
| 9 | - * |
|
| 10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | - * |
|
| 12 | - * Unless required by applicable law or agreed to in writing, software |
|
| 13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | - * See the License for the specific language governing permissions and |
|
| 16 | - * limitations under the License. |
|
| 17 | - * |
|
| 18 | - * @package log4php |
|
| 19 | - */ |
|
| 3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | + * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | + * this work for additional information regarding copyright ownership. |
|
| 6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | + * (the "License"); you may not use this file except in compliance with |
|
| 8 | + * the License. You may obtain a copy of the License at |
|
| 9 | + * |
|
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | + * |
|
| 12 | + * Unless required by applicable law or agreed to in writing, software |
|
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | + * See the License for the specific language governing permissions and |
|
| 16 | + * limitations under the License. |
|
| 17 | + * |
|
| 18 | + * @package log4php |
|
| 19 | + */ |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Allows the configuration of log4php from an external file. |
@@ -63,401 +63,401 @@ discard block |
||
| 63 | 63 | * @since 0.5 |
| 64 | 64 | */ |
| 65 | 65 | class LoggerConfiguratorIni implements LoggerConfigurator { |
| 66 | - const CATEGORY_PREFIX = "log4php.category."; |
|
| 67 | - const LOGGER_PREFIX = "log4php.logger."; |
|
| 68 | - const FACTORY_PREFIX = "log4php.factory"; |
|
| 69 | - const ADDITIVITY_PREFIX = "log4php.additivity."; |
|
| 70 | - const ROOT_CATEGORY_PREFIX = "log4php.rootCategory"; |
|
| 71 | - const ROOT_LOGGER_PREFIX = "log4php.rootLogger"; |
|
| 72 | - const APPENDER_PREFIX = "log4php.appender."; |
|
| 73 | - const RENDERER_PREFIX = "log4php.renderer."; |
|
| 74 | - const THRESHOLD_PREFIX = "log4php.threshold"; |
|
| 66 | + const CATEGORY_PREFIX = "log4php.category."; |
|
| 67 | + const LOGGER_PREFIX = "log4php.logger."; |
|
| 68 | + const FACTORY_PREFIX = "log4php.factory"; |
|
| 69 | + const ADDITIVITY_PREFIX = "log4php.additivity."; |
|
| 70 | + const ROOT_CATEGORY_PREFIX = "log4php.rootCategory"; |
|
| 71 | + const ROOT_LOGGER_PREFIX = "log4php.rootLogger"; |
|
| 72 | + const APPENDER_PREFIX = "log4php.appender."; |
|
| 73 | + const RENDERER_PREFIX = "log4php.renderer."; |
|
| 74 | + const THRESHOLD_PREFIX = "log4php.threshold"; |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Key for specifying the {@link LoggerFactory}. |
|
| 78 | - */ |
|
| 79 | - const LOGGER_FACTORY_KEY = "log4php.loggerFactory"; |
|
| 80 | - const LOGGER_DEBUG_KEY = "log4php.debug"; |
|
| 81 | - const INTERNAL_ROOT_NAME = "root"; |
|
| 76 | + /** |
|
| 77 | + * Key for specifying the {@link LoggerFactory}. |
|
| 78 | + */ |
|
| 79 | + const LOGGER_FACTORY_KEY = "log4php.loggerFactory"; |
|
| 80 | + const LOGGER_DEBUG_KEY = "log4php.debug"; |
|
| 81 | + const INTERNAL_ROOT_NAME = "root"; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Constructor |
|
| 85 | - */ |
|
| 86 | - public function __construct() { |
|
| 87 | - } |
|
| 83 | + /** |
|
| 84 | + * Constructor |
|
| 85 | + */ |
|
| 86 | + public function __construct() { |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Read configuration from a file. |
|
| 91 | - * |
|
| 92 | - * <p>The function {@link PHP_MANUAL#parse_ini_file} is used to read the |
|
| 93 | - * file.</p> |
|
| 94 | - * |
|
| 95 | - * <b>The existing configuration is not cleared nor reset.</b> |
|
| 96 | - * If you require a different behavior, then call |
|
| 97 | - * {@link Logger::resetConfiguration()} |
|
| 98 | - * method before calling {@link doConfigure()}. |
|
| 99 | - * |
|
| 100 | - * <p>The configuration file consists of statements in the format |
|
| 101 | - * <b>key=value</b>. The syntax of different configuration |
|
| 102 | - * elements are discussed below. |
|
| 103 | - * |
|
| 104 | - * <p><b>Repository-wide threshold</b></p> |
|
| 105 | - * |
|
| 106 | - * <p>The repository-wide threshold filters logging requests by level |
|
| 107 | - * regardless of logger. The syntax is: |
|
| 108 | - * |
|
| 109 | - * <pre> |
|
| 110 | - * log4php.threshold=[level] |
|
| 111 | - * </pre> |
|
| 112 | - * |
|
| 113 | - * <p>The level value can consist of the string values OFF, FATAL, |
|
| 114 | - * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A |
|
| 115 | - * custom level value can be specified in the form |
|
| 116 | - * <samp>level#classname</samp>. By default the repository-wide threshold is set |
|
| 117 | - * to the lowest possible value, namely the level <b>ALL</b>. |
|
| 118 | - * </p> |
|
| 119 | - * |
|
| 120 | - * |
|
| 121 | - * <p><b>Appender configuration</b></p> |
|
| 122 | - * |
|
| 123 | - * <p>Appender configuration syntax is:</p> |
|
| 124 | - * <pre> |
|
| 125 | - * ; For appender named <i>appenderName</i>, set its class. |
|
| 126 | - * ; Note: The appender name can contain dots. |
|
| 127 | - * log4php.appender.appenderName=name_of_appender_class |
|
| 128 | - * |
|
| 129 | - * ; Set appender specific options. |
|
| 130 | - * |
|
| 131 | - * log4php.appender.appenderName.option1=value1 |
|
| 132 | - * log4php.appender.appenderName.optionN=valueN |
|
| 133 | - * </pre> |
|
| 134 | - * |
|
| 135 | - * For each named appender you can configure its {@link LoggerLayout}. The |
|
| 136 | - * syntax for configuring an appender's layout is: |
|
| 137 | - * <pre> |
|
| 138 | - * log4php.appender.appenderName.layout=name_of_layout_class |
|
| 139 | - * log4php.appender.appenderName.layout.option1=value1 |
|
| 140 | - * .... |
|
| 141 | - * log4php.appender.appenderName.layout.optionN=valueN |
|
| 142 | - * </pre> |
|
| 143 | - * |
|
| 144 | - * <p><b>Configuring loggers</b></p> |
|
| 145 | - * |
|
| 146 | - * <p>The syntax for configuring the root logger is: |
|
| 147 | - * <pre> |
|
| 148 | - * log4php.rootLogger=[level], appenderName, appenderName, ... |
|
| 149 | - * </pre> |
|
| 150 | - * |
|
| 151 | - * <p>This syntax means that an optional <i>level</i> can be |
|
| 152 | - * supplied followed by appender names separated by commas. |
|
| 153 | - * |
|
| 154 | - * <p>The level value can consist of the string values OFF, FATAL, |
|
| 155 | - * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A |
|
| 156 | - * custom level value can be specified in the form</p> |
|
| 157 | - * |
|
| 158 | - * <pre>level#classname</pre> |
|
| 159 | - * |
|
| 160 | - * <p>If a level value is specified, then the root level is set |
|
| 161 | - * to the corresponding level. If no level value is specified, |
|
| 162 | - * then the root level remains untouched. |
|
| 163 | - * |
|
| 164 | - * <p>The root logger can be assigned multiple appenders. |
|
| 165 | - * |
|
| 166 | - * <p>Each <i>appenderName</i> (separated by commas) will be added to |
|
| 167 | - * the root logger. The named appender is defined using the |
|
| 168 | - * appender syntax defined above. |
|
| 169 | - * |
|
| 170 | - * <p>For non-root categories the syntax is almost the same: |
|
| 171 | - * <pre> |
|
| 172 | - * log4php.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ... |
|
| 173 | - * </pre> |
|
| 174 | - * |
|
| 175 | - * <p>The meaning of the optional level value is discussed above |
|
| 176 | - * in relation to the root logger. In addition however, the value |
|
| 177 | - * INHERITED can be specified meaning that the named logger should |
|
| 178 | - * inherit its level from the logger hierarchy.</p> |
|
| 179 | - * |
|
| 180 | - * <p>If no level value is supplied, then the level of the |
|
| 181 | - * named logger remains untouched.</p> |
|
| 182 | - * |
|
| 183 | - * <p>By default categories inherit their level from the |
|
| 184 | - * hierarchy. However, if you set the level of a logger and later |
|
| 185 | - * decide that that logger should inherit its level, then you should |
|
| 186 | - * specify INHERITED as the value for the level value. NULL is a |
|
| 187 | - * synonym for INHERITED.</p> |
|
| 188 | - * |
|
| 189 | - * <p>Similar to the root logger syntax, each <i>appenderName</i> |
|
| 190 | - * (separated by commas) will be attached to the named logger.</p> |
|
| 191 | - * |
|
| 192 | - * <p>See the <i>appender additivity rule</i> in the user manual for |
|
| 193 | - * the meaning of the <b>additivity</b> flag. |
|
| 194 | - * |
|
| 195 | - * <p><b>ObjectRenderers</b></p> |
|
| 196 | - * |
|
| 197 | - * <p>You can customize the way message objects of a given type are |
|
| 198 | - * converted to String before being logged. This is done by |
|
| 199 | - * specifying a {@link LoggerRendererObject} |
|
| 200 | - * for the object type would like to customize.</p> |
|
| 201 | - * |
|
| 202 | - * <p>The syntax is: |
|
| 203 | - * |
|
| 204 | - * <pre> |
|
| 205 | - * log4php.renderer.name_of_rendered_class=name_of_rendering.class |
|
| 206 | - * </pre> |
|
| 207 | - * |
|
| 208 | - * As in, |
|
| 209 | - * <pre> |
|
| 210 | - * log4php.renderer.myFruit=myFruitRenderer |
|
| 211 | - * </pre> |
|
| 212 | - * |
|
| 213 | - * <p><b>Logger Factories</b></p> |
|
| 214 | - * |
|
| 215 | - * The usage of custom logger factories is discouraged and no longer |
|
| 216 | - * documented. |
|
| 217 | - * |
|
| 218 | - * <p><b>Example</b></p> |
|
| 219 | - * |
|
| 220 | - * <p>An example configuration is given below. Other configuration |
|
| 221 | - * file examples are given in the <b>tests</b> folder. |
|
| 222 | - * |
|
| 223 | - * <pre> |
|
| 224 | - * ; Set options for appender named "A1". |
|
| 225 | - * ; Appender "A1" will be a LoggerAppenderSyslog |
|
| 226 | - * log4php.appender.A1=LoggerAppenderSyslog |
|
| 227 | - * |
|
| 228 | - * ; The syslog daemon resides on www.abc.net |
|
| 229 | - * log4php.appender.A1.ident=log4php-test |
|
| 230 | - * |
|
| 231 | - * ; A1's layout is a LoggerPatternLayout, using the conversion pattern |
|
| 232 | - * ; <b>%r %-5p %c{2} %M.%L %x - %m%n</b>. Thus, the log output will |
|
| 233 | - * ; include the relative time since the start of the application in |
|
| 234 | - * ; milliseconds, followed by the level of the log request, |
|
| 235 | - * ; followed by the two rightmost components of the logger name, |
|
| 236 | - * ; followed by the callers method name, followed by the line number, |
|
| 237 | - * ; the nested disgnostic context and finally the message itself. |
|
| 238 | - * ; Refer to the documentation of LoggerPatternLayout} for further information |
|
| 239 | - * ; on the syntax of the ConversionPattern key. |
|
| 240 | - * log4php.appender.A1.layout=LoggerPatternLayout |
|
| 241 | - * log4php.appender.A1.layout.ConversionPattern="%-4r %-5p %c{2} %M.%L %x - %m%n" |
|
| 242 | - * |
|
| 243 | - * ; Set options for appender named "A2" |
|
| 244 | - * ; A2 should be a LoggerAppenderRollingFile, with maximum file size of 10 MB |
|
| 245 | - * ; using at most one backup file. A2's layout is TTCC, using the |
|
| 246 | - * ; ISO8061 date format with context printing enabled. |
|
| 247 | - * log4php.appender.A2=LoggerAppenderRollingFile |
|
| 248 | - * log4php.appender.A2.MaxFileSize=10MB |
|
| 249 | - * log4php.appender.A2.MaxBackupIndex=1 |
|
| 250 | - * log4php.appender.A2.layout=LoggerLayoutTTCC |
|
| 251 | - * log4php.appender.A2.layout.ContextPrinting="true" |
|
| 252 | - * log4php.appender.A2.layout.DateFormat="%c" |
|
| 253 | - * |
|
| 254 | - * ; Root logger set to DEBUG using the A2 appender defined above. |
|
| 255 | - * log4php.rootLogger=DEBUG, A2 |
|
| 256 | - * |
|
| 257 | - * ; Logger definitions: |
|
| 258 | - * ; The SECURITY logger inherits is level from root. However, it's output |
|
| 259 | - * ; will go to A1 appender defined above. It's additivity is non-cumulative. |
|
| 260 | - * log4php.logger.SECURITY=INHERIT, A1 |
|
| 261 | - * log4php.additivity.SECURITY=false |
|
| 262 | - * |
|
| 263 | - * ; Only warnings or above will be logged for the logger "SECURITY.access". |
|
| 264 | - * ; Output will go to A1. |
|
| 265 | - * log4php.logger.SECURITY.access=WARN |
|
| 266 | - * |
|
| 267 | - * |
|
| 268 | - * ; The logger "class.of.the.day" inherits its level from the |
|
| 269 | - * ; logger hierarchy. Output will go to the appender's of the root |
|
| 270 | - * ; logger, A2 in this case. |
|
| 271 | - * log4php.logger.class.of.the.day=INHERIT |
|
| 272 | - * </pre> |
|
| 273 | - * |
|
| 274 | - * <p>Refer to the <b>setOption</b> method in each Appender and |
|
| 275 | - * Layout for class specific options.</p> |
|
| 276 | - * |
|
| 277 | - * <p>Use the <b>";"</b> character at the |
|
| 278 | - * beginning of a line for comments.</p> |
|
| 279 | - * |
|
| 280 | - * @param string $url The name of the configuration file where the |
|
| 281 | - * configuration information is stored. |
|
| 282 | - * @param LoggerHierarchy $repository the repository to apply the configuration |
|
| 283 | - */ |
|
| 284 | - public function configure(LoggerHierarchy $hierarchy, $url = '') { |
|
| 285 | - $properties = @parse_ini_file($url); |
|
| 286 | - if ($properties === false || count($properties) == 0) { |
|
| 287 | - $error = error_get_last(); |
|
| 288 | - throw new LoggerException("LoggerConfiguratorIni: ".$error['message']); |
|
| 289 | - } |
|
| 290 | - return $this->doConfigureProperties($properties, $hierarchy); |
|
| 291 | - } |
|
| 89 | + /** |
|
| 90 | + * Read configuration from a file. |
|
| 91 | + * |
|
| 92 | + * <p>The function {@link PHP_MANUAL#parse_ini_file} is used to read the |
|
| 93 | + * file.</p> |
|
| 94 | + * |
|
| 95 | + * <b>The existing configuration is not cleared nor reset.</b> |
|
| 96 | + * If you require a different behavior, then call |
|
| 97 | + * {@link Logger::resetConfiguration()} |
|
| 98 | + * method before calling {@link doConfigure()}. |
|
| 99 | + * |
|
| 100 | + * <p>The configuration file consists of statements in the format |
|
| 101 | + * <b>key=value</b>. The syntax of different configuration |
|
| 102 | + * elements are discussed below. |
|
| 103 | + * |
|
| 104 | + * <p><b>Repository-wide threshold</b></p> |
|
| 105 | + * |
|
| 106 | + * <p>The repository-wide threshold filters logging requests by level |
|
| 107 | + * regardless of logger. The syntax is: |
|
| 108 | + * |
|
| 109 | + * <pre> |
|
| 110 | + * log4php.threshold=[level] |
|
| 111 | + * </pre> |
|
| 112 | + * |
|
| 113 | + * <p>The level value can consist of the string values OFF, FATAL, |
|
| 114 | + * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A |
|
| 115 | + * custom level value can be specified in the form |
|
| 116 | + * <samp>level#classname</samp>. By default the repository-wide threshold is set |
|
| 117 | + * to the lowest possible value, namely the level <b>ALL</b>. |
|
| 118 | + * </p> |
|
| 119 | + * |
|
| 120 | + * |
|
| 121 | + * <p><b>Appender configuration</b></p> |
|
| 122 | + * |
|
| 123 | + * <p>Appender configuration syntax is:</p> |
|
| 124 | + * <pre> |
|
| 125 | + * ; For appender named <i>appenderName</i>, set its class. |
|
| 126 | + * ; Note: The appender name can contain dots. |
|
| 127 | + * log4php.appender.appenderName=name_of_appender_class |
|
| 128 | + * |
|
| 129 | + * ; Set appender specific options. |
|
| 130 | + * |
|
| 131 | + * log4php.appender.appenderName.option1=value1 |
|
| 132 | + * log4php.appender.appenderName.optionN=valueN |
|
| 133 | + * </pre> |
|
| 134 | + * |
|
| 135 | + * For each named appender you can configure its {@link LoggerLayout}. The |
|
| 136 | + * syntax for configuring an appender's layout is: |
|
| 137 | + * <pre> |
|
| 138 | + * log4php.appender.appenderName.layout=name_of_layout_class |
|
| 139 | + * log4php.appender.appenderName.layout.option1=value1 |
|
| 140 | + * .... |
|
| 141 | + * log4php.appender.appenderName.layout.optionN=valueN |
|
| 142 | + * </pre> |
|
| 143 | + * |
|
| 144 | + * <p><b>Configuring loggers</b></p> |
|
| 145 | + * |
|
| 146 | + * <p>The syntax for configuring the root logger is: |
|
| 147 | + * <pre> |
|
| 148 | + * log4php.rootLogger=[level], appenderName, appenderName, ... |
|
| 149 | + * </pre> |
|
| 150 | + * |
|
| 151 | + * <p>This syntax means that an optional <i>level</i> can be |
|
| 152 | + * supplied followed by appender names separated by commas. |
|
| 153 | + * |
|
| 154 | + * <p>The level value can consist of the string values OFF, FATAL, |
|
| 155 | + * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A |
|
| 156 | + * custom level value can be specified in the form</p> |
|
| 157 | + * |
|
| 158 | + * <pre>level#classname</pre> |
|
| 159 | + * |
|
| 160 | + * <p>If a level value is specified, then the root level is set |
|
| 161 | + * to the corresponding level. If no level value is specified, |
|
| 162 | + * then the root level remains untouched. |
|
| 163 | + * |
|
| 164 | + * <p>The root logger can be assigned multiple appenders. |
|
| 165 | + * |
|
| 166 | + * <p>Each <i>appenderName</i> (separated by commas) will be added to |
|
| 167 | + * the root logger. The named appender is defined using the |
|
| 168 | + * appender syntax defined above. |
|
| 169 | + * |
|
| 170 | + * <p>For non-root categories the syntax is almost the same: |
|
| 171 | + * <pre> |
|
| 172 | + * log4php.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ... |
|
| 173 | + * </pre> |
|
| 174 | + * |
|
| 175 | + * <p>The meaning of the optional level value is discussed above |
|
| 176 | + * in relation to the root logger. In addition however, the value |
|
| 177 | + * INHERITED can be specified meaning that the named logger should |
|
| 178 | + * inherit its level from the logger hierarchy.</p> |
|
| 179 | + * |
|
| 180 | + * <p>If no level value is supplied, then the level of the |
|
| 181 | + * named logger remains untouched.</p> |
|
| 182 | + * |
|
| 183 | + * <p>By default categories inherit their level from the |
|
| 184 | + * hierarchy. However, if you set the level of a logger and later |
|
| 185 | + * decide that that logger should inherit its level, then you should |
|
| 186 | + * specify INHERITED as the value for the level value. NULL is a |
|
| 187 | + * synonym for INHERITED.</p> |
|
| 188 | + * |
|
| 189 | + * <p>Similar to the root logger syntax, each <i>appenderName</i> |
|
| 190 | + * (separated by commas) will be attached to the named logger.</p> |
|
| 191 | + * |
|
| 192 | + * <p>See the <i>appender additivity rule</i> in the user manual for |
|
| 193 | + * the meaning of the <b>additivity</b> flag. |
|
| 194 | + * |
|
| 195 | + * <p><b>ObjectRenderers</b></p> |
|
| 196 | + * |
|
| 197 | + * <p>You can customize the way message objects of a given type are |
|
| 198 | + * converted to String before being logged. This is done by |
|
| 199 | + * specifying a {@link LoggerRendererObject} |
|
| 200 | + * for the object type would like to customize.</p> |
|
| 201 | + * |
|
| 202 | + * <p>The syntax is: |
|
| 203 | + * |
|
| 204 | + * <pre> |
|
| 205 | + * log4php.renderer.name_of_rendered_class=name_of_rendering.class |
|
| 206 | + * </pre> |
|
| 207 | + * |
|
| 208 | + * As in, |
|
| 209 | + * <pre> |
|
| 210 | + * log4php.renderer.myFruit=myFruitRenderer |
|
| 211 | + * </pre> |
|
| 212 | + * |
|
| 213 | + * <p><b>Logger Factories</b></p> |
|
| 214 | + * |
|
| 215 | + * The usage of custom logger factories is discouraged and no longer |
|
| 216 | + * documented. |
|
| 217 | + * |
|
| 218 | + * <p><b>Example</b></p> |
|
| 219 | + * |
|
| 220 | + * <p>An example configuration is given below. Other configuration |
|
| 221 | + * file examples are given in the <b>tests</b> folder. |
|
| 222 | + * |
|
| 223 | + * <pre> |
|
| 224 | + * ; Set options for appender named "A1". |
|
| 225 | + * ; Appender "A1" will be a LoggerAppenderSyslog |
|
| 226 | + * log4php.appender.A1=LoggerAppenderSyslog |
|
| 227 | + * |
|
| 228 | + * ; The syslog daemon resides on www.abc.net |
|
| 229 | + * log4php.appender.A1.ident=log4php-test |
|
| 230 | + * |
|
| 231 | + * ; A1's layout is a LoggerPatternLayout, using the conversion pattern |
|
| 232 | + * ; <b>%r %-5p %c{2} %M.%L %x - %m%n</b>. Thus, the log output will |
|
| 233 | + * ; include the relative time since the start of the application in |
|
| 234 | + * ; milliseconds, followed by the level of the log request, |
|
| 235 | + * ; followed by the two rightmost components of the logger name, |
|
| 236 | + * ; followed by the callers method name, followed by the line number, |
|
| 237 | + * ; the nested disgnostic context and finally the message itself. |
|
| 238 | + * ; Refer to the documentation of LoggerPatternLayout} for further information |
|
| 239 | + * ; on the syntax of the ConversionPattern key. |
|
| 240 | + * log4php.appender.A1.layout=LoggerPatternLayout |
|
| 241 | + * log4php.appender.A1.layout.ConversionPattern="%-4r %-5p %c{2} %M.%L %x - %m%n" |
|
| 242 | + * |
|
| 243 | + * ; Set options for appender named "A2" |
|
| 244 | + * ; A2 should be a LoggerAppenderRollingFile, with maximum file size of 10 MB |
|
| 245 | + * ; using at most one backup file. A2's layout is TTCC, using the |
|
| 246 | + * ; ISO8061 date format with context printing enabled. |
|
| 247 | + * log4php.appender.A2=LoggerAppenderRollingFile |
|
| 248 | + * log4php.appender.A2.MaxFileSize=10MB |
|
| 249 | + * log4php.appender.A2.MaxBackupIndex=1 |
|
| 250 | + * log4php.appender.A2.layout=LoggerLayoutTTCC |
|
| 251 | + * log4php.appender.A2.layout.ContextPrinting="true" |
|
| 252 | + * log4php.appender.A2.layout.DateFormat="%c" |
|
| 253 | + * |
|
| 254 | + * ; Root logger set to DEBUG using the A2 appender defined above. |
|
| 255 | + * log4php.rootLogger=DEBUG, A2 |
|
| 256 | + * |
|
| 257 | + * ; Logger definitions: |
|
| 258 | + * ; The SECURITY logger inherits is level from root. However, it's output |
|
| 259 | + * ; will go to A1 appender defined above. It's additivity is non-cumulative. |
|
| 260 | + * log4php.logger.SECURITY=INHERIT, A1 |
|
| 261 | + * log4php.additivity.SECURITY=false |
|
| 262 | + * |
|
| 263 | + * ; Only warnings or above will be logged for the logger "SECURITY.access". |
|
| 264 | + * ; Output will go to A1. |
|
| 265 | + * log4php.logger.SECURITY.access=WARN |
|
| 266 | + * |
|
| 267 | + * |
|
| 268 | + * ; The logger "class.of.the.day" inherits its level from the |
|
| 269 | + * ; logger hierarchy. Output will go to the appender's of the root |
|
| 270 | + * ; logger, A2 in this case. |
|
| 271 | + * log4php.logger.class.of.the.day=INHERIT |
|
| 272 | + * </pre> |
|
| 273 | + * |
|
| 274 | + * <p>Refer to the <b>setOption</b> method in each Appender and |
|
| 275 | + * Layout for class specific options.</p> |
|
| 276 | + * |
|
| 277 | + * <p>Use the <b>";"</b> character at the |
|
| 278 | + * beginning of a line for comments.</p> |
|
| 279 | + * |
|
| 280 | + * @param string $url The name of the configuration file where the |
|
| 281 | + * configuration information is stored. |
|
| 282 | + * @param LoggerHierarchy $repository the repository to apply the configuration |
|
| 283 | + */ |
|
| 284 | + public function configure(LoggerHierarchy $hierarchy, $url = '') { |
|
| 285 | + $properties = @parse_ini_file($url); |
|
| 286 | + if ($properties === false || count($properties) == 0) { |
|
| 287 | + $error = error_get_last(); |
|
| 288 | + throw new LoggerException("LoggerConfiguratorIni: ".$error['message']); |
|
| 289 | + } |
|
| 290 | + return $this->doConfigureProperties($properties, $hierarchy); |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - /** |
|
| 294 | - * Read configuration options from <b>properties</b>. |
|
| 295 | - * |
|
| 296 | - * @see doConfigure(). |
|
| 297 | - * @param array $properties |
|
| 298 | - * @param LoggerHierarchy $hierarchy |
|
| 299 | - */ |
|
| 300 | - private function doConfigureProperties($properties, LoggerHierarchy $hierarchy) { |
|
| 301 | - $thresholdStr = @$properties[self::THRESHOLD_PREFIX]; |
|
| 302 | - $hierarchy->setThreshold(LoggerOptionConverter::toLevel($thresholdStr, LoggerLevel::getLevelAll())); |
|
| 303 | - $this->configureRootCategory($properties, $hierarchy); |
|
| 304 | - $this->parseCatsAndRenderers($properties, $hierarchy); |
|
| 305 | - return true; |
|
| 306 | - } |
|
| 293 | + /** |
|
| 294 | + * Read configuration options from <b>properties</b>. |
|
| 295 | + * |
|
| 296 | + * @see doConfigure(). |
|
| 297 | + * @param array $properties |
|
| 298 | + * @param LoggerHierarchy $hierarchy |
|
| 299 | + */ |
|
| 300 | + private function doConfigureProperties($properties, LoggerHierarchy $hierarchy) { |
|
| 301 | + $thresholdStr = @$properties[self::THRESHOLD_PREFIX]; |
|
| 302 | + $hierarchy->setThreshold(LoggerOptionConverter::toLevel($thresholdStr, LoggerLevel::getLevelAll())); |
|
| 303 | + $this->configureRootCategory($properties, $hierarchy); |
|
| 304 | + $this->parseCatsAndRenderers($properties, $hierarchy); |
|
| 305 | + return true; |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * @param array $props array of properties |
|
| 310 | - * @param LoggerHierarchy $hierarchy |
|
| 311 | - */ |
|
| 312 | - private function configureRootCategory($props, LoggerHierarchy $hierarchy) { |
|
| 313 | - $effectivePrefix = self::ROOT_LOGGER_PREFIX; |
|
| 314 | - $value = @$props[self::ROOT_LOGGER_PREFIX]; |
|
| 308 | + /** |
|
| 309 | + * @param array $props array of properties |
|
| 310 | + * @param LoggerHierarchy $hierarchy |
|
| 311 | + */ |
|
| 312 | + private function configureRootCategory($props, LoggerHierarchy $hierarchy) { |
|
| 313 | + $effectivePrefix = self::ROOT_LOGGER_PREFIX; |
|
| 314 | + $value = @$props[self::ROOT_LOGGER_PREFIX]; |
|
| 315 | 315 | |
| 316 | - if(empty($value)) { |
|
| 317 | - $value = @$props[self::ROOT_CATEGORY_PREFIX]; |
|
| 318 | - $effectivePrefix = self::ROOT_CATEGORY_PREFIX; |
|
| 319 | - } |
|
| 316 | + if(empty($value)) { |
|
| 317 | + $value = @$props[self::ROOT_CATEGORY_PREFIX]; |
|
| 318 | + $effectivePrefix = self::ROOT_CATEGORY_PREFIX; |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | - if(empty($value)) { |
|
| 322 | - // TODO "Could not find root logger information. Is this OK?" |
|
| 323 | - } else { |
|
| 324 | - $root = $hierarchy->getRootLogger(); |
|
| 325 | - $this->parseCategory($props, $root, $effectivePrefix, self::INTERNAL_ROOT_NAME, $value); |
|
| 326 | - } |
|
| 327 | - } |
|
| 321 | + if(empty($value)) { |
|
| 322 | + // TODO "Could not find root logger information. Is this OK?" |
|
| 323 | + } else { |
|
| 324 | + $root = $hierarchy->getRootLogger(); |
|
| 325 | + $this->parseCategory($props, $root, $effectivePrefix, self::INTERNAL_ROOT_NAME, $value); |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - /** |
|
| 330 | - * Parse non-root elements, such non-root categories and renderers. |
|
| 331 | - * |
|
| 332 | - * @param array $props array of properties |
|
| 333 | - * @param LoggerHierarchy $hierarchy |
|
| 334 | - */ |
|
| 335 | - private function parseCatsAndRenderers($props, LoggerHierarchy $hierarchy) { |
|
| 336 | - while(list($key,$value) = each($props)) { |
|
| 337 | - if(strpos($key, self::CATEGORY_PREFIX) === 0 or |
|
| 338 | - strpos($key, self::LOGGER_PREFIX) === 0) { |
|
| 339 | - if(strpos($key, self::CATEGORY_PREFIX) === 0) { |
|
| 340 | - $loggerName = substr($key, strlen(self::CATEGORY_PREFIX)); |
|
| 341 | - } else if(strpos($key, self::LOGGER_PREFIX) === 0) { |
|
| 342 | - $loggerName = substr($key, strlen(self::LOGGER_PREFIX)); |
|
| 343 | - } |
|
| 329 | + /** |
|
| 330 | + * Parse non-root elements, such non-root categories and renderers. |
|
| 331 | + * |
|
| 332 | + * @param array $props array of properties |
|
| 333 | + * @param LoggerHierarchy $hierarchy |
|
| 334 | + */ |
|
| 335 | + private function parseCatsAndRenderers($props, LoggerHierarchy $hierarchy) { |
|
| 336 | + while(list($key,$value) = each($props)) { |
|
| 337 | + if(strpos($key, self::CATEGORY_PREFIX) === 0 or |
|
| 338 | + strpos($key, self::LOGGER_PREFIX) === 0) { |
|
| 339 | + if(strpos($key, self::CATEGORY_PREFIX) === 0) { |
|
| 340 | + $loggerName = substr($key, strlen(self::CATEGORY_PREFIX)); |
|
| 341 | + } else if(strpos($key, self::LOGGER_PREFIX) === 0) { |
|
| 342 | + $loggerName = substr($key, strlen(self::LOGGER_PREFIX)); |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - $logger = $hierarchy->getLogger($loggerName); |
|
| 346 | - $this->parseCategory($props, $logger, $key, $loggerName, $value); |
|
| 347 | - $this->parseAdditivityForLogger($props, $logger, $loggerName); |
|
| 348 | - } else if(strpos($key, self::RENDERER_PREFIX) === 0) { |
|
| 349 | - $renderedClass = substr($key, strlen(self::RENDERER_PREFIX)); |
|
| 350 | - $renderingClass = $value; |
|
| 351 | - $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClass); |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - } |
|
| 345 | + $logger = $hierarchy->getLogger($loggerName); |
|
| 346 | + $this->parseCategory($props, $logger, $key, $loggerName, $value); |
|
| 347 | + $this->parseAdditivityForLogger($props, $logger, $loggerName); |
|
| 348 | + } else if(strpos($key, self::RENDERER_PREFIX) === 0) { |
|
| 349 | + $renderedClass = substr($key, strlen(self::RENDERER_PREFIX)); |
|
| 350 | + $renderingClass = $value; |
|
| 351 | + $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClass); |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - /** |
|
| 357 | - * Parse the additivity option for a non-root category. |
|
| 358 | - * |
|
| 359 | - * @param array $props array of properties |
|
| 360 | - * @param Logger $cat |
|
| 361 | - * @param string $loggerName |
|
| 362 | - */ |
|
| 363 | - private function parseAdditivityForLogger($props, Logger $cat, $loggerName) { |
|
| 364 | - $value = LoggerOptionConverter::findAndSubst(self::ADDITIVITY_PREFIX . $loggerName, $props); |
|
| 356 | + /** |
|
| 357 | + * Parse the additivity option for a non-root category. |
|
| 358 | + * |
|
| 359 | + * @param array $props array of properties |
|
| 360 | + * @param Logger $cat |
|
| 361 | + * @param string $loggerName |
|
| 362 | + */ |
|
| 363 | + private function parseAdditivityForLogger($props, Logger $cat, $loggerName) { |
|
| 364 | + $value = LoggerOptionConverter::findAndSubst(self::ADDITIVITY_PREFIX . $loggerName, $props); |
|
| 365 | 365 | |
| 366 | - // touch additivity only if necessary |
|
| 367 | - if(!empty($value)) { |
|
| 368 | - $additivity = LoggerOptionConverter::toBoolean($value, true); |
|
| 369 | - $cat->setAdditivity($additivity); |
|
| 370 | - } |
|
| 371 | - } |
|
| 366 | + // touch additivity only if necessary |
|
| 367 | + if(!empty($value)) { |
|
| 368 | + $additivity = LoggerOptionConverter::toBoolean($value, true); |
|
| 369 | + $cat->setAdditivity($additivity); |
|
| 370 | + } |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * This method must work for the root category as well. |
|
| 375 | - * |
|
| 376 | - * @param array $props array of properties |
|
| 377 | - * @param Logger $logger |
|
| 378 | - * @param string $optionKey |
|
| 379 | - * @param string $loggerName |
|
| 380 | - * @param string $value |
|
| 381 | - * @return Logger |
|
| 382 | - */ |
|
| 383 | - private function parseCategory($props, Logger $logger, $optionKey, $loggerName, $value) { |
|
| 384 | - // We must skip over ',' but not white space |
|
| 385 | - $st = explode(',', $value); |
|
| 373 | + /** |
|
| 374 | + * This method must work for the root category as well. |
|
| 375 | + * |
|
| 376 | + * @param array $props array of properties |
|
| 377 | + * @param Logger $logger |
|
| 378 | + * @param string $optionKey |
|
| 379 | + * @param string $loggerName |
|
| 380 | + * @param string $value |
|
| 381 | + * @return Logger |
|
| 382 | + */ |
|
| 383 | + private function parseCategory($props, Logger $logger, $optionKey, $loggerName, $value) { |
|
| 384 | + // We must skip over ',' but not white space |
|
| 385 | + $st = explode(',', $value); |
|
| 386 | 386 | |
| 387 | - // If value is not in the form ", appender.." or "", then we should set |
|
| 388 | - // the level of the loggeregory. |
|
| 387 | + // If value is not in the form ", appender.." or "", then we should set |
|
| 388 | + // the level of the loggeregory. |
|
| 389 | 389 | |
| 390 | - if(!(empty($value) || @$value[0] == ',')) { |
|
| 391 | - // just to be on the safe side... |
|
| 392 | - if(count($st) == 0) { |
|
| 393 | - return; |
|
| 394 | - } |
|
| 395 | - $levelStr = current($st); |
|
| 390 | + if(!(empty($value) || @$value[0] == ',')) { |
|
| 391 | + // just to be on the safe side... |
|
| 392 | + if(count($st) == 0) { |
|
| 393 | + return; |
|
| 394 | + } |
|
| 395 | + $levelStr = current($st); |
|
| 396 | 396 | |
| 397 | - // If the level value is inherited, set category level value to |
|
| 398 | - // null. We also check that the user has not specified inherited for the |
|
| 399 | - // root category. |
|
| 400 | - if('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) { |
|
| 401 | - if($loggerName == self::INTERNAL_ROOT_NAME) { |
|
| 402 | - // TODO: throw exception? "The root logger cannot be set to null." |
|
| 403 | - } else { |
|
| 404 | - $logger->setLevel(null); |
|
| 405 | - } |
|
| 406 | - } else { |
|
| 407 | - $logger->setLevel(LoggerOptionConverter::toLevel($levelStr, LoggerLevel::getLevelDebug())); |
|
| 408 | - } |
|
| 409 | - } |
|
| 397 | + // If the level value is inherited, set category level value to |
|
| 398 | + // null. We also check that the user has not specified inherited for the |
|
| 399 | + // root category. |
|
| 400 | + if('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) { |
|
| 401 | + if($loggerName == self::INTERNAL_ROOT_NAME) { |
|
| 402 | + // TODO: throw exception? "The root logger cannot be set to null." |
|
| 403 | + } else { |
|
| 404 | + $logger->setLevel(null); |
|
| 405 | + } |
|
| 406 | + } else { |
|
| 407 | + $logger->setLevel(LoggerOptionConverter::toLevel($levelStr, LoggerLevel::getLevelDebug())); |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - // TODO: removing should be done by the logger, if necessary and wanted |
|
| 412 | - // $logger->removeAllAppenders(); |
|
| 413 | - while($appenderName = next($st)) { |
|
| 414 | - $appenderName = trim($appenderName); |
|
| 415 | - if(empty($appenderName)) { |
|
| 416 | - continue; |
|
| 417 | - } |
|
| 411 | + // TODO: removing should be done by the logger, if necessary and wanted |
|
| 412 | + // $logger->removeAllAppenders(); |
|
| 413 | + while($appenderName = next($st)) { |
|
| 414 | + $appenderName = trim($appenderName); |
|
| 415 | + if(empty($appenderName)) { |
|
| 416 | + continue; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - $appender = $this->parseAppender($props, $appenderName); |
|
| 420 | - if($appender !== null) { |
|
| 421 | - $logger->addAppender($appender); |
|
| 422 | - } |
|
| 423 | - } |
|
| 424 | - } |
|
| 419 | + $appender = $this->parseAppender($props, $appenderName); |
|
| 420 | + if($appender !== null) { |
|
| 421 | + $logger->addAppender($appender); |
|
| 422 | + } |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - /** |
|
| 427 | - * @param array $props array of properties |
|
| 428 | - * @param string $appenderName |
|
| 429 | - * @return LoggerAppender |
|
| 430 | - */ |
|
| 431 | - private function parseAppender($props, $appenderName) { |
|
| 432 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
| 433 | - $prefix = self::APPENDER_PREFIX . $appenderName; |
|
| 434 | - if($appender === null) { |
|
| 435 | - // Appender was not previously initialized. |
|
| 436 | - $appenderClass = @$props[$prefix]; |
|
| 437 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderClass); |
|
| 438 | - if($appender === null) { |
|
| 439 | - return null; |
|
| 440 | - } |
|
| 441 | - } |
|
| 426 | + /** |
|
| 427 | + * @param array $props array of properties |
|
| 428 | + * @param string $appenderName |
|
| 429 | + * @return LoggerAppender |
|
| 430 | + */ |
|
| 431 | + private function parseAppender($props, $appenderName) { |
|
| 432 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
| 433 | + $prefix = self::APPENDER_PREFIX . $appenderName; |
|
| 434 | + if($appender === null) { |
|
| 435 | + // Appender was not previously initialized. |
|
| 436 | + $appenderClass = @$props[$prefix]; |
|
| 437 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderClass); |
|
| 438 | + if($appender === null) { |
|
| 439 | + return null; |
|
| 440 | + } |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | - if($appender->requiresLayout() ) { |
|
| 444 | - $layoutPrefix = $prefix . ".layout"; |
|
| 445 | - $layoutClass = @$props[$layoutPrefix]; |
|
| 446 | - $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props); |
|
| 447 | - if(empty($layoutClass)) { |
|
| 448 | - $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
| 449 | - } else { |
|
| 450 | - $layout = LoggerReflectionUtils::createObject($layoutClass); |
|
| 451 | - if($layout === null) { |
|
| 452 | - $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
| 453 | - } |
|
| 454 | - } |
|
| 443 | + if($appender->requiresLayout() ) { |
|
| 444 | + $layoutPrefix = $prefix . ".layout"; |
|
| 445 | + $layoutClass = @$props[$layoutPrefix]; |
|
| 446 | + $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props); |
|
| 447 | + if(empty($layoutClass)) { |
|
| 448 | + $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
| 449 | + } else { |
|
| 450 | + $layout = LoggerReflectionUtils::createObject($layoutClass); |
|
| 451 | + if($layout === null) { |
|
| 452 | + $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
| 453 | + } |
|
| 454 | + } |
|
| 455 | 455 | |
| 456 | - LoggerReflectionUtils::setPropertiesByObject($layout, $props, $layoutPrefix . "."); |
|
| 457 | - $appender->setLayout($layout); |
|
| 456 | + LoggerReflectionUtils::setPropertiesByObject($layout, $props, $layoutPrefix . "."); |
|
| 457 | + $appender->setLayout($layout); |
|
| 458 | 458 | |
| 459 | - } |
|
| 460 | - LoggerReflectionUtils::setPropertiesByObject($appender, $props, $prefix . "."); |
|
| 461 | - return $appender; |
|
| 462 | - } |
|
| 459 | + } |
|
| 460 | + LoggerReflectionUtils::setPropertiesByObject($appender, $props, $prefix . "."); |
|
| 461 | + return $appender; |
|
| 462 | + } |
|
| 463 | 463 | } |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | $effectivePrefix = self::ROOT_LOGGER_PREFIX; |
| 314 | 314 | $value = @$props[self::ROOT_LOGGER_PREFIX]; |
| 315 | 315 | |
| 316 | - if(empty($value)) { |
|
| 316 | + if (empty($value)) { |
|
| 317 | 317 | $value = @$props[self::ROOT_CATEGORY_PREFIX]; |
| 318 | 318 | $effectivePrefix = self::ROOT_CATEGORY_PREFIX; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if(empty($value)) { |
|
| 321 | + if (empty($value)) { |
|
| 322 | 322 | // TODO "Could not find root logger information. Is this OK?" |
| 323 | 323 | } else { |
| 324 | 324 | $root = $hierarchy->getRootLogger(); |
| 325 | - $this->parseCategory($props, $root, $effectivePrefix, self::INTERNAL_ROOT_NAME, $value); |
|
| 325 | + $this->parseCategory($props, $root, $effectivePrefix, self::INTERNAL_ROOT_NAME, $value); |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
@@ -333,19 +333,19 @@ discard block |
||
| 333 | 333 | * @param LoggerHierarchy $hierarchy |
| 334 | 334 | */ |
| 335 | 335 | private function parseCatsAndRenderers($props, LoggerHierarchy $hierarchy) { |
| 336 | - while(list($key,$value) = each($props)) { |
|
| 337 | - if(strpos($key, self::CATEGORY_PREFIX) === 0 or |
|
| 336 | + while (list($key, $value) = each($props)) { |
|
| 337 | + if (strpos($key, self::CATEGORY_PREFIX) === 0 or |
|
| 338 | 338 | strpos($key, self::LOGGER_PREFIX) === 0) { |
| 339 | - if(strpos($key, self::CATEGORY_PREFIX) === 0) { |
|
| 339 | + if (strpos($key, self::CATEGORY_PREFIX) === 0) { |
|
| 340 | 340 | $loggerName = substr($key, strlen(self::CATEGORY_PREFIX)); |
| 341 | - } else if(strpos($key, self::LOGGER_PREFIX) === 0) { |
|
| 341 | + } else if (strpos($key, self::LOGGER_PREFIX) === 0) { |
|
| 342 | 342 | $loggerName = substr($key, strlen(self::LOGGER_PREFIX)); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | $logger = $hierarchy->getLogger($loggerName); |
| 346 | 346 | $this->parseCategory($props, $logger, $key, $loggerName, $value); |
| 347 | 347 | $this->parseAdditivityForLogger($props, $logger, $loggerName); |
| 348 | - } else if(strpos($key, self::RENDERER_PREFIX) === 0) { |
|
| 348 | + } else if (strpos($key, self::RENDERER_PREFIX) === 0) { |
|
| 349 | 349 | $renderedClass = substr($key, strlen(self::RENDERER_PREFIX)); |
| 350 | 350 | $renderingClass = $value; |
| 351 | 351 | $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClass); |
@@ -361,10 +361,10 @@ discard block |
||
| 361 | 361 | * @param string $loggerName |
| 362 | 362 | */ |
| 363 | 363 | private function parseAdditivityForLogger($props, Logger $cat, $loggerName) { |
| 364 | - $value = LoggerOptionConverter::findAndSubst(self::ADDITIVITY_PREFIX . $loggerName, $props); |
|
| 364 | + $value = LoggerOptionConverter::findAndSubst(self::ADDITIVITY_PREFIX.$loggerName, $props); |
|
| 365 | 365 | |
| 366 | 366 | // touch additivity only if necessary |
| 367 | - if(!empty($value)) { |
|
| 367 | + if (!empty($value)) { |
|
| 368 | 368 | $additivity = LoggerOptionConverter::toBoolean($value, true); |
| 369 | 369 | $cat->setAdditivity($additivity); |
| 370 | 370 | } |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | // If value is not in the form ", appender.." or "", then we should set |
| 388 | 388 | // the level of the loggeregory. |
| 389 | 389 | |
| 390 | - if(!(empty($value) || @$value[0] == ',')) { |
|
| 390 | + if (!(empty($value) || @$value[0] == ',')) { |
|
| 391 | 391 | // just to be on the safe side... |
| 392 | - if(count($st) == 0) { |
|
| 392 | + if (count($st) == 0) { |
|
| 393 | 393 | return; |
| 394 | 394 | } |
| 395 | 395 | $levelStr = current($st); |
@@ -397,8 +397,8 @@ discard block |
||
| 397 | 397 | // If the level value is inherited, set category level value to |
| 398 | 398 | // null. We also check that the user has not specified inherited for the |
| 399 | 399 | // root category. |
| 400 | - if('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) { |
|
| 401 | - if($loggerName == self::INTERNAL_ROOT_NAME) { |
|
| 400 | + if ('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) { |
|
| 401 | + if ($loggerName == self::INTERNAL_ROOT_NAME) { |
|
| 402 | 402 | // TODO: throw exception? "The root logger cannot be set to null." |
| 403 | 403 | } else { |
| 404 | 404 | $logger->setLevel(null); |
@@ -410,14 +410,14 @@ discard block |
||
| 410 | 410 | |
| 411 | 411 | // TODO: removing should be done by the logger, if necessary and wanted |
| 412 | 412 | // $logger->removeAllAppenders(); |
| 413 | - while($appenderName = next($st)) { |
|
| 413 | + while ($appenderName = next($st)) { |
|
| 414 | 414 | $appenderName = trim($appenderName); |
| 415 | - if(empty($appenderName)) { |
|
| 415 | + if (empty($appenderName)) { |
|
| 416 | 416 | continue; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | $appender = $this->parseAppender($props, $appenderName); |
| 420 | - if($appender !== null) { |
|
| 420 | + if ($appender !== null) { |
|
| 421 | 421 | $logger->addAppender($appender); |
| 422 | 422 | } |
| 423 | 423 | } |
@@ -430,34 +430,34 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | private function parseAppender($props, $appenderName) { |
| 432 | 432 | $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
| 433 | - $prefix = self::APPENDER_PREFIX . $appenderName; |
|
| 434 | - if($appender === null) { |
|
| 433 | + $prefix = self::APPENDER_PREFIX.$appenderName; |
|
| 434 | + if ($appender === null) { |
|
| 435 | 435 | // Appender was not previously initialized. |
| 436 | 436 | $appenderClass = @$props[$prefix]; |
| 437 | 437 | $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderClass); |
| 438 | - if($appender === null) { |
|
| 438 | + if ($appender === null) { |
|
| 439 | 439 | return null; |
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - if($appender->requiresLayout() ) { |
|
| 444 | - $layoutPrefix = $prefix . ".layout"; |
|
| 443 | + if ($appender->requiresLayout()) { |
|
| 444 | + $layoutPrefix = $prefix.".layout"; |
|
| 445 | 445 | $layoutClass = @$props[$layoutPrefix]; |
| 446 | 446 | $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props); |
| 447 | - if(empty($layoutClass)) { |
|
| 447 | + if (empty($layoutClass)) { |
|
| 448 | 448 | $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
| 449 | 449 | } else { |
| 450 | 450 | $layout = LoggerReflectionUtils::createObject($layoutClass); |
| 451 | - if($layout === null) { |
|
| 451 | + if ($layout === null) { |
|
| 452 | 452 | $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - LoggerReflectionUtils::setPropertiesByObject($layout, $props, $layoutPrefix . "."); |
|
| 456 | + LoggerReflectionUtils::setPropertiesByObject($layout, $props, $layoutPrefix."."); |
|
| 457 | 457 | $appender->setLayout($layout); |
| 458 | 458 | |
| 459 | 459 | } |
| 460 | - LoggerReflectionUtils::setPropertiesByObject($appender, $props, $prefix . "."); |
|
| 460 | + LoggerReflectionUtils::setPropertiesByObject($appender, $props, $prefix."."); |
|
| 461 | 461 | return $appender; |
| 462 | 462 | } |
| 463 | 463 | } |
@@ -237,6 +237,9 @@ |
||
| 237 | 237 | return $this->head; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | + /** |
|
| 241 | + * @param string $c |
|
| 242 | + */ |
|
| 240 | 243 | public function finalizeConverter($c) { |
| 241 | 244 | $pc = null; |
| 242 | 245 | switch($c) { |
@@ -186,19 +186,19 @@ |
||
| 186 | 186 | case self::CONVERTER_STATE: |
| 187 | 187 | $this->currentLiteral .= $c; |
| 188 | 188 | switch($c) { |
| 189 | - case '-': |
|
| 190 | - $this->formattingInfo->leftAlign = true; |
|
| 191 | - break; |
|
| 192 | - case '.': |
|
| 193 | - $this->state = self::DOT_STATE; |
|
| 194 | - break; |
|
| 195 | - default: |
|
| 196 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 197 | - $this->formattingInfo->min = ord($c) - ord('0'); |
|
| 198 | - $this->state = self::MIN_STATE; |
|
| 199 | - } else { |
|
| 200 | - $this->finalizeConverter($c); |
|
| 201 | - } |
|
| 189 | + case '-': |
|
| 190 | + $this->formattingInfo->leftAlign = true; |
|
| 191 | + break; |
|
| 192 | + case '.': |
|
| 193 | + $this->state = self::DOT_STATE; |
|
| 194 | + break; |
|
| 195 | + default: |
|
| 196 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 197 | + $this->formattingInfo->min = ord($c) - ord('0'); |
|
| 198 | + $this->state = self::MIN_STATE; |
|
| 199 | + } else { |
|
| 200 | + $this->finalizeConverter($c); |
|
| 201 | + } |
|
| 202 | 202 | } // switch |
| 203 | 203 | break; |
| 204 | 204 | case self::MIN_STATE: |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function __construct($pattern) { |
| 92 | 92 | $this->pattern = $pattern; |
| 93 | - $this->patternLength = strlen($pattern); |
|
| 93 | + $this->patternLength = strlen($pattern); |
|
| 94 | 94 | $this->formattingInfo = new LoggerFormattingInfo(); |
| 95 | 95 | $this->state = self::LITERAL_STATE; |
| 96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param LoggerPatternConverter $pc |
| 100 | 100 | */ |
| 101 | 101 | public function addToList($pc) { |
| 102 | - if($this->head == null) { |
|
| 102 | + if ($this->head == null) { |
|
| 103 | 103 | $this->head = $pc; |
| 104 | 104 | $this->tail = $this->head; |
| 105 | 105 | } else { |
@@ -112,11 +112,11 @@ discard block |
||
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | 114 | public function extractOption() { |
| 115 | - if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
| 116 | - $end = strpos($this->pattern, '}' , $this->i); |
|
| 117 | - if($end !== false) { |
|
| 115 | + if (($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
| 116 | + $end = strpos($this->pattern, '}', $this->i); |
|
| 117 | + if ($end !== false) { |
|
| 118 | 118 | $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
| 119 | - $this->i= $end + 1; |
|
| 119 | + $this->i = $end + 1; |
|
| 120 | 120 | return $r; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | public function extractPrecisionOption() { |
| 131 | 131 | $opt = $this->extractOption(); |
| 132 | 132 | $r = 0; |
| 133 | - if($opt !== null) { |
|
| 134 | - if(is_numeric($opt)) { |
|
| 135 | - $r = (int)$opt; |
|
| 136 | - if($r <= 0) { |
|
| 133 | + if ($opt !== null) { |
|
| 134 | + if (is_numeric($opt)) { |
|
| 135 | + $r = (int) $opt; |
|
| 136 | + if ($r <= 0) { |
|
| 137 | 137 | $r = 0; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -150,19 +150,19 @@ discard block |
||
| 150 | 150 | $c = ''; |
| 151 | 151 | $this->i = 0; |
| 152 | 152 | $this->currentLiteral = ''; |
| 153 | - while($this->i < $this->patternLength) { |
|
| 153 | + while ($this->i < $this->patternLength) { |
|
| 154 | 154 | $c = $this->pattern{$this->i++}; |
| 155 | 155 | |
| 156 | - switch($this->state) { |
|
| 156 | + switch ($this->state) { |
|
| 157 | 157 | case self::LITERAL_STATE: |
| 158 | 158 | // In literal state, the last char is always a literal. |
| 159 | - if($this->i == $this->patternLength) { |
|
| 159 | + if ($this->i == $this->patternLength) { |
|
| 160 | 160 | $this->currentLiteral .= $c; |
| 161 | 161 | continue; |
| 162 | 162 | } |
| 163 | - if($c == self::ESCAPE_CHAR) { |
|
| 163 | + if ($c == self::ESCAPE_CHAR) { |
|
| 164 | 164 | // peek at the next char. |
| 165 | - switch($this->pattern{$this->i}) { |
|
| 165 | + switch ($this->pattern{$this->i}) { |
|
| 166 | 166 | case self::ESCAPE_CHAR: |
| 167 | 167 | $this->currentLiteral .= $c; |
| 168 | 168 | $this->i++; // move pointer |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $this->i++; // move pointer |
| 173 | 173 | break; |
| 174 | 174 | default: |
| 175 | - if(strlen($this->currentLiteral) != 0) { |
|
| 175 | + if (strlen($this->currentLiteral) != 0) { |
|
| 176 | 176 | $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
| 177 | 177 | } |
| 178 | 178 | $this->currentLiteral = $c; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | break; |
| 186 | 186 | case self::CONVERTER_STATE: |
| 187 | 187 | $this->currentLiteral .= $c; |
| 188 | - switch($c) { |
|
| 188 | + switch ($c) { |
|
| 189 | 189 | case '-': |
| 190 | 190 | $this->formattingInfo->leftAlign = true; |
| 191 | 191 | break; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $this->state = self::DOT_STATE; |
| 194 | 194 | break; |
| 195 | 195 | default: |
| 196 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 196 | + if (ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 197 | 197 | $this->formattingInfo->min = ord($c) - ord('0'); |
| 198 | 198 | $this->state = self::MIN_STATE; |
| 199 | 199 | } else { |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | break; |
| 204 | 204 | case self::MIN_STATE: |
| 205 | 205 | $this->currentLiteral .= $c; |
| 206 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 206 | + if (ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 207 | 207 | $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0')); |
| 208 | 208 | } else if ($c == '.') { |
| 209 | 209 | $this->state = self::DOT_STATE; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | break; |
| 214 | 214 | case self::DOT_STATE: |
| 215 | 215 | $this->currentLiteral .= $c; |
| 216 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 216 | + if (ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 217 | 217 | $this->formattingInfo->max = ord($c) - ord('0'); |
| 218 | 218 | $this->state = self::MAX_STATE; |
| 219 | 219 | } else { |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | break; |
| 223 | 223 | case self::MAX_STATE: |
| 224 | 224 | $this->currentLiteral .= $c; |
| 225 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 225 | + if (ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 226 | 226 | $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
| 227 | 227 | } else { |
| 228 | 228 | $this->finalizeConverter($c); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | break; |
| 232 | 232 | } // switch |
| 233 | 233 | } // while |
| 234 | - if(strlen($this->currentLiteral) != 0) { |
|
| 234 | + if (strlen($this->currentLiteral) != 0) { |
|
| 235 | 235 | $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
| 236 | 236 | } |
| 237 | 237 | return $this->head; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | public function finalizeConverter($c) { |
| 241 | 241 | $pc = null; |
| 242 | - switch($c) { |
|
| 242 | + switch ($c) { |
|
| 243 | 243 | case 'c': |
| 244 | 244 | $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
| 245 | 245 | $this->currentLiteral = ''; |
@@ -252,18 +252,18 @@ discard block |
||
| 252 | 252 | $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
| 253 | 253 | $dOpt = $this->extractOption(); |
| 254 | 254 | |
| 255 | - if($dOpt !== null) |
|
| 255 | + if ($dOpt !== null) |
|
| 256 | 256 | $dateFormatStr = $dOpt; |
| 257 | 257 | |
| 258 | - if($dateFormatStr == 'ISO8601') { |
|
| 258 | + if ($dateFormatStr == 'ISO8601') { |
|
| 259 | 259 | $df = self::DATE_FORMAT_ISO8601; |
| 260 | - } else if($dateFormatStr == 'ABSOLUTE') { |
|
| 260 | + } else if ($dateFormatStr == 'ABSOLUTE') { |
|
| 261 | 261 | $df = self::DATE_FORMAT_ABSOLUTE; |
| 262 | - } else if($dateFormatStr == 'DATE') { |
|
| 262 | + } else if ($dateFormatStr == 'DATE') { |
|
| 263 | 263 | $df = self::DATE_FORMAT_DATE; |
| 264 | 264 | } else { |
| 265 | 265 | $df = $dateFormatStr; |
| 266 | - if($df == null) { |
|
| 266 | + if ($df == null) { |
|
| 267 | 267 | $df = self::DATE_FORMAT_ISO8601; |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -303,10 +303,10 @@ discard block |
||
| 303 | 303 | $this->currentLiteral = ''; |
| 304 | 304 | break; |
| 305 | 305 | case 'u': |
| 306 | - if($this->i < $this->patternLength) { |
|
| 306 | + if ($this->i < $this->patternLength) { |
|
| 307 | 307 | $cNext = $this->pattern{$this->i}; |
| 308 | - if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
| 309 | - $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
| 308 | + if (ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
| 309 | + $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string) (ord($cNext) - ord('0'))); |
|
| 310 | 310 | $this->currentLiteral = ''; |
| 311 | 311 | $this->i++; |
| 312 | 312 | } |
@@ -252,8 +252,9 @@ |
||
| 252 | 252 | $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
| 253 | 253 | $dOpt = $this->extractOption(); |
| 254 | 254 | |
| 255 | - if($dOpt !== null) |
|
| 256 | - $dateFormatStr = $dOpt; |
|
| 255 | + if($dOpt !== null) { |
|
| 256 | + $dateFormatStr = $dOpt; |
|
| 257 | + } |
|
| 257 | 258 | |
| 258 | 259 | if($dateFormatStr == 'ISO8601') { |
| 259 | 260 | $df = self::DATE_FORMAT_ISO8601; |
@@ -33,309 +33,309 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class LoggerPatternParser { |
| 35 | 35 | |
| 36 | - const ESCAPE_CHAR = '%'; |
|
| 36 | + const ESCAPE_CHAR = '%'; |
|
| 37 | 37 | |
| 38 | - const LITERAL_STATE = 0; |
|
| 39 | - const CONVERTER_STATE = 1; |
|
| 40 | - const MINUS_STATE = 2; |
|
| 41 | - const DOT_STATE = 3; |
|
| 42 | - const MIN_STATE = 4; |
|
| 43 | - const MAX_STATE = 5; |
|
| 38 | + const LITERAL_STATE = 0; |
|
| 39 | + const CONVERTER_STATE = 1; |
|
| 40 | + const MINUS_STATE = 2; |
|
| 41 | + const DOT_STATE = 3; |
|
| 42 | + const MIN_STATE = 4; |
|
| 43 | + const MAX_STATE = 5; |
|
| 44 | 44 | |
| 45 | - const FULL_LOCATION_CONVERTER = 1000; |
|
| 46 | - const METHOD_LOCATION_CONVERTER = 1001; |
|
| 47 | - const CLASS_LOCATION_CONVERTER = 1002; |
|
| 48 | - const FILE_LOCATION_CONVERTER = 1003; |
|
| 49 | - const LINE_LOCATION_CONVERTER = 1004; |
|
| 45 | + const FULL_LOCATION_CONVERTER = 1000; |
|
| 46 | + const METHOD_LOCATION_CONVERTER = 1001; |
|
| 47 | + const CLASS_LOCATION_CONVERTER = 1002; |
|
| 48 | + const FILE_LOCATION_CONVERTER = 1003; |
|
| 49 | + const LINE_LOCATION_CONVERTER = 1004; |
|
| 50 | 50 | |
| 51 | - const RELATIVE_TIME_CONVERTER = 2000; |
|
| 52 | - const THREAD_CONVERTER = 2001; |
|
| 53 | - const LEVEL_CONVERTER = 2002; |
|
| 54 | - const NDC_CONVERTER = 2003; |
|
| 55 | - const MESSAGE_CONVERTER = 2004; |
|
| 51 | + const RELATIVE_TIME_CONVERTER = 2000; |
|
| 52 | + const THREAD_CONVERTER = 2001; |
|
| 53 | + const LEVEL_CONVERTER = 2002; |
|
| 54 | + const NDC_CONVERTER = 2003; |
|
| 55 | + const MESSAGE_CONVERTER = 2004; |
|
| 56 | 56 | |
| 57 | - const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; |
|
| 58 | - const DATE_FORMAT_ABSOLUTE = 'H:i:s'; |
|
| 59 | - const DATE_FORMAT_DATE = 'd M Y H:i:s,u'; |
|
| 57 | + const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; |
|
| 58 | + const DATE_FORMAT_ABSOLUTE = 'H:i:s'; |
|
| 59 | + const DATE_FORMAT_DATE = 'd M Y H:i:s,u'; |
|
| 60 | 60 | |
| 61 | - private $state; |
|
| 62 | - private $currentLiteral; |
|
| 63 | - private $patternLength; |
|
| 64 | - private $i; |
|
| 61 | + private $state; |
|
| 62 | + private $currentLiteral; |
|
| 63 | + private $patternLength; |
|
| 64 | + private $i; |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @var LoggerPatternConverter |
|
| 68 | - */ |
|
| 69 | - private $head = null; |
|
| 66 | + /** |
|
| 67 | + * @var LoggerPatternConverter |
|
| 68 | + */ |
|
| 69 | + private $head = null; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @var LoggerPatternConverter |
|
| 73 | - */ |
|
| 74 | - private $tail = null; |
|
| 71 | + /** |
|
| 72 | + * @var LoggerPatternConverter |
|
| 73 | + */ |
|
| 74 | + private $tail = null; |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @var LoggerFormattingInfo |
|
| 78 | - */ |
|
| 79 | - private $formattingInfo; |
|
| 76 | + /** |
|
| 77 | + * @var LoggerFormattingInfo |
|
| 78 | + */ |
|
| 79 | + private $formattingInfo; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @var string pattern to parse |
|
| 83 | - */ |
|
| 84 | - private $pattern; |
|
| 81 | + /** |
|
| 82 | + * @var string pattern to parse |
|
| 83 | + */ |
|
| 84 | + private $pattern; |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Constructor |
|
| 88 | - * |
|
| 89 | - * @param string $pattern |
|
| 90 | - */ |
|
| 91 | - public function __construct($pattern) { |
|
| 92 | - $this->pattern = $pattern; |
|
| 93 | - $this->patternLength = strlen($pattern); |
|
| 94 | - $this->formattingInfo = new LoggerFormattingInfo(); |
|
| 95 | - $this->state = self::LITERAL_STATE; |
|
| 96 | - } |
|
| 86 | + /** |
|
| 87 | + * Constructor |
|
| 88 | + * |
|
| 89 | + * @param string $pattern |
|
| 90 | + */ |
|
| 91 | + public function __construct($pattern) { |
|
| 92 | + $this->pattern = $pattern; |
|
| 93 | + $this->patternLength = strlen($pattern); |
|
| 94 | + $this->formattingInfo = new LoggerFormattingInfo(); |
|
| 95 | + $this->state = self::LITERAL_STATE; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * @param LoggerPatternConverter $pc |
|
| 100 | - */ |
|
| 101 | - public function addToList($pc) { |
|
| 102 | - if($this->head == null) { |
|
| 103 | - $this->head = $pc; |
|
| 104 | - $this->tail = $this->head; |
|
| 105 | - } else { |
|
| 106 | - $this->tail->next = $pc; |
|
| 107 | - $this->tail = $this->tail->next; |
|
| 108 | - } |
|
| 109 | - } |
|
| 98 | + /** |
|
| 99 | + * @param LoggerPatternConverter $pc |
|
| 100 | + */ |
|
| 101 | + public function addToList($pc) { |
|
| 102 | + if($this->head == null) { |
|
| 103 | + $this->head = $pc; |
|
| 104 | + $this->tail = $this->head; |
|
| 105 | + } else { |
|
| 106 | + $this->tail->next = $pc; |
|
| 107 | + $this->tail = $this->tail->next; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public function extractOption() { |
|
| 115 | - if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
| 116 | - $end = strpos($this->pattern, '}' , $this->i); |
|
| 117 | - if($end !== false) { |
|
| 118 | - $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
|
| 119 | - $this->i= $end + 1; |
|
| 120 | - return $r; |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - return null; |
|
| 124 | - } |
|
| 111 | + /** |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public function extractOption() { |
|
| 115 | + if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
| 116 | + $end = strpos($this->pattern, '}' , $this->i); |
|
| 117 | + if($end !== false) { |
|
| 118 | + $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
|
| 119 | + $this->i= $end + 1; |
|
| 120 | + return $r; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + return null; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * The option is expected to be in decimal and positive. In case of |
|
| 128 | - * error, zero is returned. |
|
| 129 | - */ |
|
| 130 | - public function extractPrecisionOption() { |
|
| 131 | - $opt = $this->extractOption(); |
|
| 132 | - $r = 0; |
|
| 133 | - if($opt !== null) { |
|
| 134 | - if(is_numeric($opt)) { |
|
| 135 | - $r = (int)$opt; |
|
| 136 | - if($r <= 0) { |
|
| 137 | - $r = 0; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - return $r; |
|
| 142 | - } |
|
| 126 | + /** |
|
| 127 | + * The option is expected to be in decimal and positive. In case of |
|
| 128 | + * error, zero is returned. |
|
| 129 | + */ |
|
| 130 | + public function extractPrecisionOption() { |
|
| 131 | + $opt = $this->extractOption(); |
|
| 132 | + $r = 0; |
|
| 133 | + if($opt !== null) { |
|
| 134 | + if(is_numeric($opt)) { |
|
| 135 | + $r = (int)$opt; |
|
| 136 | + if($r <= 0) { |
|
| 137 | + $r = 0; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + return $r; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | - /** Parser. |
|
| 146 | - * |
|
| 147 | - * @return LoggerPatternConverter Returns $this->head. |
|
| 148 | - */ |
|
| 149 | - public function parse() { |
|
| 150 | - $c = ''; |
|
| 151 | - $this->i = 0; |
|
| 152 | - $this->currentLiteral = ''; |
|
| 153 | - while($this->i < $this->patternLength) { |
|
| 154 | - $c = $this->pattern{$this->i++}; |
|
| 145 | + /** Parser. |
|
| 146 | + * |
|
| 147 | + * @return LoggerPatternConverter Returns $this->head. |
|
| 148 | + */ |
|
| 149 | + public function parse() { |
|
| 150 | + $c = ''; |
|
| 151 | + $this->i = 0; |
|
| 152 | + $this->currentLiteral = ''; |
|
| 153 | + while($this->i < $this->patternLength) { |
|
| 154 | + $c = $this->pattern{$this->i++}; |
|
| 155 | 155 | |
| 156 | - switch($this->state) { |
|
| 157 | - case self::LITERAL_STATE: |
|
| 158 | - // In literal state, the last char is always a literal. |
|
| 159 | - if($this->i == $this->patternLength) { |
|
| 160 | - $this->currentLiteral .= $c; |
|
| 161 | - continue; |
|
| 162 | - } |
|
| 163 | - if($c == self::ESCAPE_CHAR) { |
|
| 164 | - // peek at the next char. |
|
| 165 | - switch($this->pattern{$this->i}) { |
|
| 166 | - case self::ESCAPE_CHAR: |
|
| 167 | - $this->currentLiteral .= $c; |
|
| 168 | - $this->i++; // move pointer |
|
| 169 | - break; |
|
| 170 | - case 'n': |
|
| 171 | - $this->currentLiteral .= PHP_EOL; |
|
| 172 | - $this->i++; // move pointer |
|
| 173 | - break; |
|
| 174 | - default: |
|
| 175 | - if(strlen($this->currentLiteral) != 0) { |
|
| 176 | - $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
| 177 | - } |
|
| 178 | - $this->currentLiteral = $c; |
|
| 179 | - $this->state = self::CONVERTER_STATE; |
|
| 180 | - $this->formattingInfo->reset(); |
|
| 181 | - } |
|
| 182 | - } else { |
|
| 183 | - $this->currentLiteral .= $c; |
|
| 184 | - } |
|
| 185 | - break; |
|
| 186 | - case self::CONVERTER_STATE: |
|
| 187 | - $this->currentLiteral .= $c; |
|
| 188 | - switch($c) { |
|
| 189 | - case '-': |
|
| 190 | - $this->formattingInfo->leftAlign = true; |
|
| 191 | - break; |
|
| 192 | - case '.': |
|
| 193 | - $this->state = self::DOT_STATE; |
|
| 194 | - break; |
|
| 195 | - default: |
|
| 196 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 197 | - $this->formattingInfo->min = ord($c) - ord('0'); |
|
| 198 | - $this->state = self::MIN_STATE; |
|
| 199 | - } else { |
|
| 200 | - $this->finalizeConverter($c); |
|
| 201 | - } |
|
| 202 | - } // switch |
|
| 203 | - break; |
|
| 204 | - case self::MIN_STATE: |
|
| 205 | - $this->currentLiteral .= $c; |
|
| 206 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 207 | - $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0')); |
|
| 208 | - } else if ($c == '.') { |
|
| 209 | - $this->state = self::DOT_STATE; |
|
| 210 | - } else { |
|
| 211 | - $this->finalizeConverter($c); |
|
| 212 | - } |
|
| 213 | - break; |
|
| 214 | - case self::DOT_STATE: |
|
| 215 | - $this->currentLiteral .= $c; |
|
| 216 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 217 | - $this->formattingInfo->max = ord($c) - ord('0'); |
|
| 218 | - $this->state = self::MAX_STATE; |
|
| 219 | - } else { |
|
| 220 | - $this->state = self::LITERAL_STATE; |
|
| 221 | - } |
|
| 222 | - break; |
|
| 223 | - case self::MAX_STATE: |
|
| 224 | - $this->currentLiteral .= $c; |
|
| 225 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 226 | - $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
|
| 227 | - } else { |
|
| 228 | - $this->finalizeConverter($c); |
|
| 229 | - $this->state = self::LITERAL_STATE; |
|
| 230 | - } |
|
| 231 | - break; |
|
| 232 | - } // switch |
|
| 233 | - } // while |
|
| 234 | - if(strlen($this->currentLiteral) != 0) { |
|
| 235 | - $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
| 236 | - } |
|
| 237 | - return $this->head; |
|
| 238 | - } |
|
| 156 | + switch($this->state) { |
|
| 157 | + case self::LITERAL_STATE: |
|
| 158 | + // In literal state, the last char is always a literal. |
|
| 159 | + if($this->i == $this->patternLength) { |
|
| 160 | + $this->currentLiteral .= $c; |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 163 | + if($c == self::ESCAPE_CHAR) { |
|
| 164 | + // peek at the next char. |
|
| 165 | + switch($this->pattern{$this->i}) { |
|
| 166 | + case self::ESCAPE_CHAR: |
|
| 167 | + $this->currentLiteral .= $c; |
|
| 168 | + $this->i++; // move pointer |
|
| 169 | + break; |
|
| 170 | + case 'n': |
|
| 171 | + $this->currentLiteral .= PHP_EOL; |
|
| 172 | + $this->i++; // move pointer |
|
| 173 | + break; |
|
| 174 | + default: |
|
| 175 | + if(strlen($this->currentLiteral) != 0) { |
|
| 176 | + $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
| 177 | + } |
|
| 178 | + $this->currentLiteral = $c; |
|
| 179 | + $this->state = self::CONVERTER_STATE; |
|
| 180 | + $this->formattingInfo->reset(); |
|
| 181 | + } |
|
| 182 | + } else { |
|
| 183 | + $this->currentLiteral .= $c; |
|
| 184 | + } |
|
| 185 | + break; |
|
| 186 | + case self::CONVERTER_STATE: |
|
| 187 | + $this->currentLiteral .= $c; |
|
| 188 | + switch($c) { |
|
| 189 | + case '-': |
|
| 190 | + $this->formattingInfo->leftAlign = true; |
|
| 191 | + break; |
|
| 192 | + case '.': |
|
| 193 | + $this->state = self::DOT_STATE; |
|
| 194 | + break; |
|
| 195 | + default: |
|
| 196 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 197 | + $this->formattingInfo->min = ord($c) - ord('0'); |
|
| 198 | + $this->state = self::MIN_STATE; |
|
| 199 | + } else { |
|
| 200 | + $this->finalizeConverter($c); |
|
| 201 | + } |
|
| 202 | + } // switch |
|
| 203 | + break; |
|
| 204 | + case self::MIN_STATE: |
|
| 205 | + $this->currentLiteral .= $c; |
|
| 206 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 207 | + $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0')); |
|
| 208 | + } else if ($c == '.') { |
|
| 209 | + $this->state = self::DOT_STATE; |
|
| 210 | + } else { |
|
| 211 | + $this->finalizeConverter($c); |
|
| 212 | + } |
|
| 213 | + break; |
|
| 214 | + case self::DOT_STATE: |
|
| 215 | + $this->currentLiteral .= $c; |
|
| 216 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 217 | + $this->formattingInfo->max = ord($c) - ord('0'); |
|
| 218 | + $this->state = self::MAX_STATE; |
|
| 219 | + } else { |
|
| 220 | + $this->state = self::LITERAL_STATE; |
|
| 221 | + } |
|
| 222 | + break; |
|
| 223 | + case self::MAX_STATE: |
|
| 224 | + $this->currentLiteral .= $c; |
|
| 225 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 226 | + $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
|
| 227 | + } else { |
|
| 228 | + $this->finalizeConverter($c); |
|
| 229 | + $this->state = self::LITERAL_STATE; |
|
| 230 | + } |
|
| 231 | + break; |
|
| 232 | + } // switch |
|
| 233 | + } // while |
|
| 234 | + if(strlen($this->currentLiteral) != 0) { |
|
| 235 | + $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
| 236 | + } |
|
| 237 | + return $this->head; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - public function finalizeConverter($c) { |
|
| 241 | - $pc = null; |
|
| 242 | - switch($c) { |
|
| 243 | - case 'c': |
|
| 244 | - $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
| 245 | - $this->currentLiteral = ''; |
|
| 246 | - break; |
|
| 247 | - case 'C': |
|
| 248 | - $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
| 249 | - $this->currentLiteral = ''; |
|
| 250 | - break; |
|
| 251 | - case 'd': |
|
| 252 | - $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
|
| 253 | - $dOpt = $this->extractOption(); |
|
| 240 | + public function finalizeConverter($c) { |
|
| 241 | + $pc = null; |
|
| 242 | + switch($c) { |
|
| 243 | + case 'c': |
|
| 244 | + $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
| 245 | + $this->currentLiteral = ''; |
|
| 246 | + break; |
|
| 247 | + case 'C': |
|
| 248 | + $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
| 249 | + $this->currentLiteral = ''; |
|
| 250 | + break; |
|
| 251 | + case 'd': |
|
| 252 | + $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
|
| 253 | + $dOpt = $this->extractOption(); |
|
| 254 | 254 | |
| 255 | - if($dOpt !== null) |
|
| 256 | - $dateFormatStr = $dOpt; |
|
| 255 | + if($dOpt !== null) |
|
| 256 | + $dateFormatStr = $dOpt; |
|
| 257 | 257 | |
| 258 | - if($dateFormatStr == 'ISO8601') { |
|
| 259 | - $df = self::DATE_FORMAT_ISO8601; |
|
| 260 | - } else if($dateFormatStr == 'ABSOLUTE') { |
|
| 261 | - $df = self::DATE_FORMAT_ABSOLUTE; |
|
| 262 | - } else if($dateFormatStr == 'DATE') { |
|
| 263 | - $df = self::DATE_FORMAT_DATE; |
|
| 264 | - } else { |
|
| 265 | - $df = $dateFormatStr; |
|
| 266 | - if($df == null) { |
|
| 267 | - $df = self::DATE_FORMAT_ISO8601; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - $pc = new LoggerDatePatternConverter($this->formattingInfo, $df); |
|
| 271 | - $this->currentLiteral = ''; |
|
| 272 | - break; |
|
| 273 | - case 'F': |
|
| 274 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER); |
|
| 275 | - $this->currentLiteral = ''; |
|
| 276 | - break; |
|
| 277 | - case 'l': |
|
| 278 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER); |
|
| 279 | - $this->currentLiteral = ''; |
|
| 280 | - break; |
|
| 281 | - case 'L': |
|
| 282 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER); |
|
| 283 | - $this->currentLiteral = ''; |
|
| 284 | - break; |
|
| 285 | - case 'm': |
|
| 286 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER); |
|
| 287 | - $this->currentLiteral = ''; |
|
| 288 | - break; |
|
| 289 | - case 'M': |
|
| 290 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER); |
|
| 291 | - $this->currentLiteral = ''; |
|
| 292 | - break; |
|
| 293 | - case 'p': |
|
| 294 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER); |
|
| 295 | - $this->currentLiteral = ''; |
|
| 296 | - break; |
|
| 297 | - case 'r': |
|
| 298 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER); |
|
| 299 | - $this->currentLiteral = ''; |
|
| 300 | - break; |
|
| 301 | - case 't': |
|
| 302 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER); |
|
| 303 | - $this->currentLiteral = ''; |
|
| 304 | - break; |
|
| 305 | - case 'u': |
|
| 306 | - if($this->i < $this->patternLength) { |
|
| 307 | - $cNext = $this->pattern{$this->i}; |
|
| 308 | - if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
| 309 | - $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
| 310 | - $this->currentLiteral = ''; |
|
| 311 | - $this->i++; |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - break; |
|
| 315 | - case 'x': |
|
| 316 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER); |
|
| 317 | - $this->currentLiteral = ''; |
|
| 318 | - break; |
|
| 319 | - case 'X': |
|
| 320 | - $xOpt = $this->extractOption(); |
|
| 321 | - $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt); |
|
| 322 | - $this->currentLiteral = ''; |
|
| 323 | - break; |
|
| 324 | - default: |
|
| 325 | - $pc = new LoggerLiteralPatternConverter($this->currentLiteral); |
|
| 326 | - $this->currentLiteral = ''; |
|
| 327 | - } |
|
| 328 | - $this->addConverter($pc); |
|
| 329 | - } |
|
| 258 | + if($dateFormatStr == 'ISO8601') { |
|
| 259 | + $df = self::DATE_FORMAT_ISO8601; |
|
| 260 | + } else if($dateFormatStr == 'ABSOLUTE') { |
|
| 261 | + $df = self::DATE_FORMAT_ABSOLUTE; |
|
| 262 | + } else if($dateFormatStr == 'DATE') { |
|
| 263 | + $df = self::DATE_FORMAT_DATE; |
|
| 264 | + } else { |
|
| 265 | + $df = $dateFormatStr; |
|
| 266 | + if($df == null) { |
|
| 267 | + $df = self::DATE_FORMAT_ISO8601; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + $pc = new LoggerDatePatternConverter($this->formattingInfo, $df); |
|
| 271 | + $this->currentLiteral = ''; |
|
| 272 | + break; |
|
| 273 | + case 'F': |
|
| 274 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER); |
|
| 275 | + $this->currentLiteral = ''; |
|
| 276 | + break; |
|
| 277 | + case 'l': |
|
| 278 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER); |
|
| 279 | + $this->currentLiteral = ''; |
|
| 280 | + break; |
|
| 281 | + case 'L': |
|
| 282 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER); |
|
| 283 | + $this->currentLiteral = ''; |
|
| 284 | + break; |
|
| 285 | + case 'm': |
|
| 286 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER); |
|
| 287 | + $this->currentLiteral = ''; |
|
| 288 | + break; |
|
| 289 | + case 'M': |
|
| 290 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER); |
|
| 291 | + $this->currentLiteral = ''; |
|
| 292 | + break; |
|
| 293 | + case 'p': |
|
| 294 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER); |
|
| 295 | + $this->currentLiteral = ''; |
|
| 296 | + break; |
|
| 297 | + case 'r': |
|
| 298 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER); |
|
| 299 | + $this->currentLiteral = ''; |
|
| 300 | + break; |
|
| 301 | + case 't': |
|
| 302 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER); |
|
| 303 | + $this->currentLiteral = ''; |
|
| 304 | + break; |
|
| 305 | + case 'u': |
|
| 306 | + if($this->i < $this->patternLength) { |
|
| 307 | + $cNext = $this->pattern{$this->i}; |
|
| 308 | + if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
| 309 | + $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
| 310 | + $this->currentLiteral = ''; |
|
| 311 | + $this->i++; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + break; |
|
| 315 | + case 'x': |
|
| 316 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER); |
|
| 317 | + $this->currentLiteral = ''; |
|
| 318 | + break; |
|
| 319 | + case 'X': |
|
| 320 | + $xOpt = $this->extractOption(); |
|
| 321 | + $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt); |
|
| 322 | + $this->currentLiteral = ''; |
|
| 323 | + break; |
|
| 324 | + default: |
|
| 325 | + $pc = new LoggerLiteralPatternConverter($this->currentLiteral); |
|
| 326 | + $this->currentLiteral = ''; |
|
| 327 | + } |
|
| 328 | + $this->addConverter($pc); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - public function addConverter($pc) { |
|
| 332 | - $this->currentLiteral = ''; |
|
| 333 | - // Add the pattern converter to the list. |
|
| 334 | - $this->addToList($pc); |
|
| 335 | - // Next pattern is assumed to be a literal. |
|
| 336 | - $this->state = self::LITERAL_STATE; |
|
| 337 | - // Reset formatting info |
|
| 338 | - $this->formattingInfo->reset(); |
|
| 339 | - } |
|
| 331 | + public function addConverter($pc) { |
|
| 332 | + $this->currentLiteral = ''; |
|
| 333 | + // Add the pattern converter to the list. |
|
| 334 | + $this->addToList($pc); |
|
| 335 | + // Next pattern is assumed to be a literal. |
|
| 336 | + $this->state = self::LITERAL_STATE; |
|
| 337 | + // Reset formatting info |
|
| 338 | + $this->formattingInfo->reset(); |
|
| 339 | + } |
|
| 340 | 340 | } |
| 341 | 341 | |
@@ -169,6 +169,7 @@ |
||
| 169 | 169 | * Set the <b>ConversionPattern</b> option. This is the string which |
| 170 | 170 | * controls formatting and consists of a mix of literal content and |
| 171 | 171 | * conversion specifiers. |
| 172 | + * @param string $conversionPattern |
|
| 172 | 173 | */ |
| 173 | 174 | public function setConversionPattern($conversionPattern) { |
| 174 | 175 | $this->pattern = $conversionPattern; |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | - * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | - * this work for additional information regarding copyright ownership. |
|
| 6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | - * (the "License"); you may not use this file except in compliance with |
|
| 8 | - * the License. You may obtain a copy of the License at |
|
| 9 | - * |
|
| 10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | - * |
|
| 12 | - * Unless required by applicable law or agreed to in writing, software |
|
| 13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | - * See the License for the specific language governing permissions and |
|
| 16 | - * limitations under the License. |
|
| 17 | - * |
|
| 18 | - * @package log4php |
|
| 19 | - */ |
|
| 3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | + * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | + * this work for additional information regarding copyright ownership. |
|
| 6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | + * (the "License"); you may not use this file except in compliance with |
|
| 8 | + * the License. You may obtain a copy of the License at |
|
| 9 | + * |
|
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | + * |
|
| 12 | + * Unless required by applicable law or agreed to in writing, software |
|
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | + * See the License for the specific language governing permissions and |
|
| 16 | + * limitations under the License. |
|
| 17 | + * |
|
| 18 | + * @package log4php |
|
| 19 | + */ |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * A flexible layout configurable with pattern string. |
@@ -136,61 +136,61 @@ discard block |
||
| 136 | 136 | * @since 0.3 |
| 137 | 137 | */ |
| 138 | 138 | class LoggerLayoutPattern extends LoggerLayout { |
| 139 | - /** Default conversion Pattern */ |
|
| 140 | - const DEFAULT_CONVERSION_PATTERN = '%m%n'; |
|
| 139 | + /** Default conversion Pattern */ |
|
| 140 | + const DEFAULT_CONVERSION_PATTERN = '%m%n'; |
|
| 141 | 141 | |
| 142 | - /** Default conversion TTCC Pattern */ |
|
| 143 | - const TTCC_CONVERSION_PATTERN = '%r [%t] %p %c %x - %m%n'; |
|
| 142 | + /** Default conversion TTCC Pattern */ |
|
| 143 | + const TTCC_CONVERSION_PATTERN = '%r [%t] %p %c %x - %m%n'; |
|
| 144 | 144 | |
| 145 | - /** The pattern. |
|
| 146 | - * @var string */ |
|
| 147 | - private $pattern; |
|
| 145 | + /** The pattern. |
|
| 146 | + * @var string */ |
|
| 147 | + private $pattern; |
|
| 148 | 148 | |
| 149 | - /** Head of a chain of Converters. |
|
| 150 | - * @var LoggerPatternConverter */ |
|
| 151 | - private $head; |
|
| 149 | + /** Head of a chain of Converters. |
|
| 150 | + * @var LoggerPatternConverter */ |
|
| 151 | + private $head; |
|
| 152 | 152 | |
| 153 | - private $timezone; |
|
| 153 | + private $timezone; |
|
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * Constructs a PatternLayout using the |
|
| 157 | - * {@link DEFAULT_LAYOUT_PATTERN}. |
|
| 158 | - * The default pattern just produces the application supplied message. |
|
| 159 | - */ |
|
| 160 | - public function __construct($pattern = null) { |
|
| 161 | - if ($pattern === null) { |
|
| 162 | - $this->pattern = self :: DEFAULT_CONVERSION_PATTERN; |
|
| 163 | - } else { |
|
| 164 | - $this->pattern = $pattern; |
|
| 165 | - } |
|
| 166 | - } |
|
| 155 | + /** |
|
| 156 | + * Constructs a PatternLayout using the |
|
| 157 | + * {@link DEFAULT_LAYOUT_PATTERN}. |
|
| 158 | + * The default pattern just produces the application supplied message. |
|
| 159 | + */ |
|
| 160 | + public function __construct($pattern = null) { |
|
| 161 | + if ($pattern === null) { |
|
| 162 | + $this->pattern = self :: DEFAULT_CONVERSION_PATTERN; |
|
| 163 | + } else { |
|
| 164 | + $this->pattern = $pattern; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Set the <b>ConversionPattern</b> option. This is the string which |
|
| 170 | - * controls formatting and consists of a mix of literal content and |
|
| 171 | - * conversion specifiers. |
|
| 172 | - */ |
|
| 173 | - public function setConversionPattern($conversionPattern) { |
|
| 174 | - $this->pattern = $conversionPattern; |
|
| 175 | - $patternParser = new LoggerPatternParser($this->pattern); |
|
| 176 | - $this->head = $patternParser->parse(); |
|
| 177 | - } |
|
| 168 | + /** |
|
| 169 | + * Set the <b>ConversionPattern</b> option. This is the string which |
|
| 170 | + * controls formatting and consists of a mix of literal content and |
|
| 171 | + * conversion specifiers. |
|
| 172 | + */ |
|
| 173 | + public function setConversionPattern($conversionPattern) { |
|
| 174 | + $this->pattern = $conversionPattern; |
|
| 175 | + $patternParser = new LoggerPatternParser($this->pattern); |
|
| 176 | + $this->head = $patternParser->parse(); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Produces a formatted string as specified by the conversion pattern. |
|
| 181 | - * |
|
| 182 | - * @param LoggerLoggingEvent $event |
|
| 183 | - * @return string |
|
| 184 | - */ |
|
| 185 | - public function format(LoggerLoggingEvent $event) { |
|
| 186 | - $sbuf = ''; |
|
| 187 | - $c = $this->head; |
|
| 188 | - while ($c !== null) { |
|
| 189 | - $c->format($sbuf, $event); |
|
| 190 | - $c = $c->next; |
|
| 191 | - } |
|
| 192 | - return $sbuf; |
|
| 193 | - } |
|
| 179 | + /** |
|
| 180 | + * Produces a formatted string as specified by the conversion pattern. |
|
| 181 | + * |
|
| 182 | + * @param LoggerLoggingEvent $event |
|
| 183 | + * @return string |
|
| 184 | + */ |
|
| 185 | + public function format(LoggerLoggingEvent $event) { |
|
| 186 | + $sbuf = ''; |
|
| 187 | + $c = $this->head; |
|
| 188 | + while ($c !== null) { |
|
| 189 | + $c->format($sbuf, $event); |
|
| 190 | + $c = $c->next; |
|
| 191 | + } |
|
| 192 | + return $sbuf; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | 196 | * Returns an array with the formatted elements. |
@@ -206,7 +206,7 @@ |
||
| 206 | 206 | $results = array(); |
| 207 | 207 | $c = $this->head; |
| 208 | 208 | while ($c !== null) { |
| 209 | - if ( ! $c instanceOf LoggerLiteralPatternConverter) { |
|
| 209 | + if (!$c instanceOf LoggerLiteralPatternConverter) { |
|
| 210 | 210 | $sbuf = null; |
| 211 | 211 | $c->format($sbuf, $event); |
| 212 | 212 | $results[] = $sbuf; |