@@ -46,125 +46,125 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | class LoggerAppenderMailEvent extends LoggerAppenderSkeleton { |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var string 'from' field |
|
| 51 | - */ |
|
| 52 | - public $from = null; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @var integer 'from' field |
|
| 56 | - */ |
|
| 57 | - public $port = 25; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var string hostname. |
|
| 61 | - */ |
|
| 62 | - public $smtpHost = null; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @var string 'subject' field |
|
| 66 | - */ |
|
| 67 | - public $subject = ''; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @var string 'to' field |
|
| 71 | - */ |
|
| 72 | - public $to = null; |
|
| 49 | + /** |
|
| 50 | + * @var string 'from' field |
|
| 51 | + */ |
|
| 52 | + public $from = null; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @var integer 'from' field |
|
| 56 | + */ |
|
| 57 | + public $port = 25; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var string hostname. |
|
| 61 | + */ |
|
| 62 | + public $smtpHost = null; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @var string 'subject' field |
|
| 66 | + */ |
|
| 67 | + public $subject = ''; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @var string 'to' field |
|
| 71 | + */ |
|
| 72 | + public $to = null; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @access private |
|
| 76 | - */ |
|
| 77 | - public $requiresLayout = true; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Constructor. |
|
| 81 | - * |
|
| 82 | - * @param string $name appender name |
|
| 83 | - */ |
|
| 84 | - public function LoggerAppenderMailEvent($name) |
|
| 85 | - { |
|
| 86 | - $this->LoggerAppenderSkeleton($name); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - public function activateOptions() |
|
| 90 | - { |
|
| 91 | - $this->closed = false; |
|
| 92 | - } |
|
| 74 | + /** |
|
| 75 | + * @access private |
|
| 76 | + */ |
|
| 77 | + public $requiresLayout = true; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Constructor. |
|
| 81 | + * |
|
| 82 | + * @param string $name appender name |
|
| 83 | + */ |
|
| 84 | + public function LoggerAppenderMailEvent($name) |
|
| 85 | + { |
|
| 86 | + $this->LoggerAppenderSkeleton($name); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + public function activateOptions() |
|
| 90 | + { |
|
| 91 | + $this->closed = false; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public function close() |
|
| 95 | - { |
|
| 96 | - $this->closed = true; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - public function getFrom() { return $this->from; } |
|
| 94 | + public function close() |
|
| 95 | + { |
|
| 96 | + $this->closed = true; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + public function getFrom() { return $this->from; } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * @return integer |
|
| 106 | - */ |
|
| 107 | - public function getPort() { return $this->port; } |
|
| 104 | + /** |
|
| 105 | + * @return integer |
|
| 106 | + */ |
|
| 107 | + public function getPort() { return $this->port; } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @return string |
|
| 111 | - */ |
|
| 112 | - public function getSmtpHost() { return $this->smtpHost; } |
|
| 109 | + /** |
|
| 110 | + * @return string |
|
| 111 | + */ |
|
| 112 | + public function getSmtpHost() { return $this->smtpHost; } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * @return string |
|
| 116 | - */ |
|
| 117 | - public function getSubject() { return $this->subject; } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - public function getTo() { return $this->to; } |
|
| 123 | - |
|
| 124 | - public function setFrom($from) { $this->from = $from; } |
|
| 125 | - public function setPort($port) { $this->port = (int)$port; } |
|
| 126 | - public function setSmtpHost($smtphost) { $this->smtpHost = $smtpHost; } |
|
| 127 | - public function setSubject($subject) { $this->subject = $subject; } |
|
| 128 | - public function setTo($to) { $this->to = $to; } |
|
| 129 | - |
|
| 130 | - public function append($event) |
|
| 131 | - { |
|
| 132 | - $from = $this->getFrom(); |
|
| 133 | - $to = $this->getTo(); |
|
| 134 | - if (empty($from) || empty($to)) |
|
| 135 | - return; |
|
| 114 | + /** |
|
| 115 | + * @return string |
|
| 116 | + */ |
|
| 117 | + public function getSubject() { return $this->subject; } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + public function getTo() { return $this->to; } |
|
| 123 | + |
|
| 124 | + public function setFrom($from) { $this->from = $from; } |
|
| 125 | + public function setPort($port) { $this->port = (int)$port; } |
|
| 126 | + public function setSmtpHost($smtphost) { $this->smtpHost = $smtpHost; } |
|
| 127 | + public function setSubject($subject) { $this->subject = $subject; } |
|
| 128 | + public function setTo($to) { $this->to = $to; } |
|
| 129 | + |
|
| 130 | + public function append($event) |
|
| 131 | + { |
|
| 132 | + $from = $this->getFrom(); |
|
| 133 | + $to = $this->getTo(); |
|
| 134 | + if (empty($from) || empty($to)) |
|
| 135 | + return; |
|
| 136 | 136 | |
| 137 | - $smtpHost = $this->getSmtpHost(); |
|
| 138 | - $prevSmtpHost = ini_get('SMTP'); |
|
| 139 | - if (!empty($smtpHost)) { |
|
| 140 | - ini_set('SMTP', $smtpHost); |
|
| 141 | - } else { |
|
| 142 | - $smtpHost = $prevSmtpHost; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - $smtpPort = $this->getPort(); |
|
| 146 | - $prevSmtpPort= ini_get('smtp_port'); |
|
| 147 | - if ($smtpPort > 0 && $smtpPort < 65535) { |
|
| 148 | - ini_set('smtp_port', $smtpPort); |
|
| 149 | - } else { |
|
| 150 | - $smtpPort = $prevSmtpPort; |
|
| 151 | - } |
|
| 137 | + $smtpHost = $this->getSmtpHost(); |
|
| 138 | + $prevSmtpHost = ini_get('SMTP'); |
|
| 139 | + if (!empty($smtpHost)) { |
|
| 140 | + ini_set('SMTP', $smtpHost); |
|
| 141 | + } else { |
|
| 142 | + $smtpHost = $prevSmtpHost; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + $smtpPort = $this->getPort(); |
|
| 146 | + $prevSmtpPort= ini_get('smtp_port'); |
|
| 147 | + if ($smtpPort > 0 && $smtpPort < 65535) { |
|
| 148 | + ini_set('smtp_port', $smtpPort); |
|
| 149 | + } else { |
|
| 150 | + $smtpPort = $prevSmtpPort; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - LoggerLog::debug( |
|
| 154 | - "LoggerAppenderMailEvent::append()" . |
|
| 155 | - ":from=[{$from}]:to=[{$to}]:smtpHost=[{$smtpHost}]:smtpPort=[{$smtpPort}]" |
|
| 156 | - ); |
|
| 153 | + LoggerLog::debug( |
|
| 154 | + "LoggerAppenderMailEvent::append()" . |
|
| 155 | + ":from=[{$from}]:to=[{$to}]:smtpHost=[{$smtpHost}]:smtpPort=[{$smtpPort}]" |
|
| 156 | + ); |
|
| 157 | 157 | |
| 158 | - if (!@mail( $to, $this->getSubject(), |
|
| 159 | - $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), |
|
| 160 | - "From: {$from}\r\n" |
|
| 161 | - )) { |
|
| 162 | - LoggerLog::debug("LoggerAppenderMailEvent::append() mail error"); |
|
| 163 | - } |
|
| 158 | + if (!@mail( $to, $this->getSubject(), |
|
| 159 | + $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), |
|
| 160 | + "From: {$from}\r\n" |
|
| 161 | + )) { |
|
| 162 | + LoggerLog::debug("LoggerAppenderMailEvent::append() mail error"); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - ini_set('SMTP', $prevSmtpHost); |
|
| 166 | - ini_set('smtp_port', $prevSmtpPort); |
|
| 167 | - } |
|
| 165 | + ini_set('SMTP', $prevSmtpHost); |
|
| 166 | + ini_set('smtp_port', $prevSmtpPort); |
|
| 167 | + } |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | ?> |
| 171 | 171 | \ No newline at end of file |
@@ -49,27 +49,27 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * @var string 'from' field |
| 51 | 51 | */ |
| 52 | - public $from = null; |
|
| 52 | + public $from = null; |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @var integer 'from' field |
| 56 | 56 | */ |
| 57 | - public $port = 25; |
|
| 57 | + public $port = 25; |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @var string hostname. |
| 61 | 61 | */ |
| 62 | - public $smtpHost = null; |
|
| 62 | + public $smtpHost = null; |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @var string 'subject' field |
| 66 | 66 | */ |
| 67 | - public $subject = ''; |
|
| 67 | + public $subject = ''; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @var string 'to' field |
| 71 | 71 | */ |
| 72 | - public $to = null; |
|
| 72 | + public $to = null; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @access private |
@@ -99,33 +99,33 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * @return string |
| 101 | 101 | */ |
| 102 | - public function getFrom() { return $this->from; } |
|
| 102 | + public function getFrom() { return $this->from; } |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * @return integer |
| 106 | 106 | */ |
| 107 | - public function getPort() { return $this->port; } |
|
| 107 | + public function getPort() { return $this->port; } |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | - public function getSmtpHost() { return $this->smtpHost; } |
|
| 112 | + public function getSmtpHost() { return $this->smtpHost; } |
|
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | - public function getSubject() { return $this->subject; } |
|
| 117 | + public function getSubject() { return $this->subject; } |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * @return string |
| 121 | 121 | */ |
| 122 | - public function getTo() { return $this->to; } |
|
| 122 | + public function getTo() { return $this->to; } |
|
| 123 | 123 | |
| 124 | - public function setFrom($from) { $this->from = $from; } |
|
| 125 | - public function setPort($port) { $this->port = (int)$port; } |
|
| 126 | - public function setSmtpHost($smtphost) { $this->smtpHost = $smtpHost; } |
|
| 127 | - public function setSubject($subject) { $this->subject = $subject; } |
|
| 128 | - public function setTo($to) { $this->to = $to; } |
|
| 124 | + public function setFrom($from) { $this->from = $from; } |
|
| 125 | + public function setPort($port) { $this->port = (int) $port; } |
|
| 126 | + public function setSmtpHost($smtphost) { $this->smtpHost = $smtpHost; } |
|
| 127 | + public function setSubject($subject) { $this->subject = $subject; } |
|
| 128 | + public function setTo($to) { $this->to = $to; } |
|
| 129 | 129 | |
| 130 | 130 | public function append($event) |
| 131 | 131 | { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $smtpPort = $this->getPort(); |
| 146 | - $prevSmtpPort= ini_get('smtp_port'); |
|
| 146 | + $prevSmtpPort = ini_get('smtp_port'); |
|
| 147 | 147 | if ($smtpPort > 0 && $smtpPort < 65535) { |
| 148 | 148 | ini_set('smtp_port', $smtpPort); |
| 149 | 149 | } else { |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | ":from=[{$from}]:to=[{$to}]:smtpHost=[{$smtpHost}]:smtpPort=[{$smtpPort}]" |
| 156 | 156 | ); |
| 157 | 157 | |
| 158 | - if (!@mail( $to, $this->getSubject(), |
|
| 158 | + if (!@mail($to, $this->getSubject(), |
|
| 159 | 159 | $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), |
| 160 | 160 | "From: {$from}\r\n" |
| 161 | 161 | )) { |
| 162 | 162 | LoggerLog::debug("LoggerAppenderMailEvent::append() mail error"); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - ini_set('SMTP', $prevSmtpHost); |
|
| 166 | - ini_set('smtp_port', $prevSmtpPort); |
|
| 165 | + ini_set('SMTP', $prevSmtpHost); |
|
| 166 | + ini_set('smtp_port', $prevSmtpPort); |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | * Used by {@link LoggerPatternConverter::spacePad()}. |
| 32 | 32 | */ |
| 33 | 33 | $GLOBALS['log4php.LoggerPatternConverter.spaces'] = array(" ", " ", " ", " ", //1,2,4,8 spaces |
| 34 | - " ", // 16 spaces |
|
| 35 | - " " ); // 32 spaces |
|
| 34 | + " ", // 16 spaces |
|
| 35 | + " " ); // 32 spaces |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * LoggerPatternConverter is an abstract class that provides the formatting |
@@ -51,101 +51,101 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | class LoggerPatternConverter { |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var LoggerPatternConverter next converter in converter chain |
|
| 56 | - */ |
|
| 57 | - public $next = null; |
|
| 54 | + /** |
|
| 55 | + * @var LoggerPatternConverter next converter in converter chain |
|
| 56 | + */ |
|
| 57 | + public $next = null; |
|
| 58 | 58 | |
| 59 | - public $min = -1; |
|
| 60 | - public $max = 0x7FFFFFFF; |
|
| 61 | - public $leftAlign = false; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Constructor |
|
| 65 | - * |
|
| 66 | - * @param LoggerFormattingInfo $fi |
|
| 67 | - */ |
|
| 68 | - public function LoggerPatternConverter($fi = null) |
|
| 69 | - { |
|
| 70 | - if ($fi !== null) { |
|
| 71 | - $this->min = $fi->min; |
|
| 72 | - $this->max = $fi->max; |
|
| 73 | - $this->leftAlign = $fi->leftAlign; |
|
| 74 | - } |
|
| 75 | - } |
|
| 59 | + public $min = -1; |
|
| 60 | + public $max = 0x7FFFFFFF; |
|
| 61 | + public $leftAlign = false; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Constructor |
|
| 65 | + * |
|
| 66 | + * @param LoggerFormattingInfo $fi |
|
| 67 | + */ |
|
| 68 | + public function LoggerPatternConverter($fi = null) |
|
| 69 | + { |
|
| 70 | + if ($fi !== null) { |
|
| 71 | + $this->min = $fi->min; |
|
| 72 | + $this->max = $fi->max; |
|
| 73 | + $this->leftAlign = $fi->leftAlign; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Derived pattern converters must override this method in order to |
|
| 79 | - * convert conversion specifiers in the correct way. |
|
| 80 | - * |
|
| 81 | - * @param LoggerLoggingEvent $event |
|
| 82 | - */ |
|
| 83 | - public function convert($event) {} |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * A template method for formatting in a converter specific way. |
|
| 87 | - * |
|
| 88 | - * @param string &$sbuf string buffer |
|
| 89 | - * @param LoggerLoggingEvent $e |
|
| 90 | - */ |
|
| 91 | - public function format(&$sbuf, $e) |
|
| 92 | - { |
|
| 93 | - LoggerLog::debug("LoggerPatternConverter::format() sbuf='$sbuf'"); |
|
| 77 | + /** |
|
| 78 | + * Derived pattern converters must override this method in order to |
|
| 79 | + * convert conversion specifiers in the correct way. |
|
| 80 | + * |
|
| 81 | + * @param LoggerLoggingEvent $event |
|
| 82 | + */ |
|
| 83 | + public function convert($event) {} |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * A template method for formatting in a converter specific way. |
|
| 87 | + * |
|
| 88 | + * @param string &$sbuf string buffer |
|
| 89 | + * @param LoggerLoggingEvent $e |
|
| 90 | + */ |
|
| 91 | + public function format(&$sbuf, $e) |
|
| 92 | + { |
|
| 93 | + LoggerLog::debug("LoggerPatternConverter::format() sbuf='$sbuf'"); |
|
| 94 | 94 | |
| 95 | - $s = $this->convert($e); |
|
| 95 | + $s = $this->convert($e); |
|
| 96 | 96 | |
| 97 | - LoggerLog::debug("LoggerPatternConverter::format() converted event is '$s'"); |
|
| 97 | + LoggerLog::debug("LoggerPatternConverter::format() converted event is '$s'"); |
|
| 98 | 98 | |
| 99 | 99 | |
| 100 | - if($s == null || empty($s)) { |
|
| 101 | - if(0 < $this->min) |
|
| 102 | - $this->spacePad($sbuf, $this->min); |
|
| 103 | - return; |
|
| 104 | - } |
|
| 100 | + if($s == null || empty($s)) { |
|
| 101 | + if(0 < $this->min) |
|
| 102 | + $this->spacePad($sbuf, $this->min); |
|
| 103 | + return; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - $len = strlen($s); |
|
| 106 | + $len = strlen($s); |
|
| 107 | 107 | |
| 108 | - if($len > $this->max) { |
|
| 109 | - $sbuf .= substr($s , 0, ($len - $this->max)); |
|
| 110 | - } elseif($len < $this->min) { |
|
| 111 | - if($this->leftAlign) { |
|
| 112 | - $sbuf .= $s; |
|
| 113 | - $this->spacePad($sbuf, ($this->min - $len)); |
|
| 114 | - } else { |
|
| 115 | - $this->spacePad($sbuf, ($this->min - $len)); |
|
| 116 | - $sbuf .= $s; |
|
| 117 | - } |
|
| 118 | - } else { |
|
| 119 | - $sbuf .= $s; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Fast space padding method. |
|
| 126 | - * |
|
| 127 | - * @param string &$sbuf string buffer |
|
| 128 | - * @param integer $length pad length |
|
| 129 | - * |
|
| 130 | - * @todo reimplement using PHP string functions |
|
| 131 | - */ |
|
| 132 | - public function spacePad(&$sbuf, $length) |
|
| 133 | - { |
|
| 134 | - LoggerLog::debug("LoggerPatternConverter::spacePad() sbuf='$sbuf' len='$length'"); |
|
| 108 | + if($len > $this->max) { |
|
| 109 | + $sbuf .= substr($s , 0, ($len - $this->max)); |
|
| 110 | + } elseif($len < $this->min) { |
|
| 111 | + if($this->leftAlign) { |
|
| 112 | + $sbuf .= $s; |
|
| 113 | + $this->spacePad($sbuf, ($this->min - $len)); |
|
| 114 | + } else { |
|
| 115 | + $this->spacePad($sbuf, ($this->min - $len)); |
|
| 116 | + $sbuf .= $s; |
|
| 117 | + } |
|
| 118 | + } else { |
|
| 119 | + $sbuf .= $s; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Fast space padding method. |
|
| 126 | + * |
|
| 127 | + * @param string &$sbuf string buffer |
|
| 128 | + * @param integer $length pad length |
|
| 129 | + * |
|
| 130 | + * @todo reimplement using PHP string functions |
|
| 131 | + */ |
|
| 132 | + public function spacePad(&$sbuf, $length) |
|
| 133 | + { |
|
| 134 | + LoggerLog::debug("LoggerPatternConverter::spacePad() sbuf='$sbuf' len='$length'"); |
|
| 135 | 135 | |
| 136 | - while($length >= 32) { |
|
| 137 | - $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; |
|
| 138 | - $length -= 32; |
|
| 139 | - } |
|
| 136 | + while($length >= 32) { |
|
| 137 | + $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; |
|
| 138 | + $length -= 32; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - for($i = 4; $i >= 0; $i--) { |
|
| 142 | - if(($length & (1<<$i)) != 0) { |
|
| 143 | - $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // $sbuf = str_pad($sbuf, $length); |
|
| 148 | - } |
|
| 141 | + for($i = 4; $i >= 0; $i--) { |
|
| 142 | + if(($length & (1<<$i)) != 0) { |
|
| 143 | + $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // $sbuf = str_pad($sbuf, $length); |
|
| 148 | + } |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // --------------------------------------------------------------------- |
@@ -159,54 +159,54 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | class LoggerBasicPatternConverter extends LoggerPatternConverter { |
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * @var integer |
|
| 164 | - */ |
|
| 165 | - public $type; |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Constructor |
|
| 169 | - * |
|
| 170 | - * @param string $formattingInfo |
|
| 171 | - * @param integer $type |
|
| 172 | - */ |
|
| 173 | - public function LoggerBasicPatternConverter($formattingInfo, $type) |
|
| 174 | - { |
|
| 175 | - LoggerLog::debug("LoggerBasicPatternConverter::LoggerBasicPatternConverter() type='$type'"); |
|
| 162 | + /** |
|
| 163 | + * @var integer |
|
| 164 | + */ |
|
| 165 | + public $type; |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Constructor |
|
| 169 | + * |
|
| 170 | + * @param string $formattingInfo |
|
| 171 | + * @param integer $type |
|
| 172 | + */ |
|
| 173 | + public function LoggerBasicPatternConverter($formattingInfo, $type) |
|
| 174 | + { |
|
| 175 | + LoggerLog::debug("LoggerBasicPatternConverter::LoggerBasicPatternConverter() type='$type'"); |
|
| 176 | 176 | |
| 177 | - $this->LoggerPatternConverter($formattingInfo); |
|
| 178 | - $this->type = $type; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * @param LoggerLoggingEvent $event |
|
| 183 | - * @return string |
|
| 184 | - */ |
|
| 185 | - public function convert($event) |
|
| 186 | - { |
|
| 187 | - switch($this->type) { |
|
| 188 | - case LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER: |
|
| 189 | - $timeStamp = $event->getTimeStamp(); |
|
| 190 | - $startTime = LoggerLoggingEvent::getStartTime(); |
|
| 191 | - return (string)(int)($timeStamp * 1000 - $startTime * 1000); |
|
| 177 | + $this->LoggerPatternConverter($formattingInfo); |
|
| 178 | + $this->type = $type; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @param LoggerLoggingEvent $event |
|
| 183 | + * @return string |
|
| 184 | + */ |
|
| 185 | + public function convert($event) |
|
| 186 | + { |
|
| 187 | + switch($this->type) { |
|
| 188 | + case LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER: |
|
| 189 | + $timeStamp = $event->getTimeStamp(); |
|
| 190 | + $startTime = LoggerLoggingEvent::getStartTime(); |
|
| 191 | + return (string)(int)($timeStamp * 1000 - $startTime * 1000); |
|
| 192 | 192 | |
| 193 | - case LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER: |
|
| 194 | - return $event->getThreadName(); |
|
| 193 | + case LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER: |
|
| 194 | + return $event->getThreadName(); |
|
| 195 | 195 | |
| 196 | - case LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER: |
|
| 197 | - $level = $event->getLevel(); |
|
| 198 | - return $level->toString(); |
|
| 196 | + case LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER: |
|
| 197 | + $level = $event->getLevel(); |
|
| 198 | + return $level->toString(); |
|
| 199 | 199 | |
| 200 | - case LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER: |
|
| 201 | - return $event->getNDC(); |
|
| 200 | + case LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER: |
|
| 201 | + return $event->getNDC(); |
|
| 202 | 202 | |
| 203 | - case LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER: |
|
| 204 | - return $event->getRenderedMessage(); |
|
| 203 | + case LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER: |
|
| 204 | + return $event->getRenderedMessage(); |
|
| 205 | 205 | |
| 206 | - default: |
|
| 207 | - return ''; |
|
| 208 | - } |
|
| 209 | - } |
|
| 206 | + default: |
|
| 207 | + return ''; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -216,40 +216,40 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | class LoggerLiteralPatternConverter extends LoggerPatternConverter { |
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * @var string |
|
| 221 | - */ |
|
| 222 | - public $literal; |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Constructor |
|
| 226 | - * |
|
| 227 | - * @param string $value |
|
| 228 | - */ |
|
| 229 | - public function LoggerLiteralPatternConverter($value) |
|
| 230 | - { |
|
| 231 | - LoggerLog::debug("LoggerLiteralPatternConverter::LoggerLiteralPatternConverter() value='$value'"); |
|
| 219 | + /** |
|
| 220 | + * @var string |
|
| 221 | + */ |
|
| 222 | + public $literal; |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Constructor |
|
| 226 | + * |
|
| 227 | + * @param string $value |
|
| 228 | + */ |
|
| 229 | + public function LoggerLiteralPatternConverter($value) |
|
| 230 | + { |
|
| 231 | + LoggerLog::debug("LoggerLiteralPatternConverter::LoggerLiteralPatternConverter() value='$value'"); |
|
| 232 | 232 | |
| 233 | - $this->literal = $value; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * @param string &$sbuf |
|
| 238 | - * @param LoggerLoggingEvent $event |
|
| 239 | - */ |
|
| 240 | - public function format(&$sbuf, $event) |
|
| 241 | - { |
|
| 242 | - $sbuf .= $this->literal; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * @param LoggerLoggingEvent $event |
|
| 247 | - * @return string |
|
| 248 | - */ |
|
| 249 | - public function convert($event) |
|
| 250 | - { |
|
| 251 | - return $this->literal; |
|
| 252 | - } |
|
| 233 | + $this->literal = $value; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * @param string &$sbuf |
|
| 238 | + * @param LoggerLoggingEvent $event |
|
| 239 | + */ |
|
| 240 | + public function format(&$sbuf, $event) |
|
| 241 | + { |
|
| 242 | + $sbuf .= $this->literal; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * @param LoggerLoggingEvent $event |
|
| 247 | + * @return string |
|
| 248 | + */ |
|
| 249 | + public function convert($event) |
|
| 250 | + { |
|
| 251 | + return $this->literal; |
|
| 252 | + } |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -259,38 +259,38 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | class LoggerDatePatternConverter extends LoggerPatternConverter { |
| 261 | 261 | |
| 262 | - /** |
|
| 263 | - * @var string |
|
| 264 | - */ |
|
| 265 | - public $df; |
|
| 262 | + /** |
|
| 263 | + * @var string |
|
| 264 | + */ |
|
| 265 | + public $df; |
|
| 266 | 266 | |
| 267 | - /** |
|
| 268 | - * Constructor |
|
| 269 | - * |
|
| 270 | - * @param string $formattingInfo |
|
| 271 | - * @param string $df |
|
| 272 | - */ |
|
| 273 | - public function LoggerDatePatternConverter($formattingInfo, $df) |
|
| 274 | - { |
|
| 275 | - LoggerLog::debug("LoggerDatePatternConverter::LoggerDatePatternConverter() dateFormat='$df'"); |
|
| 267 | + /** |
|
| 268 | + * Constructor |
|
| 269 | + * |
|
| 270 | + * @param string $formattingInfo |
|
| 271 | + * @param string $df |
|
| 272 | + */ |
|
| 273 | + public function LoggerDatePatternConverter($formattingInfo, $df) |
|
| 274 | + { |
|
| 275 | + LoggerLog::debug("LoggerDatePatternConverter::LoggerDatePatternConverter() dateFormat='$df'"); |
|
| 276 | 276 | |
| 277 | - $this->LoggerPatternConverter($formattingInfo); |
|
| 278 | - $this->df = $df; |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * @param LoggerLoggingEvent $event |
|
| 283 | - * @return string |
|
| 284 | - */ |
|
| 285 | - public function convert($event) |
|
| 286 | - { |
|
| 287 | - $timeStamp = $event->getTimeStamp(); |
|
| 288 | - $usecs = round(($timeStamp - (int)$timeStamp) * 1000); |
|
| 289 | - $this->df = str_replace("\u", "u", ereg_replace("[^\\]u", sprintf(',%03d', $usecs), $this->df)); |
|
| 277 | + $this->LoggerPatternConverter($formattingInfo); |
|
| 278 | + $this->df = $df; |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * @param LoggerLoggingEvent $event |
|
| 283 | + * @return string |
|
| 284 | + */ |
|
| 285 | + public function convert($event) |
|
| 286 | + { |
|
| 287 | + $timeStamp = $event->getTimeStamp(); |
|
| 288 | + $usecs = round(($timeStamp - (int)$timeStamp) * 1000); |
|
| 289 | + $this->df = str_replace("\u", "u", ereg_replace("[^\\]u", sprintf(',%03d', $usecs), $this->df)); |
|
| 290 | 290 | |
| 291 | - return date($this->df, $event->getTimeStamp()); |
|
| 291 | + return date($this->df, $event->getTimeStamp()); |
|
| 292 | 292 | |
| 293 | - } |
|
| 293 | + } |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -300,33 +300,33 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | class LoggerMDCPatternConverter extends LoggerPatternConverter { |
| 302 | 302 | |
| 303 | - /** |
|
| 304 | - * @var string |
|
| 305 | - */ |
|
| 306 | - public $key; |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * Constructor |
|
| 310 | - * |
|
| 311 | - * @param string $formattingInfo |
|
| 312 | - * @param string $key |
|
| 313 | - */ |
|
| 314 | - public function LoggerMDCPatternConverter($formattingInfo, $key) |
|
| 315 | - { |
|
| 316 | - LoggerLog::debug("LoggerMDCPatternConverter::LoggerMDCPatternConverter() key='$key'"); |
|
| 317 | - |
|
| 318 | - $this->LoggerPatternConverter($formattingInfo); |
|
| 319 | - $this->key = $key; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * @param LoggerLoggingEvent $event |
|
| 324 | - * @return string |
|
| 325 | - */ |
|
| 326 | - public function convert($event) |
|
| 327 | - { |
|
| 328 | - return $event->getMDC($this->key); |
|
| 329 | - } |
|
| 303 | + /** |
|
| 304 | + * @var string |
|
| 305 | + */ |
|
| 306 | + public $key; |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * Constructor |
|
| 310 | + * |
|
| 311 | + * @param string $formattingInfo |
|
| 312 | + * @param string $key |
|
| 313 | + */ |
|
| 314 | + public function LoggerMDCPatternConverter($formattingInfo, $key) |
|
| 315 | + { |
|
| 316 | + LoggerLog::debug("LoggerMDCPatternConverter::LoggerMDCPatternConverter() key='$key'"); |
|
| 317 | + |
|
| 318 | + $this->LoggerPatternConverter($formattingInfo); |
|
| 319 | + $this->key = $key; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * @param LoggerLoggingEvent $event |
|
| 324 | + * @return string |
|
| 325 | + */ |
|
| 326 | + public function convert($event) |
|
| 327 | + { |
|
| 328 | + return $event->getMDC($this->key); |
|
| 329 | + } |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** |
@@ -336,45 +336,45 @@ discard block |
||
| 336 | 336 | */ |
| 337 | 337 | class LoggerLocationPatternConverter extends LoggerPatternConverter { |
| 338 | 338 | |
| 339 | - /** |
|
| 340 | - * @var integer |
|
| 341 | - */ |
|
| 342 | - public $type; |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Constructor |
|
| 346 | - * |
|
| 347 | - * @param string $formattingInfo |
|
| 348 | - * @param integer $type |
|
| 349 | - */ |
|
| 350 | - public function LoggerLocationPatternConverter($formattingInfo, $type) |
|
| 351 | - { |
|
| 352 | - LoggerLog::debug("LoggerLocationPatternConverter::LoggerLocationPatternConverter() type='$type'"); |
|
| 339 | + /** |
|
| 340 | + * @var integer |
|
| 341 | + */ |
|
| 342 | + public $type; |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Constructor |
|
| 346 | + * |
|
| 347 | + * @param string $formattingInfo |
|
| 348 | + * @param integer $type |
|
| 349 | + */ |
|
| 350 | + public function LoggerLocationPatternConverter($formattingInfo, $type) |
|
| 351 | + { |
|
| 352 | + LoggerLog::debug("LoggerLocationPatternConverter::LoggerLocationPatternConverter() type='$type'"); |
|
| 353 | 353 | |
| 354 | - $this->LoggerPatternConverter($formattingInfo); |
|
| 355 | - $this->type = $type; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * @param LoggerLoggingEvent $event |
|
| 360 | - * @return string |
|
| 361 | - */ |
|
| 362 | - public function convert($event) |
|
| 363 | - { |
|
| 364 | - $locationInfo = $event->getLocationInformation(); |
|
| 365 | - switch($this->type) { |
|
| 366 | - case LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER: |
|
| 367 | - return $locationInfo->fullInfo; |
|
| 368 | - case LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER: |
|
| 369 | - return $locationInfo->getMethodName(); |
|
| 370 | - case LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER: |
|
| 371 | - return $locationInfo->getLineNumber(); |
|
| 372 | - case LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER: |
|
| 373 | - return $locationInfo->getFileName(); |
|
| 374 | - default: |
|
| 375 | - return ''; |
|
| 376 | - } |
|
| 377 | - } |
|
| 354 | + $this->LoggerPatternConverter($formattingInfo); |
|
| 355 | + $this->type = $type; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * @param LoggerLoggingEvent $event |
|
| 360 | + * @return string |
|
| 361 | + */ |
|
| 362 | + public function convert($event) |
|
| 363 | + { |
|
| 364 | + $locationInfo = $event->getLocationInformation(); |
|
| 365 | + switch($this->type) { |
|
| 366 | + case LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER: |
|
| 367 | + return $locationInfo->fullInfo; |
|
| 368 | + case LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER: |
|
| 369 | + return $locationInfo->getMethodName(); |
|
| 370 | + case LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER: |
|
| 371 | + return $locationInfo->getLineNumber(); |
|
| 372 | + case LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER: |
|
| 373 | + return $locationInfo->getFileName(); |
|
| 374 | + default: |
|
| 375 | + return ''; |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -385,60 +385,60 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | class LoggerNamedPatternConverter extends LoggerPatternConverter { |
| 387 | 387 | |
| 388 | - /** |
|
| 389 | - * @var integer |
|
| 390 | - */ |
|
| 391 | - public $precision; |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Constructor |
|
| 395 | - * |
|
| 396 | - * @param string $formattingInfo |
|
| 397 | - * @param integer $precision |
|
| 398 | - */ |
|
| 399 | - public function LoggerNamedPatternConverter($formattingInfo, $precision) |
|
| 400 | - { |
|
| 401 | - LoggerLog::debug("LoggerNamedPatternConverter::LoggerNamedPatternConverter() precision='$precision'"); |
|
| 388 | + /** |
|
| 389 | + * @var integer |
|
| 390 | + */ |
|
| 391 | + public $precision; |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Constructor |
|
| 395 | + * |
|
| 396 | + * @param string $formattingInfo |
|
| 397 | + * @param integer $precision |
|
| 398 | + */ |
|
| 399 | + public function LoggerNamedPatternConverter($formattingInfo, $precision) |
|
| 400 | + { |
|
| 401 | + LoggerLog::debug("LoggerNamedPatternConverter::LoggerNamedPatternConverter() precision='$precision'"); |
|
| 402 | 402 | |
| 403 | - $this->LoggerPatternConverter($formattingInfo); |
|
| 404 | - $this->precision = $precision; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * @param LoggerLoggingEvent $event |
|
| 409 | - * @return string |
|
| 410 | - * @abstract |
|
| 411 | - */ |
|
| 412 | - public function getFullyQualifiedName($event) |
|
| 413 | - { |
|
| 414 | - // abstract |
|
| 415 | - return; |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - /** |
|
| 419 | - * @param LoggerLoggingEvent $event |
|
| 420 | - * @return string |
|
| 421 | - */ |
|
| 422 | - public function convert($event) |
|
| 423 | - { |
|
| 424 | - $n = $this->getFullyQualifiedName($event); |
|
| 425 | - if ($this->precision <= 0) { |
|
| 426 | - return $n; |
|
| 427 | - } else { |
|
| 428 | - $len = strlen($n); |
|
| 403 | + $this->LoggerPatternConverter($formattingInfo); |
|
| 404 | + $this->precision = $precision; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * @param LoggerLoggingEvent $event |
|
| 409 | + * @return string |
|
| 410 | + * @abstract |
|
| 411 | + */ |
|
| 412 | + public function getFullyQualifiedName($event) |
|
| 413 | + { |
|
| 414 | + // abstract |
|
| 415 | + return; |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + /** |
|
| 419 | + * @param LoggerLoggingEvent $event |
|
| 420 | + * @return string |
|
| 421 | + */ |
|
| 422 | + public function convert($event) |
|
| 423 | + { |
|
| 424 | + $n = $this->getFullyQualifiedName($event); |
|
| 425 | + if ($this->precision <= 0) { |
|
| 426 | + return $n; |
|
| 427 | + } else { |
|
| 428 | + $len = strlen($n); |
|
| 429 | 429 | |
| 430 | - // We substract 1 from 'len' when assigning to 'end' to avoid out of |
|
| 431 | - // bounds exception in return r.substring(end+1, len). This can happen if |
|
| 432 | - // precision is 1 and the category name ends with a dot. |
|
| 433 | - $end = $len -1 ; |
|
| 434 | - for($i = $this->precision; $i > 0; $i--) { |
|
| 435 | - $end = strrpos(substr($n, 0, ($end - 1)), '.'); |
|
| 436 | - if ($end === false) |
|
| 437 | - return $n; |
|
| 438 | - } |
|
| 439 | - return substr($n, ($end + 1), $len); |
|
| 440 | - } |
|
| 441 | - } |
|
| 430 | + // We substract 1 from 'len' when assigning to 'end' to avoid out of |
|
| 431 | + // bounds exception in return r.substring(end+1, len). This can happen if |
|
| 432 | + // precision is 1 and the category name ends with a dot. |
|
| 433 | + $end = $len -1 ; |
|
| 434 | + for($i = $this->precision; $i > 0; $i--) { |
|
| 435 | + $end = strrpos(substr($n, 0, ($end - 1)), '.'); |
|
| 436 | + if ($end === false) |
|
| 437 | + return $n; |
|
| 438 | + } |
|
| 439 | + return substr($n, ($end + 1), $len); |
|
| 440 | + } |
|
| 441 | + } |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -448,27 +448,27 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | class LoggerClassNamePatternConverter extends LoggerNamedPatternConverter { |
| 450 | 450 | |
| 451 | - /** |
|
| 452 | - * Constructor |
|
| 453 | - * |
|
| 454 | - * @param string $formattingInfo |
|
| 455 | - * @param integer $precision |
|
| 456 | - */ |
|
| 457 | - public function LoggerClassNamePatternConverter($formattingInfo, $precision) |
|
| 458 | - { |
|
| 459 | - LoggerLog::debug("LoggerClassNamePatternConverter::LoggerClassNamePatternConverter() precision='$precision'"); |
|
| 451 | + /** |
|
| 452 | + * Constructor |
|
| 453 | + * |
|
| 454 | + * @param string $formattingInfo |
|
| 455 | + * @param integer $precision |
|
| 456 | + */ |
|
| 457 | + public function LoggerClassNamePatternConverter($formattingInfo, $precision) |
|
| 458 | + { |
|
| 459 | + LoggerLog::debug("LoggerClassNamePatternConverter::LoggerClassNamePatternConverter() precision='$precision'"); |
|
| 460 | 460 | |
| 461 | - $this->LoggerNamedPatternConverter($formattingInfo, $precision); |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - /** |
|
| 465 | - * @param LoggerLoggingEvent $event |
|
| 466 | - * @return string |
|
| 467 | - */ |
|
| 468 | - public function getFullyQualifiedName($event) |
|
| 469 | - { |
|
| 470 | - return $event->fqcn; |
|
| 471 | - } |
|
| 461 | + $this->LoggerNamedPatternConverter($formattingInfo, $precision); |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | + * @param LoggerLoggingEvent $event |
|
| 466 | + * @return string |
|
| 467 | + */ |
|
| 468 | + public function getFullyQualifiedName($event) |
|
| 469 | + { |
|
| 470 | + return $event->fqcn; |
|
| 471 | + } |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -478,27 +478,27 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | class LoggerCategoryPatternConverter extends LoggerNamedPatternConverter { |
| 480 | 480 | |
| 481 | - /** |
|
| 482 | - * Constructor |
|
| 483 | - * |
|
| 484 | - * @param string $formattingInfo |
|
| 485 | - * @param integer $precision |
|
| 486 | - */ |
|
| 487 | - public function LoggerCategoryPatternConverter($formattingInfo, $precision) |
|
| 488 | - { |
|
| 489 | - LoggerLog::debug("LoggerCategoryPatternConverter::LoggerCategoryPatternConverter() precision='$precision'"); |
|
| 481 | + /** |
|
| 482 | + * Constructor |
|
| 483 | + * |
|
| 484 | + * @param string $formattingInfo |
|
| 485 | + * @param integer $precision |
|
| 486 | + */ |
|
| 487 | + public function LoggerCategoryPatternConverter($formattingInfo, $precision) |
|
| 488 | + { |
|
| 489 | + LoggerLog::debug("LoggerCategoryPatternConverter::LoggerCategoryPatternConverter() precision='$precision'"); |
|
| 490 | 490 | |
| 491 | - $this->LoggerNamedPatternConverter($formattingInfo, $precision); |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - /** |
|
| 495 | - * @param LoggerLoggingEvent $event |
|
| 496 | - * @return string |
|
| 497 | - */ |
|
| 498 | - public function getFullyQualifiedName($event) |
|
| 499 | - { |
|
| 500 | - return $event->getLoggerName(); |
|
| 501 | - } |
|
| 491 | + $this->LoggerNamedPatternConverter($formattingInfo, $precision); |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + /** |
|
| 495 | + * @param LoggerLoggingEvent $event |
|
| 496 | + * @return string |
|
| 497 | + */ |
|
| 498 | + public function getFullyQualifiedName($event) |
|
| 499 | + { |
|
| 500 | + return $event->getLoggerName(); |
|
| 501 | + } |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | ?> |
| 505 | 505 | \ No newline at end of file |
@@ -23,17 +23,17 @@ discard block |
||
| 23 | 23 | if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); |
| 24 | 24 | |
| 25 | 25 | if (!defined('LOG4PHP_LINE_SEP')) { |
| 26 | - if (substr(php_uname(), 0, 7) == "Windows") { |
|
| 27 | - /** |
|
| 28 | - * @ignore |
|
| 29 | - */ |
|
| 30 | - define('LOG4PHP_LINE_SEP', "\r\n"); |
|
| 31 | - } else { |
|
| 32 | - /** |
|
| 33 | - * @ignore |
|
| 34 | - */ |
|
| 35 | - define('LOG4PHP_LINE_SEP', "\n"); |
|
| 36 | - } |
|
| 26 | + if (substr(php_uname(), 0, 7) == "Windows") { |
|
| 27 | + /** |
|
| 28 | + * @ignore |
|
| 29 | + */ |
|
| 30 | + define('LOG4PHP_LINE_SEP', "\r\n"); |
|
| 31 | + } else { |
|
| 32 | + /** |
|
| 33 | + * @ignore |
|
| 34 | + */ |
|
| 35 | + define('LOG4PHP_LINE_SEP', "\n"); |
|
| 36 | + } |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -83,335 +83,335 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | class LoggerPatternParser { |
| 85 | 85 | |
| 86 | - public $state; |
|
| 87 | - public $currentLiteral; |
|
| 88 | - public $patternLength; |
|
| 89 | - public $i; |
|
| 86 | + public $state; |
|
| 87 | + public $currentLiteral; |
|
| 88 | + public $patternLength; |
|
| 89 | + public $i; |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @var LoggerPatternConverter |
|
| 93 | - */ |
|
| 94 | - public $head = null; |
|
| 91 | + /** |
|
| 92 | + * @var LoggerPatternConverter |
|
| 93 | + */ |
|
| 94 | + public $head = null; |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * @var LoggerPatternConverter |
|
| 98 | - */ |
|
| 99 | - public $tail = null; |
|
| 96 | + /** |
|
| 97 | + * @var LoggerPatternConverter |
|
| 98 | + */ |
|
| 99 | + public $tail = null; |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * @var LoggerFormattingInfo |
|
| 103 | - */ |
|
| 104 | - public $formattingInfo; |
|
| 101 | + /** |
|
| 102 | + * @var LoggerFormattingInfo |
|
| 103 | + */ |
|
| 104 | + public $formattingInfo; |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * @var string pattern to parse |
|
| 108 | - */ |
|
| 109 | - public $pattern; |
|
| 106 | + /** |
|
| 107 | + * @var string pattern to parse |
|
| 108 | + */ |
|
| 109 | + public $pattern; |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Constructor |
|
| 113 | - * |
|
| 114 | - * @param string $pattern |
|
| 115 | - */ |
|
| 116 | - public function LoggerPatternParser($pattern) |
|
| 117 | - { |
|
| 118 | - LoggerLog::debug("LoggerPatternParser::LoggerPatternParser() pattern='$pattern'"); |
|
| 111 | + /** |
|
| 112 | + * Constructor |
|
| 113 | + * |
|
| 114 | + * @param string $pattern |
|
| 115 | + */ |
|
| 116 | + public function LoggerPatternParser($pattern) |
|
| 117 | + { |
|
| 118 | + LoggerLog::debug("LoggerPatternParser::LoggerPatternParser() pattern='$pattern'"); |
|
| 119 | 119 | |
| 120 | - $this->pattern = $pattern; |
|
| 121 | - $this->patternLength = strlen($pattern); |
|
| 122 | - $this->formattingInfo = new LoggerFormattingInfo(); |
|
| 123 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
|
| 124 | - } |
|
| 120 | + $this->pattern = $pattern; |
|
| 121 | + $this->patternLength = strlen($pattern); |
|
| 122 | + $this->formattingInfo = new LoggerFormattingInfo(); |
|
| 123 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * @param LoggerPatternConverter $pc |
|
| 128 | - */ |
|
| 129 | - public function addToList($pc) |
|
| 130 | - { |
|
| 131 | - // LoggerLog::debug("LoggerPatternParser::addToList()"); |
|
| 126 | + /** |
|
| 127 | + * @param LoggerPatternConverter $pc |
|
| 128 | + */ |
|
| 129 | + public function addToList($pc) |
|
| 130 | + { |
|
| 131 | + // LoggerLog::debug("LoggerPatternParser::addToList()"); |
|
| 132 | 132 | |
| 133 | - if($this->head == null) { |
|
| 134 | - $this->head = $pc; |
|
| 135 | - $this->tail =& $this->head; |
|
| 136 | - } else { |
|
| 137 | - $this->tail->next = $pc; |
|
| 138 | - $this->tail =& $this->tail->next; |
|
| 139 | - } |
|
| 140 | - } |
|
| 133 | + if($this->head == null) { |
|
| 134 | + $this->head = $pc; |
|
| 135 | + $this->tail =& $this->head; |
|
| 136 | + } else { |
|
| 137 | + $this->tail->next = $pc; |
|
| 138 | + $this->tail =& $this->tail->next; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * @return string |
|
| 144 | - */ |
|
| 145 | - public function extractOption() |
|
| 146 | - { |
|
| 147 | - if(($this->i < $this->patternLength) && ($this->pattern{$this->i} == '{')) { |
|
| 148 | - $end = strpos($this->pattern, '}' , $this->i); |
|
| 149 | - if ($end !== false) { |
|
| 150 | - $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
|
| 151 | - $this->i= $end + 1; |
|
| 152 | - return $r; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - return null; |
|
| 156 | - } |
|
| 142 | + /** |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 145 | + public function extractOption() |
|
| 146 | + { |
|
| 147 | + if(($this->i < $this->patternLength) && ($this->pattern{$this->i} == '{')) { |
|
| 148 | + $end = strpos($this->pattern, '}' , $this->i); |
|
| 149 | + if ($end !== false) { |
|
| 150 | + $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
|
| 151 | + $this->i= $end + 1; |
|
| 152 | + return $r; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + return null; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * The option is expected to be in decimal and positive. In case of |
|
| 160 | - * error, zero is returned. |
|
| 161 | - */ |
|
| 162 | - public function extractPrecisionOption() |
|
| 163 | - { |
|
| 164 | - $opt = $this->extractOption(); |
|
| 165 | - $r = 0; |
|
| 166 | - if ($opt !== null) { |
|
| 167 | - if (is_numeric($opt)) { |
|
| 168 | - $r = (int)$opt; |
|
| 169 | - if($r <= 0) { |
|
| 170 | - LoggerLog::warn("Precision option ({$opt}) isn't a positive integer."); |
|
| 171 | - $r = 0; |
|
| 172 | - } |
|
| 173 | - } else { |
|
| 174 | - LoggerLog::warn("Category option \"{$opt}\" not a decimal integer."); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - return $r; |
|
| 178 | - } |
|
| 158 | + /** |
|
| 159 | + * The option is expected to be in decimal and positive. In case of |
|
| 160 | + * error, zero is returned. |
|
| 161 | + */ |
|
| 162 | + public function extractPrecisionOption() |
|
| 163 | + { |
|
| 164 | + $opt = $this->extractOption(); |
|
| 165 | + $r = 0; |
|
| 166 | + if ($opt !== null) { |
|
| 167 | + if (is_numeric($opt)) { |
|
| 168 | + $r = (int)$opt; |
|
| 169 | + if($r <= 0) { |
|
| 170 | + LoggerLog::warn("Precision option ({$opt}) isn't a positive integer."); |
|
| 171 | + $r = 0; |
|
| 172 | + } |
|
| 173 | + } else { |
|
| 174 | + LoggerLog::warn("Category option \"{$opt}\" not a decimal integer."); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + return $r; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - public function parse() |
|
| 181 | - { |
|
| 182 | - LoggerLog::debug("LoggerPatternParser::parse()"); |
|
| 180 | + public function parse() |
|
| 181 | + { |
|
| 182 | + LoggerLog::debug("LoggerPatternParser::parse()"); |
|
| 183 | 183 | |
| 184 | - $c = ''; |
|
| 185 | - $this->i = 0; |
|
| 186 | - $this->currentLiteral = ''; |
|
| 187 | - while ($this->i < $this->patternLength) { |
|
| 188 | - $c = $this->pattern{$this->i++}; |
|
| 184 | + $c = ''; |
|
| 185 | + $this->i = 0; |
|
| 186 | + $this->currentLiteral = ''; |
|
| 187 | + while ($this->i < $this->patternLength) { |
|
| 188 | + $c = $this->pattern{$this->i++}; |
|
| 189 | 189 | // LoggerLog::debug("LoggerPatternParser::parse() char is now '$c' and currentLiteral is '{$this->currentLiteral}'"); |
| 190 | - switch($this->state) { |
|
| 191 | - case LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE: |
|
| 192 | - // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE'"); |
|
| 193 | - // In literal state, the last char is always a literal. |
|
| 194 | - if($this->i == $this->patternLength) { |
|
| 195 | - $this->currentLiteral .= $c; |
|
| 196 | - continue; |
|
| 197 | - } |
|
| 198 | - if($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) { |
|
| 199 | - // LoggerLog::debug("LoggerPatternParser::parse() char is an escape char"); |
|
| 200 | - // peek at the next char. |
|
| 201 | - switch($this->pattern{$this->i}) { |
|
| 202 | - case LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR: |
|
| 203 | - // LoggerLog::debug("LoggerPatternParser::parse() next char is an escape char"); |
|
| 204 | - $this->currentLiteral .= $c; |
|
| 205 | - $this->i++; // move pointer |
|
| 206 | - break; |
|
| 207 | - case 'n': |
|
| 208 | - // LoggerLog::debug("LoggerPatternParser::parse() next char is 'n'"); |
|
| 209 | - $this->currentLiteral .= LOG4PHP_LINE_SEP; |
|
| 210 | - $this->i++; // move pointer |
|
| 211 | - break; |
|
| 212 | - default: |
|
| 213 | - if(strlen($this->currentLiteral) != 0) { |
|
| 214 | - $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
| 215 | - LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\"."); |
|
| 216 | - } |
|
| 217 | - $this->currentLiteral = $c; |
|
| 218 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE; |
|
| 219 | - $this->formattingInfo->reset(); |
|
| 220 | - } |
|
| 221 | - } else { |
|
| 222 | - $this->currentLiteral .= $c; |
|
| 223 | - } |
|
| 224 | - break; |
|
| 225 | - case LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE: |
|
| 226 | - // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE'"); |
|
| 227 | - $this->currentLiteral .= $c; |
|
| 228 | - switch($c) { |
|
| 229 | - case '-': |
|
| 230 | - $this->formattingInfo->leftAlign = true; |
|
| 231 | - break; |
|
| 232 | - case '.': |
|
| 233 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE; |
|
| 234 | - break; |
|
| 235 | - default: |
|
| 236 | - if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 237 | - $this->formattingInfo->min = ord($c) - ord('0'); |
|
| 238 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE; |
|
| 239 | - } else { |
|
| 240 | - $this->finalizeConverter($c); |
|
| 241 | - } |
|
| 242 | - } // switch |
|
| 243 | - break; |
|
| 244 | - case LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE: |
|
| 245 | - // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE'"); |
|
| 246 | - $this->currentLiteral .= $c; |
|
| 247 | - if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 248 | - $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord(c) - ord('0')); |
|
| 249 | - } elseif ($c == '.') { |
|
| 250 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE; |
|
| 251 | - } else { |
|
| 252 | - $this->finalizeConverter($c); |
|
| 253 | - } |
|
| 254 | - break; |
|
| 255 | - case LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE: |
|
| 256 | - // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE'"); |
|
| 257 | - $this->currentLiteral .= $c; |
|
| 258 | - if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 259 | - $this->formattingInfo->max = ord($c) - ord('0'); |
|
| 260 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE; |
|
| 261 | - } else { |
|
| 262 | - LoggerLog::warn("LoggerPatternParser::parse() Error occured in position {$this->i}. Was expecting digit, instead got char \"{$c}\"."); |
|
| 263 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
|
| 264 | - } |
|
| 265 | - break; |
|
| 266 | - case LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE: |
|
| 267 | - // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE'"); |
|
| 268 | - $this->currentLiteral .= $c; |
|
| 269 | - if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 270 | - $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
|
| 271 | - } else { |
|
| 272 | - $this->finalizeConverter($c); |
|
| 273 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
|
| 274 | - } |
|
| 275 | - break; |
|
| 276 | - } // switch |
|
| 277 | - } // while |
|
| 278 | - if(strlen($this->currentLiteral) != 0) { |
|
| 279 | - $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
| 280 | - // LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\"."); |
|
| 281 | - } |
|
| 282 | - return $this->head; |
|
| 283 | - } |
|
| 190 | + switch($this->state) { |
|
| 191 | + case LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE: |
|
| 192 | + // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE'"); |
|
| 193 | + // In literal state, the last char is always a literal. |
|
| 194 | + if($this->i == $this->patternLength) { |
|
| 195 | + $this->currentLiteral .= $c; |
|
| 196 | + continue; |
|
| 197 | + } |
|
| 198 | + if($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) { |
|
| 199 | + // LoggerLog::debug("LoggerPatternParser::parse() char is an escape char"); |
|
| 200 | + // peek at the next char. |
|
| 201 | + switch($this->pattern{$this->i}) { |
|
| 202 | + case LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR: |
|
| 203 | + // LoggerLog::debug("LoggerPatternParser::parse() next char is an escape char"); |
|
| 204 | + $this->currentLiteral .= $c; |
|
| 205 | + $this->i++; // move pointer |
|
| 206 | + break; |
|
| 207 | + case 'n': |
|
| 208 | + // LoggerLog::debug("LoggerPatternParser::parse() next char is 'n'"); |
|
| 209 | + $this->currentLiteral .= LOG4PHP_LINE_SEP; |
|
| 210 | + $this->i++; // move pointer |
|
| 211 | + break; |
|
| 212 | + default: |
|
| 213 | + if(strlen($this->currentLiteral) != 0) { |
|
| 214 | + $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
| 215 | + LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\"."); |
|
| 216 | + } |
|
| 217 | + $this->currentLiteral = $c; |
|
| 218 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE; |
|
| 219 | + $this->formattingInfo->reset(); |
|
| 220 | + } |
|
| 221 | + } else { |
|
| 222 | + $this->currentLiteral .= $c; |
|
| 223 | + } |
|
| 224 | + break; |
|
| 225 | + case LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE: |
|
| 226 | + // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE'"); |
|
| 227 | + $this->currentLiteral .= $c; |
|
| 228 | + switch($c) { |
|
| 229 | + case '-': |
|
| 230 | + $this->formattingInfo->leftAlign = true; |
|
| 231 | + break; |
|
| 232 | + case '.': |
|
| 233 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE; |
|
| 234 | + break; |
|
| 235 | + default: |
|
| 236 | + if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 237 | + $this->formattingInfo->min = ord($c) - ord('0'); |
|
| 238 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE; |
|
| 239 | + } else { |
|
| 240 | + $this->finalizeConverter($c); |
|
| 241 | + } |
|
| 242 | + } // switch |
|
| 243 | + break; |
|
| 244 | + case LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE: |
|
| 245 | + // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE'"); |
|
| 246 | + $this->currentLiteral .= $c; |
|
| 247 | + if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 248 | + $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord(c) - ord('0')); |
|
| 249 | + } elseif ($c == '.') { |
|
| 250 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE; |
|
| 251 | + } else { |
|
| 252 | + $this->finalizeConverter($c); |
|
| 253 | + } |
|
| 254 | + break; |
|
| 255 | + case LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE: |
|
| 256 | + // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE'"); |
|
| 257 | + $this->currentLiteral .= $c; |
|
| 258 | + if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 259 | + $this->formattingInfo->max = ord($c) - ord('0'); |
|
| 260 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE; |
|
| 261 | + } else { |
|
| 262 | + LoggerLog::warn("LoggerPatternParser::parse() Error occured in position {$this->i}. Was expecting digit, instead got char \"{$c}\"."); |
|
| 263 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
|
| 264 | + } |
|
| 265 | + break; |
|
| 266 | + case LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE: |
|
| 267 | + // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE'"); |
|
| 268 | + $this->currentLiteral .= $c; |
|
| 269 | + if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 270 | + $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
|
| 271 | + } else { |
|
| 272 | + $this->finalizeConverter($c); |
|
| 273 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
|
| 274 | + } |
|
| 275 | + break; |
|
| 276 | + } // switch |
|
| 277 | + } // while |
|
| 278 | + if(strlen($this->currentLiteral) != 0) { |
|
| 279 | + $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
| 280 | + // LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\"."); |
|
| 281 | + } |
|
| 282 | + return $this->head; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - public function finalizeConverter($c) |
|
| 286 | - { |
|
| 287 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() with char '$c'"); |
|
| 285 | + public function finalizeConverter($c) |
|
| 286 | + { |
|
| 287 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() with char '$c'"); |
|
| 288 | 288 | |
| 289 | - $pc = null; |
|
| 290 | - switch($c) { |
|
| 291 | - case 'c': |
|
| 292 | - $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
| 293 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() CATEGORY converter."); |
|
| 294 | - $this->currentLiteral = ''; |
|
| 295 | - break; |
|
| 296 | - case 'C': |
|
| 297 | - $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
| 298 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() CLASSNAME converter."); |
|
| 299 | - $this->currentLiteral = ''; |
|
| 300 | - break; |
|
| 301 | - case 'd': |
|
| 302 | - $dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
|
| 303 | - $dOpt = $this->extractOption(); |
|
| 289 | + $pc = null; |
|
| 290 | + switch($c) { |
|
| 291 | + case 'c': |
|
| 292 | + $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
| 293 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() CATEGORY converter."); |
|
| 294 | + $this->currentLiteral = ''; |
|
| 295 | + break; |
|
| 296 | + case 'C': |
|
| 297 | + $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
| 298 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() CLASSNAME converter."); |
|
| 299 | + $this->currentLiteral = ''; |
|
| 300 | + break; |
|
| 301 | + case 'd': |
|
| 302 | + $dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
|
| 303 | + $dOpt = $this->extractOption(); |
|
| 304 | 304 | |
| 305 | - if($dOpt !== null) |
|
| 306 | - $dateFormatStr = $dOpt; |
|
| 305 | + if($dOpt !== null) |
|
| 306 | + $dateFormatStr = $dOpt; |
|
| 307 | 307 | |
| 308 | - if ($dateFormatStr == 'ISO8601') { |
|
| 309 | - $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; |
|
| 310 | - } elseif($dateFormatStr == 'ABSOLUTE') { |
|
| 311 | - $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE; |
|
| 312 | - } elseif($dateFormatStr == 'DATE') { |
|
| 313 | - $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE; |
|
| 314 | - } else { |
|
| 315 | - $df = $dateFormatStr; |
|
| 316 | - if ($df == null) { |
|
| 317 | - $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - $pc = new LoggerDatePatternConverter($this->formattingInfo, $df); |
|
| 321 | - $this->currentLiteral = ''; |
|
| 322 | - break; |
|
| 323 | - case 'F': |
|
| 324 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER); |
|
| 325 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() File name converter."); |
|
| 326 | - //formattingInfo.dump(); |
|
| 327 | - $this->currentLiteral = ''; |
|
| 328 | - break; |
|
| 329 | - case 'l': |
|
| 330 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER); |
|
| 331 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() Location converter."); |
|
| 332 | - //formattingInfo.dump(); |
|
| 333 | - $this->currentLiteral = ''; |
|
| 334 | - break; |
|
| 335 | - case 'L': |
|
| 336 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER); |
|
| 337 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() LINE NUMBER converter."); |
|
| 338 | - //formattingInfo.dump(); |
|
| 339 | - $this->currentLiteral = ''; |
|
| 340 | - break; |
|
| 341 | - case 'm': |
|
| 342 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER); |
|
| 343 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() MESSAGE converter."); |
|
| 344 | - //formattingInfo.dump(); |
|
| 345 | - $this->currentLiteral = ''; |
|
| 346 | - break; |
|
| 347 | - case 'M': |
|
| 348 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER); |
|
| 349 | - //LogLog.debug("METHOD converter."); |
|
| 350 | - //formattingInfo.dump(); |
|
| 351 | - $this->currentLiteral = ''; |
|
| 352 | - break; |
|
| 353 | - case 'p': |
|
| 354 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER); |
|
| 355 | - //LogLog.debug("LEVEL converter."); |
|
| 356 | - //formattingInfo.dump(); |
|
| 357 | - $this->currentLiteral = ''; |
|
| 358 | - break; |
|
| 359 | - case 'r': |
|
| 360 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER); |
|
| 361 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() RELATIVE TIME converter."); |
|
| 362 | - //formattingInfo.dump(); |
|
| 363 | - $this->currentLiteral = ''; |
|
| 364 | - break; |
|
| 365 | - case 't': |
|
| 366 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER); |
|
| 367 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() THREAD converter."); |
|
| 368 | - //formattingInfo.dump(); |
|
| 369 | - $this->currentLiteral = ''; |
|
| 370 | - break; |
|
| 371 | - case 'u': |
|
| 372 | - if($this->i < $this->patternLength) { |
|
| 373 | - $cNext = $this->pattern{$this->i}; |
|
| 374 | - if(ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) { |
|
| 375 | - $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
| 376 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() USER converter [{$cNext}]."); |
|
| 377 | - // formattingInfo.dump(); |
|
| 378 | - $this->currentLiteral = ''; |
|
| 379 | - $this->i++; |
|
| 380 | - } else { |
|
| 381 | - LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char '{$cNext}' at position {$this->i}."); |
|
| 382 | - } |
|
| 383 | - } |
|
| 384 | - break; |
|
| 385 | - case 'x': |
|
| 386 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER); |
|
| 387 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() NDC converter."); |
|
| 388 | - $this->currentLiteral = ''; |
|
| 389 | - break; |
|
| 308 | + if ($dateFormatStr == 'ISO8601') { |
|
| 309 | + $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; |
|
| 310 | + } elseif($dateFormatStr == 'ABSOLUTE') { |
|
| 311 | + $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE; |
|
| 312 | + } elseif($dateFormatStr == 'DATE') { |
|
| 313 | + $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE; |
|
| 314 | + } else { |
|
| 315 | + $df = $dateFormatStr; |
|
| 316 | + if ($df == null) { |
|
| 317 | + $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + $pc = new LoggerDatePatternConverter($this->formattingInfo, $df); |
|
| 321 | + $this->currentLiteral = ''; |
|
| 322 | + break; |
|
| 323 | + case 'F': |
|
| 324 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER); |
|
| 325 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() File name converter."); |
|
| 326 | + //formattingInfo.dump(); |
|
| 327 | + $this->currentLiteral = ''; |
|
| 328 | + break; |
|
| 329 | + case 'l': |
|
| 330 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER); |
|
| 331 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() Location converter."); |
|
| 332 | + //formattingInfo.dump(); |
|
| 333 | + $this->currentLiteral = ''; |
|
| 334 | + break; |
|
| 335 | + case 'L': |
|
| 336 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER); |
|
| 337 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() LINE NUMBER converter."); |
|
| 338 | + //formattingInfo.dump(); |
|
| 339 | + $this->currentLiteral = ''; |
|
| 340 | + break; |
|
| 341 | + case 'm': |
|
| 342 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER); |
|
| 343 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() MESSAGE converter."); |
|
| 344 | + //formattingInfo.dump(); |
|
| 345 | + $this->currentLiteral = ''; |
|
| 346 | + break; |
|
| 347 | + case 'M': |
|
| 348 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER); |
|
| 349 | + //LogLog.debug("METHOD converter."); |
|
| 350 | + //formattingInfo.dump(); |
|
| 351 | + $this->currentLiteral = ''; |
|
| 352 | + break; |
|
| 353 | + case 'p': |
|
| 354 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER); |
|
| 355 | + //LogLog.debug("LEVEL converter."); |
|
| 356 | + //formattingInfo.dump(); |
|
| 357 | + $this->currentLiteral = ''; |
|
| 358 | + break; |
|
| 359 | + case 'r': |
|
| 360 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER); |
|
| 361 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() RELATIVE TIME converter."); |
|
| 362 | + //formattingInfo.dump(); |
|
| 363 | + $this->currentLiteral = ''; |
|
| 364 | + break; |
|
| 365 | + case 't': |
|
| 366 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER); |
|
| 367 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() THREAD converter."); |
|
| 368 | + //formattingInfo.dump(); |
|
| 369 | + $this->currentLiteral = ''; |
|
| 370 | + break; |
|
| 371 | + case 'u': |
|
| 372 | + if($this->i < $this->patternLength) { |
|
| 373 | + $cNext = $this->pattern{$this->i}; |
|
| 374 | + if(ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) { |
|
| 375 | + $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
| 376 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() USER converter [{$cNext}]."); |
|
| 377 | + // formattingInfo.dump(); |
|
| 378 | + $this->currentLiteral = ''; |
|
| 379 | + $this->i++; |
|
| 380 | + } else { |
|
| 381 | + LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char '{$cNext}' at position {$this->i}."); |
|
| 382 | + } |
|
| 383 | + } |
|
| 384 | + break; |
|
| 385 | + case 'x': |
|
| 386 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER); |
|
| 387 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() NDC converter."); |
|
| 388 | + $this->currentLiteral = ''; |
|
| 389 | + break; |
|
| 390 | 390 | |
| 391 | - case 'X': |
|
| 392 | - $xOpt = $this->extractOption(); |
|
| 393 | - $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt); |
|
| 394 | - LoggerLog::debug("LoggerPatternParser::finalizeConverter() MDC converter."); |
|
| 395 | - $this->currentLiteral = ''; |
|
| 396 | - break; |
|
| 397 | - default: |
|
| 398 | - LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char [$c] at position {$this->i} in conversion pattern."); |
|
| 399 | - $pc = new LoggerLiteralPatternConverter($this->currentLiteral); |
|
| 400 | - $this->currentLiteral = ''; |
|
| 401 | - } |
|
| 402 | - $this->addConverter($pc); |
|
| 403 | - } |
|
| 391 | + case 'X': |
|
| 392 | + $xOpt = $this->extractOption(); |
|
| 393 | + $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt); |
|
| 394 | + LoggerLog::debug("LoggerPatternParser::finalizeConverter() MDC converter."); |
|
| 395 | + $this->currentLiteral = ''; |
|
| 396 | + break; |
|
| 397 | + default: |
|
| 398 | + LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char [$c] at position {$this->i} in conversion pattern."); |
|
| 399 | + $pc = new LoggerLiteralPatternConverter($this->currentLiteral); |
|
| 400 | + $this->currentLiteral = ''; |
|
| 401 | + } |
|
| 402 | + $this->addConverter($pc); |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | - public function addConverter($pc) |
|
| 406 | - { |
|
| 407 | - $this->currentLiteral = ''; |
|
| 408 | - // Add the pattern converter to the list. |
|
| 409 | - $this->addToList($pc); |
|
| 410 | - // Next pattern is assumed to be a literal. |
|
| 411 | - $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
|
| 412 | - // Reset formatting info |
|
| 413 | - $this->formattingInfo->reset(); |
|
| 414 | - } |
|
| 405 | + public function addConverter($pc) |
|
| 406 | + { |
|
| 407 | + $this->currentLiteral = ''; |
|
| 408 | + // Add the pattern converter to the list. |
|
| 409 | + $this->addToList($pc); |
|
| 410 | + // Next pattern is assumed to be a literal. |
|
| 411 | + $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
|
| 412 | + // Reset formatting info |
|
| 413 | + $this->formattingInfo->reset(); |
|
| 414 | + } |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | ?> |
| 418 | 418 | \ No newline at end of file |
@@ -37,25 +37,25 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class LoggerFormattingInfo { |
| 39 | 39 | |
| 40 | - public $min = -1; |
|
| 41 | - public $max = 0x7FFFFFFF; |
|
| 42 | - public $leftAlign = false; |
|
| 40 | + public $min = -1; |
|
| 41 | + public $max = 0x7FFFFFFF; |
|
| 42 | + public $leftAlign = false; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Constructor |
|
| 46 | - */ |
|
| 47 | - public function LoggerFormattingInfo() {} |
|
| 44 | + /** |
|
| 45 | + * Constructor |
|
| 46 | + */ |
|
| 47 | + public function LoggerFormattingInfo() {} |
|
| 48 | 48 | |
| 49 | - public function reset() |
|
| 50 | - { |
|
| 51 | - $this->min = -1; |
|
| 52 | - $this->max = 0x7FFFFFFF; |
|
| 53 | - $this->leftAlign = false; |
|
| 54 | - } |
|
| 49 | + public function reset() |
|
| 50 | + { |
|
| 51 | + $this->min = -1; |
|
| 52 | + $this->max = 0x7FFFFFFF; |
|
| 53 | + $this->leftAlign = false; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - public function dump() |
|
| 57 | - { |
|
| 58 | - LoggerLog::debug("LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}"); |
|
| 59 | - } |
|
| 56 | + public function dump() |
|
| 57 | + { |
|
| 58 | + LoggerLog::debug("LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}"); |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | ?> |
| 62 | 62 | \ No newline at end of file |
@@ -47,73 +47,73 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | class LoggerLevelMatchFilter extends LoggerFilter { |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var boolean |
|
| 52 | - */ |
|
| 53 | - public $acceptOnMatch = true; |
|
| 50 | + /** |
|
| 51 | + * @var boolean |
|
| 52 | + */ |
|
| 53 | + public $acceptOnMatch = true; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @var LoggerLevel |
|
| 57 | - */ |
|
| 58 | - public $levelToMatch; |
|
| 55 | + /** |
|
| 56 | + * @var LoggerLevel |
|
| 57 | + */ |
|
| 58 | + public $levelToMatch; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @return boolean |
|
| 62 | - */ |
|
| 63 | - public function getAcceptOnMatch() |
|
| 64 | - { |
|
| 65 | - return $this->acceptOnMatch; |
|
| 66 | - } |
|
| 60 | + /** |
|
| 61 | + * @return boolean |
|
| 62 | + */ |
|
| 63 | + public function getAcceptOnMatch() |
|
| 64 | + { |
|
| 65 | + return $this->acceptOnMatch; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @param boolean $acceptOnMatch |
|
| 70 | - */ |
|
| 71 | - public function setAcceptOnMatch($acceptOnMatch) |
|
| 72 | - { |
|
| 73 | - $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
| 74 | - } |
|
| 68 | + /** |
|
| 69 | + * @param boolean $acceptOnMatch |
|
| 70 | + */ |
|
| 71 | + public function setAcceptOnMatch($acceptOnMatch) |
|
| 72 | + { |
|
| 73 | + $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @return LoggerLevel |
|
| 78 | - */ |
|
| 79 | - public function getLevelToMatch() |
|
| 80 | - { |
|
| 81 | - return $this->levelToMatch; |
|
| 82 | - } |
|
| 76 | + /** |
|
| 77 | + * @return LoggerLevel |
|
| 78 | + */ |
|
| 79 | + public function getLevelToMatch() |
|
| 80 | + { |
|
| 81 | + return $this->levelToMatch; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @param string $l the level to match |
|
| 86 | - */ |
|
| 87 | - public function setLevelToMatch($l) |
|
| 88 | - { |
|
| 89 | - $this->levelToMatch = LoggerOptionConverter::toLevel($l, null); |
|
| 90 | - } |
|
| 84 | + /** |
|
| 85 | + * @param string $l the level to match |
|
| 86 | + */ |
|
| 87 | + public function setLevelToMatch($l) |
|
| 88 | + { |
|
| 89 | + $this->levelToMatch = LoggerOptionConverter::toLevel($l, null); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Return the decision of this filter. |
|
| 94 | - * |
|
| 95 | - * Returns {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} if the <b><var>LevelToMatch</var></b> |
|
| 96 | - * option is not set or if there is not match. Otherwise, if there is a |
|
| 97 | - * match, then the returned decision is {@link LOG4PHP_LOGGER_FILTER_ACCEPT} if the |
|
| 98 | - * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The |
|
| 99 | - * returned decision is {@link LOG4PHP_LOGGER_FILTER_DENY} if the |
|
| 100 | - * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>. |
|
| 101 | - * |
|
| 102 | - * @param LoggerLoggingEvent $event |
|
| 103 | - * @return integer |
|
| 104 | - */ |
|
| 105 | - public function decide($event) |
|
| 106 | - { |
|
| 107 | - if($this->levelToMatch === null) |
|
| 108 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 92 | + /** |
|
| 93 | + * Return the decision of this filter. |
|
| 94 | + * |
|
| 95 | + * Returns {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} if the <b><var>LevelToMatch</var></b> |
|
| 96 | + * option is not set or if there is not match. Otherwise, if there is a |
|
| 97 | + * match, then the returned decision is {@link LOG4PHP_LOGGER_FILTER_ACCEPT} if the |
|
| 98 | + * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The |
|
| 99 | + * returned decision is {@link LOG4PHP_LOGGER_FILTER_DENY} if the |
|
| 100 | + * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>. |
|
| 101 | + * |
|
| 102 | + * @param LoggerLoggingEvent $event |
|
| 103 | + * @return integer |
|
| 104 | + */ |
|
| 105 | + public function decide($event) |
|
| 106 | + { |
|
| 107 | + if($this->levelToMatch === null) |
|
| 108 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 109 | 109 | |
| 110 | - if ($this->levelToMatch->equals($event->getLevel())) { |
|
| 111 | - return $this->getAcceptOnMatch() ? |
|
| 112 | - LOG4PHP_LOGGER_FILTER_ACCEPT : |
|
| 113 | - LOG4PHP_LOGGER_FILTER_DENY; |
|
| 114 | - } else { |
|
| 115 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 116 | - } |
|
| 117 | - } |
|
| 110 | + if ($this->levelToMatch->equals($event->getLevel())) { |
|
| 111 | + return $this->getAcceptOnMatch() ? |
|
| 112 | + LOG4PHP_LOGGER_FILTER_ACCEPT : |
|
| 113 | + LOG4PHP_LOGGER_FILTER_DENY; |
|
| 114 | + } else { |
|
| 115 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | ?> |
| 120 | 120 | \ No newline at end of file |
@@ -46,63 +46,63 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | class LoggerStringMatchFilter extends LoggerFilter { |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var boolean |
|
| 51 | - */ |
|
| 52 | - public $acceptOnMatch = true; |
|
| 49 | + /** |
|
| 50 | + * @var boolean |
|
| 51 | + */ |
|
| 52 | + public $acceptOnMatch = true; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 57 | - public $stringToMatch = null; |
|
| 54 | + /** |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | + public $stringToMatch = null; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return boolean |
|
| 61 | - */ |
|
| 62 | - public function getAcceptOnMatch() |
|
| 63 | - { |
|
| 64 | - return $this->acceptOnMatch; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * @return boolean |
|
| 61 | + */ |
|
| 62 | + public function getAcceptOnMatch() |
|
| 63 | + { |
|
| 64 | + return $this->acceptOnMatch; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false') |
|
| 69 | - */ |
|
| 70 | - public function setAcceptOnMatch($acceptOnMatch) |
|
| 71 | - { |
|
| 72 | - $this->acceptOnMatch = is_bool($acceptOnMatch) ? |
|
| 73 | - $acceptOnMatch : |
|
| 74 | - (bool)(strtolower($acceptOnMatch) == 'true'); |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false') |
|
| 69 | + */ |
|
| 70 | + public function setAcceptOnMatch($acceptOnMatch) |
|
| 71 | + { |
|
| 72 | + $this->acceptOnMatch = is_bool($acceptOnMatch) ? |
|
| 73 | + $acceptOnMatch : |
|
| 74 | + (bool)(strtolower($acceptOnMatch) == 'true'); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public function getStringToMatch() |
|
| 81 | - { |
|
| 82 | - return $this->stringToMatch; |
|
| 83 | - } |
|
| 77 | + /** |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public function getStringToMatch() |
|
| 81 | + { |
|
| 82 | + return $this->stringToMatch; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @param string $s the string to match |
|
| 87 | - */ |
|
| 88 | - public function setStringToMatch($s) |
|
| 89 | - { |
|
| 90 | - $this->stringToMatch = $s; |
|
| 91 | - } |
|
| 85 | + /** |
|
| 86 | + * @param string $s the string to match |
|
| 87 | + */ |
|
| 88 | + public function setStringToMatch($s) |
|
| 89 | + { |
|
| 90 | + $this->stringToMatch = $s; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. |
|
| 95 | - */ |
|
| 96 | - public function decide($event) |
|
| 97 | - { |
|
| 98 | - $msg = $event->getRenderedMessage(); |
|
| 93 | + /** |
|
| 94 | + * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. |
|
| 95 | + */ |
|
| 96 | + public function decide($event) |
|
| 97 | + { |
|
| 98 | + $msg = $event->getRenderedMessage(); |
|
| 99 | 99 | |
| 100 | - if($msg === null || $this->stringToMatch === null) |
|
| 101 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 102 | - if( strpos($msg, $this->stringToMatch) !== false ) { |
|
| 103 | - return ($this->acceptOnMatch) ? LOG4PHP_LOGGER_FILTER_ACCEPT : LOG4PHP_LOGGER_FILTER_DENY ; |
|
| 104 | - } |
|
| 105 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 106 | - } |
|
| 100 | + if($msg === null || $this->stringToMatch === null) |
|
| 101 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 102 | + if( strpos($msg, $this->stringToMatch) !== false ) { |
|
| 103 | + return ($this->acceptOnMatch) ? LOG4PHP_LOGGER_FILTER_ACCEPT : LOG4PHP_LOGGER_FILTER_DENY ; |
|
| 104 | + } |
|
| 105 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 106 | + } |
|
| 107 | 107 | } |
| 108 | 108 | ?> |
| 109 | 109 | \ No newline at end of file |
@@ -65,104 +65,104 @@ |
||
| 65 | 65 | */ |
| 66 | 66 | class LoggerLevelRangeFilter extends LoggerFilter { |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var boolean |
|
| 70 | - */ |
|
| 71 | - public $acceptOnMatch = true; |
|
| 68 | + /** |
|
| 69 | + * @var boolean |
|
| 70 | + */ |
|
| 71 | + public $acceptOnMatch = true; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @var LoggerLevel |
|
| 75 | - */ |
|
| 76 | - public $levelMin; |
|
| 73 | + /** |
|
| 74 | + * @var LoggerLevel |
|
| 75 | + */ |
|
| 76 | + public $levelMin; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @var LoggerLevel |
|
| 80 | - */ |
|
| 81 | - public $levelMax; |
|
| 78 | + /** |
|
| 79 | + * @var LoggerLevel |
|
| 80 | + */ |
|
| 81 | + public $levelMax; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @return boolean |
|
| 85 | - */ |
|
| 86 | - public function getAcceptOnMatch() |
|
| 87 | - { |
|
| 88 | - return $this->acceptOnMatch; |
|
| 89 | - } |
|
| 83 | + /** |
|
| 84 | + * @return boolean |
|
| 85 | + */ |
|
| 86 | + public function getAcceptOnMatch() |
|
| 87 | + { |
|
| 88 | + return $this->acceptOnMatch; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @param boolean $acceptOnMatch |
|
| 93 | - */ |
|
| 94 | - public function setAcceptOnMatch($acceptOnMatch) |
|
| 95 | - { |
|
| 96 | - $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
| 97 | - } |
|
| 91 | + /** |
|
| 92 | + * @param boolean $acceptOnMatch |
|
| 93 | + */ |
|
| 94 | + public function setAcceptOnMatch($acceptOnMatch) |
|
| 95 | + { |
|
| 96 | + $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * @return LoggerLevel |
|
| 101 | - */ |
|
| 102 | - public function getLevelMin() |
|
| 103 | - { |
|
| 104 | - return $this->levelMin; |
|
| 105 | - } |
|
| 99 | + /** |
|
| 100 | + * @return LoggerLevel |
|
| 101 | + */ |
|
| 102 | + public function getLevelMin() |
|
| 103 | + { |
|
| 104 | + return $this->levelMin; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * @param string $l the level min to match |
|
| 109 | - */ |
|
| 110 | - public function setLevelMin($l) |
|
| 111 | - { |
|
| 112 | - $this->levelMin = LoggerOptionConverter::toLevel($l, null); |
|
| 113 | - } |
|
| 107 | + /** |
|
| 108 | + * @param string $l the level min to match |
|
| 109 | + */ |
|
| 110 | + public function setLevelMin($l) |
|
| 111 | + { |
|
| 112 | + $this->levelMin = LoggerOptionConverter::toLevel($l, null); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * @return LoggerLevel |
|
| 117 | - */ |
|
| 118 | - public function getLevelMax() |
|
| 119 | - { |
|
| 120 | - return $this->levelMax; |
|
| 121 | - } |
|
| 115 | + /** |
|
| 116 | + * @return LoggerLevel |
|
| 117 | + */ |
|
| 118 | + public function getLevelMax() |
|
| 119 | + { |
|
| 120 | + return $this->levelMax; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * @param string $l the level max to match |
|
| 125 | - */ |
|
| 126 | - public function setLevelMax($l) |
|
| 127 | - { |
|
| 128 | - $this->levelMax = LoggerOptionConverter::toLevel($l, null); |
|
| 129 | - } |
|
| 123 | + /** |
|
| 124 | + * @param string $l the level max to match |
|
| 125 | + */ |
|
| 126 | + public function setLevelMax($l) |
|
| 127 | + { |
|
| 128 | + $this->levelMax = LoggerOptionConverter::toLevel($l, null); |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Return the decision of this filter. |
|
| 133 | - * |
|
| 134 | - * @param LoggerLoggingEvent $event |
|
| 135 | - * @return integer |
|
| 136 | - */ |
|
| 137 | - public function decide($event) |
|
| 138 | - { |
|
| 139 | - $level = $event->getLevel(); |
|
| 131 | + /** |
|
| 132 | + * Return the decision of this filter. |
|
| 133 | + * |
|
| 134 | + * @param LoggerLoggingEvent $event |
|
| 135 | + * @return integer |
|
| 136 | + */ |
|
| 137 | + public function decide($event) |
|
| 138 | + { |
|
| 139 | + $level = $event->getLevel(); |
|
| 140 | 140 | |
| 141 | - if($this->levelMin !== null) { |
|
| 142 | - if ($level->isGreaterOrEqual($this->levelMin) === false) { |
|
| 143 | - // level of event is less than minimum |
|
| 144 | - return LOG4PHP_LOGGER_FILTER_DENY; |
|
| 145 | - } |
|
| 146 | - } |
|
| 141 | + if($this->levelMin !== null) { |
|
| 142 | + if ($level->isGreaterOrEqual($this->levelMin) === false) { |
|
| 143 | + // level of event is less than minimum |
|
| 144 | + return LOG4PHP_LOGGER_FILTER_DENY; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - if($this->levelMax !== null) { |
|
| 149 | - if ($level->toInt() > $this->levelMax->toInt()) { |
|
| 150 | - // level of event is greater than maximum |
|
| 151 | - // Alas, there is no Level.isGreater method. and using |
|
| 152 | - // a combo of isGreaterOrEqual && !Equal seems worse than |
|
| 153 | - // checking the int values of the level objects.. |
|
| 154 | - return LOG4PHP_LOGGER_FILTER_DENY; |
|
| 155 | - } |
|
| 156 | - } |
|
| 148 | + if($this->levelMax !== null) { |
|
| 149 | + if ($level->toInt() > $this->levelMax->toInt()) { |
|
| 150 | + // level of event is greater than maximum |
|
| 151 | + // Alas, there is no Level.isGreater method. and using |
|
| 152 | + // a combo of isGreaterOrEqual && !Equal seems worse than |
|
| 153 | + // checking the int values of the level objects.. |
|
| 154 | + return LOG4PHP_LOGGER_FILTER_DENY; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - if ($this->getAcceptOnMatch()) { |
|
| 159 | - // this filter set up to bypass later filters and always return |
|
| 160 | - // accept if level in range |
|
| 161 | - return LOG4PHP_LOGGER_FILTER_ACCEPT; |
|
| 162 | - } else { |
|
| 163 | - // event is ok for this filter; allow later filters to have a look.. |
|
| 164 | - return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 165 | - } |
|
| 166 | - } |
|
| 158 | + if ($this->getAcceptOnMatch()) { |
|
| 159 | + // this filter set up to bypass later filters and always return |
|
| 160 | + // accept if level in range |
|
| 161 | + return LOG4PHP_LOGGER_FILTER_ACCEPT; |
|
| 162 | + } else { |
|
| 163 | + // event is ok for this filter; allow later filters to have a look.. |
|
| 164 | + return LOG4PHP_LOGGER_FILTER_NEUTRAL; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | 167 | } |
| 168 | 168 | ?> |
| 169 | 169 | \ No newline at end of file |
@@ -91,560 +91,560 @@ |
||
| 91 | 91 | */ |
| 92 | 92 | class LoggerPropertyConfigurator extends LoggerConfigurator { |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @var LoggerFactory |
|
| 96 | - */ |
|
| 97 | - public $loggerFactory = null; |
|
| 94 | + /** |
|
| 95 | + * @var LoggerFactory |
|
| 96 | + */ |
|
| 97 | + public $loggerFactory = null; |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Constructor |
|
| 101 | - */ |
|
| 102 | - public function LoggerPropertyConfigurator() |
|
| 103 | - { |
|
| 104 | - $this->loggerFactory = new LoggerDefaultCategoryFactory(); |
|
| 105 | - } |
|
| 99 | + /** |
|
| 100 | + * Constructor |
|
| 101 | + */ |
|
| 102 | + public function LoggerPropertyConfigurator() |
|
| 103 | + { |
|
| 104 | + $this->loggerFactory = new LoggerDefaultCategoryFactory(); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Configure the default repository using the resource pointed by <b>url</b>. |
|
| 109 | - * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function. |
|
| 110 | - * Note that the resource will be search with <i>use_include_path</i> parameter |
|
| 111 | - * set to "1". |
|
| 112 | - * |
|
| 113 | - * @param string $url |
|
| 114 | - * @return boolean configuration result |
|
| 115 | - * @static |
|
| 116 | - */ |
|
| 117 | - public function configure($url = '') |
|
| 118 | - { |
|
| 119 | - $configurator = new LoggerPropertyConfigurator(); |
|
| 120 | - $repository =& LoggerManager::getLoggerRepository(); |
|
| 121 | - return $configurator->doConfigure($url, $repository); |
|
| 122 | - } |
|
| 107 | + /** |
|
| 108 | + * Configure the default repository using the resource pointed by <b>url</b>. |
|
| 109 | + * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function. |
|
| 110 | + * Note that the resource will be search with <i>use_include_path</i> parameter |
|
| 111 | + * set to "1". |
|
| 112 | + * |
|
| 113 | + * @param string $url |
|
| 114 | + * @return boolean configuration result |
|
| 115 | + * @static |
|
| 116 | + */ |
|
| 117 | + public function configure($url = '') |
|
| 118 | + { |
|
| 119 | + $configurator = new LoggerPropertyConfigurator(); |
|
| 120 | + $repository =& LoggerManager::getLoggerRepository(); |
|
| 121 | + return $configurator->doConfigure($url, $repository); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Read configuration from a file. |
|
| 126 | - * |
|
| 127 | - * <p>The function {@link PHP_MANUAL#parse_ini_file} is used to read the |
|
| 128 | - * file.</p> |
|
| 129 | - * |
|
| 130 | - * <b>The existing configuration is not cleared nor reset.</b> |
|
| 131 | - * If you require a different behavior, then call |
|
| 132 | - * {@link LoggerManager::resetConfiguration()} |
|
| 133 | - * method before calling {@link doConfigure()}. |
|
| 134 | - * |
|
| 135 | - * <p>The configuration file consists of statements in the format |
|
| 136 | - * <b>key=value</b>. The syntax of different configuration |
|
| 137 | - * elements are discussed below. |
|
| 138 | - * |
|
| 139 | - * <p><b>Repository-wide threshold</b></p> |
|
| 140 | - * |
|
| 141 | - * <p>The repository-wide threshold filters logging requests by level |
|
| 142 | - * regardless of logger. The syntax is: |
|
| 143 | - * |
|
| 144 | - * <pre> |
|
| 145 | - * log4php.threshold=[level] |
|
| 146 | - * </pre> |
|
| 147 | - * |
|
| 148 | - * <p>The level value can consist of the string values OFF, FATAL, |
|
| 149 | - * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A |
|
| 150 | - * custom level value can be specified in the form |
|
| 151 | - * <samp>level#classname</samp>. By default the repository-wide threshold is set |
|
| 152 | - * to the lowest possible value, namely the level <b>ALL</b>. |
|
| 153 | - * </p> |
|
| 154 | - * |
|
| 155 | - * |
|
| 156 | - * <p><b>Appender configuration</b></p> |
|
| 157 | - * |
|
| 158 | - * <p>Appender configuration syntax is:</p> |
|
| 159 | - * <pre> |
|
| 160 | - * ; For appender named <i>appenderName</i>, set its class. |
|
| 161 | - * ; Note: The appender name can contain dots. |
|
| 162 | - * log4php.appender.appenderName=name_of_appender_class |
|
| 163 | - * |
|
| 164 | - * ; Set appender specific options. |
|
| 165 | - * |
|
| 166 | - * log4php.appender.appenderName.option1=value1 |
|
| 167 | - * log4php.appender.appenderName.optionN=valueN |
|
| 168 | - * </pre> |
|
| 169 | - * |
|
| 170 | - * For each named appender you can configure its {@link LoggerLayout}. The |
|
| 171 | - * syntax for configuring an appender's layout is: |
|
| 172 | - * <pre> |
|
| 173 | - * log4php.appender.appenderName.layout=name_of_layout_class |
|
| 174 | - * log4php.appender.appenderName.layout.option1=value1 |
|
| 175 | - * .... |
|
| 176 | - * log4php.appender.appenderName.layout.optionN=valueN |
|
| 177 | - * </pre> |
|
| 178 | - * |
|
| 179 | - * <p><b>Configuring loggers</b></p> |
|
| 180 | - * |
|
| 181 | - * <p>The syntax for configuring the root logger is: |
|
| 182 | - * <pre> |
|
| 183 | - * log4php.rootLogger=[level], appenderName, appenderName, ... |
|
| 184 | - * </pre> |
|
| 185 | - * |
|
| 186 | - * <p>This syntax means that an optional <i>level</i> can be |
|
| 187 | - * supplied followed by appender names separated by commas. |
|
| 188 | - * |
|
| 189 | - * <p>The level value can consist of the string values OFF, FATAL, |
|
| 190 | - * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A |
|
| 191 | - * custom level value can be specified in the form</p> |
|
| 192 | - * |
|
| 193 | - * <pre>level#classname</pre> |
|
| 194 | - * |
|
| 195 | - * <p>If a level value is specified, then the root level is set |
|
| 196 | - * to the corresponding level. If no level value is specified, |
|
| 197 | - * then the root level remains untouched. |
|
| 198 | - * |
|
| 199 | - * <p>The root logger can be assigned multiple appenders. |
|
| 200 | - * |
|
| 201 | - * <p>Each <i>appenderName</i> (separated by commas) will be added to |
|
| 202 | - * the root logger. The named appender is defined using the |
|
| 203 | - * appender syntax defined above. |
|
| 204 | - * |
|
| 205 | - * <p>For non-root categories the syntax is almost the same: |
|
| 206 | - * <pre> |
|
| 207 | - * log4php.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ... |
|
| 208 | - * </pre> |
|
| 209 | - * |
|
| 210 | - * <p>The meaning of the optional level value is discussed above |
|
| 211 | - * in relation to the root logger. In addition however, the value |
|
| 212 | - * INHERITED can be specified meaning that the named logger should |
|
| 213 | - * inherit its level from the logger hierarchy.</p> |
|
| 214 | - * |
|
| 215 | - * <p>If no level value is supplied, then the level of the |
|
| 216 | - * named logger remains untouched.</p> |
|
| 217 | - * |
|
| 218 | - * <p>By default categories inherit their level from the |
|
| 219 | - * hierarchy. However, if you set the level of a logger and later |
|
| 220 | - * decide that that logger should inherit its level, then you should |
|
| 221 | - * specify INHERITED as the value for the level value. NULL is a |
|
| 222 | - * synonym for INHERITED.</p> |
|
| 223 | - * |
|
| 224 | - * <p>Similar to the root logger syntax, each <i>appenderName</i> |
|
| 225 | - * (separated by commas) will be attached to the named logger.</p> |
|
| 226 | - * |
|
| 227 | - * <p>See the <i>appender additivity rule</i> in the user manual for |
|
| 228 | - * the meaning of the <b>additivity</b> flag. |
|
| 229 | - * |
|
| 230 | - * <p><b>ObjectRenderers</b></p> |
|
| 231 | - * |
|
| 232 | - * <p>You can customize the way message objects of a given type are |
|
| 233 | - * converted to String before being logged. This is done by |
|
| 234 | - * specifying a {@link LoggerObjectRenderer} |
|
| 235 | - * for the object type would like to customize.</p> |
|
| 236 | - * |
|
| 237 | - * <p>The syntax is: |
|
| 238 | - * |
|
| 239 | - * <pre> |
|
| 240 | - * log4php.renderer.name_of_rendered_class=name_of_rendering.class |
|
| 241 | - * </pre> |
|
| 242 | - * |
|
| 243 | - * As in, |
|
| 244 | - * <pre> |
|
| 245 | - * log4php.renderer.myFruit=myFruitRenderer |
|
| 246 | - * </pre> |
|
| 247 | - * |
|
| 248 | - * <p><b>Logger Factories</b></p> |
|
| 249 | - * |
|
| 250 | - * The usage of custom logger factories is discouraged and no longer |
|
| 251 | - * documented. |
|
| 252 | - * |
|
| 253 | - * <p><b>Example</b></p> |
|
| 254 | - * |
|
| 255 | - * <p>An example configuration is given below. Other configuration |
|
| 256 | - * file examples are given in the <b>tests</b> folder. |
|
| 257 | - * |
|
| 258 | - * <pre> |
|
| 259 | - * ; Set options for appender named "A1". |
|
| 260 | - * ; Appender "A1" will be a SyslogAppender |
|
| 261 | - * log4php.appender.A1=SyslogAppender |
|
| 262 | - * |
|
| 263 | - * ; The syslog daemon resides on www.abc.net |
|
| 264 | - * log4php.appender.A1.SyslogHost=www.abc.net |
|
| 265 | - * |
|
| 266 | - * ; A1's layout is a LoggerPatternLayout, using the conversion pattern |
|
| 267 | - * ; <b>%r %-5p %c{2} %M.%L %x - %m%n</b>. Thus, the log output will |
|
| 268 | - * ; include the relative time since the start of the application in |
|
| 269 | - * ; milliseconds, followed by the level of the log request, |
|
| 270 | - * ; followed by the two rightmost components of the logger name, |
|
| 271 | - * ; followed by the callers method name, followed by the line number, |
|
| 272 | - * ; the nested disgnostic context and finally the message itself. |
|
| 273 | - * ; Refer to the documentation of LoggerPatternLayout} for further information |
|
| 274 | - * ; on the syntax of the ConversionPattern key. |
|
| 275 | - * log4php.appender.A1.layout=LoggerPatternLayout |
|
| 276 | - * log4php.appender.A1.layout.ConversionPattern="%-4r %-5p %c{2} %M.%L %x - %m%n" |
|
| 277 | - * |
|
| 278 | - * ; Set options for appender named "A2" |
|
| 279 | - * ; A2 should be a LoggerAppenderRollingFile, with maximum file size of 10 MB |
|
| 280 | - * ; using at most one backup file. A2's layout is TTCC, using the |
|
| 281 | - * ; ISO8061 date format with context printing enabled. |
|
| 282 | - * log4php.appender.A2=LoggerAppenderRollingFile |
|
| 283 | - * log4php.appender.A2.MaxFileSize=10MB |
|
| 284 | - * log4php.appender.A2.MaxBackupIndex=1 |
|
| 285 | - * log4php.appender.A2.layout=LoggerLayoutTTCC |
|
| 286 | - * log4php.appender.A2.layout.ContextPrinting="true" |
|
| 287 | - * log4php.appender.A2.layout.DateFormat="%c" |
|
| 288 | - * |
|
| 289 | - * ; Root logger set to DEBUG using the A2 appender defined above. |
|
| 290 | - * log4php.rootLogger=DEBUG, A2 |
|
| 291 | - * |
|
| 292 | - * ; Logger definitions: |
|
| 293 | - * ; The SECURITY logger inherits is level from root. However, it's output |
|
| 294 | - * ; will go to A1 appender defined above. It's additivity is non-cumulative. |
|
| 295 | - * log4php.logger.SECURITY=INHERIT, A1 |
|
| 296 | - * log4php.additivity.SECURITY=false |
|
| 297 | - * |
|
| 298 | - * ; Only warnings or above will be logged for the logger "SECURITY.access". |
|
| 299 | - * ; Output will go to A1. |
|
| 300 | - * log4php.logger.SECURITY.access=WARN |
|
| 301 | - * |
|
| 302 | - * |
|
| 303 | - * ; The logger "class.of.the.day" inherits its level from the |
|
| 304 | - * ; logger hierarchy. Output will go to the appender's of the root |
|
| 305 | - * ; logger, A2 in this case. |
|
| 306 | - * log4php.logger.class.of.the.day=INHERIT |
|
| 307 | - * </pre> |
|
| 308 | - * |
|
| 309 | - * <p>Refer to the <b>setOption</b> method in each Appender and |
|
| 310 | - * Layout for class specific options.</p> |
|
| 311 | - * |
|
| 312 | - * <p>Use the <b>";"</b> character at the |
|
| 313 | - * beginning of a line for comments.</p> |
|
| 314 | - * |
|
| 315 | - * @param string $url The name of the configuration file where the |
|
| 316 | - * configuration information is stored. |
|
| 317 | - * @param LoggerHierarchy &$repository the repository to apply the configuration |
|
| 318 | - */ |
|
| 319 | - public function doConfigure($url, &$repository) |
|
| 320 | - { |
|
| 321 | - $properties = @parse_ini_file($url); |
|
| 322 | - if ($properties === false) { |
|
| 323 | - LoggerLog::warn("LoggerPropertyConfigurator::doConfigure() cannot load '$url' configuration."); |
|
| 324 | - return false; |
|
| 325 | - } |
|
| 326 | - return $this->doConfigureProperties($properties, $repository); |
|
| 327 | - } |
|
| 124 | + /** |
|
| 125 | + * Read configuration from a file. |
|
| 126 | + * |
|
| 127 | + * <p>The function {@link PHP_MANUAL#parse_ini_file} is used to read the |
|
| 128 | + * file.</p> |
|
| 129 | + * |
|
| 130 | + * <b>The existing configuration is not cleared nor reset.</b> |
|
| 131 | + * If you require a different behavior, then call |
|
| 132 | + * {@link LoggerManager::resetConfiguration()} |
|
| 133 | + * method before calling {@link doConfigure()}. |
|
| 134 | + * |
|
| 135 | + * <p>The configuration file consists of statements in the format |
|
| 136 | + * <b>key=value</b>. The syntax of different configuration |
|
| 137 | + * elements are discussed below. |
|
| 138 | + * |
|
| 139 | + * <p><b>Repository-wide threshold</b></p> |
|
| 140 | + * |
|
| 141 | + * <p>The repository-wide threshold filters logging requests by level |
|
| 142 | + * regardless of logger. The syntax is: |
|
| 143 | + * |
|
| 144 | + * <pre> |
|
| 145 | + * log4php.threshold=[level] |
|
| 146 | + * </pre> |
|
| 147 | + * |
|
| 148 | + * <p>The level value can consist of the string values OFF, FATAL, |
|
| 149 | + * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A |
|
| 150 | + * custom level value can be specified in the form |
|
| 151 | + * <samp>level#classname</samp>. By default the repository-wide threshold is set |
|
| 152 | + * to the lowest possible value, namely the level <b>ALL</b>. |
|
| 153 | + * </p> |
|
| 154 | + * |
|
| 155 | + * |
|
| 156 | + * <p><b>Appender configuration</b></p> |
|
| 157 | + * |
|
| 158 | + * <p>Appender configuration syntax is:</p> |
|
| 159 | + * <pre> |
|
| 160 | + * ; For appender named <i>appenderName</i>, set its class. |
|
| 161 | + * ; Note: The appender name can contain dots. |
|
| 162 | + * log4php.appender.appenderName=name_of_appender_class |
|
| 163 | + * |
|
| 164 | + * ; Set appender specific options. |
|
| 165 | + * |
|
| 166 | + * log4php.appender.appenderName.option1=value1 |
|
| 167 | + * log4php.appender.appenderName.optionN=valueN |
|
| 168 | + * </pre> |
|
| 169 | + * |
|
| 170 | + * For each named appender you can configure its {@link LoggerLayout}. The |
|
| 171 | + * syntax for configuring an appender's layout is: |
|
| 172 | + * <pre> |
|
| 173 | + * log4php.appender.appenderName.layout=name_of_layout_class |
|
| 174 | + * log4php.appender.appenderName.layout.option1=value1 |
|
| 175 | + * .... |
|
| 176 | + * log4php.appender.appenderName.layout.optionN=valueN |
|
| 177 | + * </pre> |
|
| 178 | + * |
|
| 179 | + * <p><b>Configuring loggers</b></p> |
|
| 180 | + * |
|
| 181 | + * <p>The syntax for configuring the root logger is: |
|
| 182 | + * <pre> |
|
| 183 | + * log4php.rootLogger=[level], appenderName, appenderName, ... |
|
| 184 | + * </pre> |
|
| 185 | + * |
|
| 186 | + * <p>This syntax means that an optional <i>level</i> can be |
|
| 187 | + * supplied followed by appender names separated by commas. |
|
| 188 | + * |
|
| 189 | + * <p>The level value can consist of the string values OFF, FATAL, |
|
| 190 | + * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A |
|
| 191 | + * custom level value can be specified in the form</p> |
|
| 192 | + * |
|
| 193 | + * <pre>level#classname</pre> |
|
| 194 | + * |
|
| 195 | + * <p>If a level value is specified, then the root level is set |
|
| 196 | + * to the corresponding level. If no level value is specified, |
|
| 197 | + * then the root level remains untouched. |
|
| 198 | + * |
|
| 199 | + * <p>The root logger can be assigned multiple appenders. |
|
| 200 | + * |
|
| 201 | + * <p>Each <i>appenderName</i> (separated by commas) will be added to |
|
| 202 | + * the root logger. The named appender is defined using the |
|
| 203 | + * appender syntax defined above. |
|
| 204 | + * |
|
| 205 | + * <p>For non-root categories the syntax is almost the same: |
|
| 206 | + * <pre> |
|
| 207 | + * log4php.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ... |
|
| 208 | + * </pre> |
|
| 209 | + * |
|
| 210 | + * <p>The meaning of the optional level value is discussed above |
|
| 211 | + * in relation to the root logger. In addition however, the value |
|
| 212 | + * INHERITED can be specified meaning that the named logger should |
|
| 213 | + * inherit its level from the logger hierarchy.</p> |
|
| 214 | + * |
|
| 215 | + * <p>If no level value is supplied, then the level of the |
|
| 216 | + * named logger remains untouched.</p> |
|
| 217 | + * |
|
| 218 | + * <p>By default categories inherit their level from the |
|
| 219 | + * hierarchy. However, if you set the level of a logger and later |
|
| 220 | + * decide that that logger should inherit its level, then you should |
|
| 221 | + * specify INHERITED as the value for the level value. NULL is a |
|
| 222 | + * synonym for INHERITED.</p> |
|
| 223 | + * |
|
| 224 | + * <p>Similar to the root logger syntax, each <i>appenderName</i> |
|
| 225 | + * (separated by commas) will be attached to the named logger.</p> |
|
| 226 | + * |
|
| 227 | + * <p>See the <i>appender additivity rule</i> in the user manual for |
|
| 228 | + * the meaning of the <b>additivity</b> flag. |
|
| 229 | + * |
|
| 230 | + * <p><b>ObjectRenderers</b></p> |
|
| 231 | + * |
|
| 232 | + * <p>You can customize the way message objects of a given type are |
|
| 233 | + * converted to String before being logged. This is done by |
|
| 234 | + * specifying a {@link LoggerObjectRenderer} |
|
| 235 | + * for the object type would like to customize.</p> |
|
| 236 | + * |
|
| 237 | + * <p>The syntax is: |
|
| 238 | + * |
|
| 239 | + * <pre> |
|
| 240 | + * log4php.renderer.name_of_rendered_class=name_of_rendering.class |
|
| 241 | + * </pre> |
|
| 242 | + * |
|
| 243 | + * As in, |
|
| 244 | + * <pre> |
|
| 245 | + * log4php.renderer.myFruit=myFruitRenderer |
|
| 246 | + * </pre> |
|
| 247 | + * |
|
| 248 | + * <p><b>Logger Factories</b></p> |
|
| 249 | + * |
|
| 250 | + * The usage of custom logger factories is discouraged and no longer |
|
| 251 | + * documented. |
|
| 252 | + * |
|
| 253 | + * <p><b>Example</b></p> |
|
| 254 | + * |
|
| 255 | + * <p>An example configuration is given below. Other configuration |
|
| 256 | + * file examples are given in the <b>tests</b> folder. |
|
| 257 | + * |
|
| 258 | + * <pre> |
|
| 259 | + * ; Set options for appender named "A1". |
|
| 260 | + * ; Appender "A1" will be a SyslogAppender |
|
| 261 | + * log4php.appender.A1=SyslogAppender |
|
| 262 | + * |
|
| 263 | + * ; The syslog daemon resides on www.abc.net |
|
| 264 | + * log4php.appender.A1.SyslogHost=www.abc.net |
|
| 265 | + * |
|
| 266 | + * ; A1's layout is a LoggerPatternLayout, using the conversion pattern |
|
| 267 | + * ; <b>%r %-5p %c{2} %M.%L %x - %m%n</b>. Thus, the log output will |
|
| 268 | + * ; include the relative time since the start of the application in |
|
| 269 | + * ; milliseconds, followed by the level of the log request, |
|
| 270 | + * ; followed by the two rightmost components of the logger name, |
|
| 271 | + * ; followed by the callers method name, followed by the line number, |
|
| 272 | + * ; the nested disgnostic context and finally the message itself. |
|
| 273 | + * ; Refer to the documentation of LoggerPatternLayout} for further information |
|
| 274 | + * ; on the syntax of the ConversionPattern key. |
|
| 275 | + * log4php.appender.A1.layout=LoggerPatternLayout |
|
| 276 | + * log4php.appender.A1.layout.ConversionPattern="%-4r %-5p %c{2} %M.%L %x - %m%n" |
|
| 277 | + * |
|
| 278 | + * ; Set options for appender named "A2" |
|
| 279 | + * ; A2 should be a LoggerAppenderRollingFile, with maximum file size of 10 MB |
|
| 280 | + * ; using at most one backup file. A2's layout is TTCC, using the |
|
| 281 | + * ; ISO8061 date format with context printing enabled. |
|
| 282 | + * log4php.appender.A2=LoggerAppenderRollingFile |
|
| 283 | + * log4php.appender.A2.MaxFileSize=10MB |
|
| 284 | + * log4php.appender.A2.MaxBackupIndex=1 |
|
| 285 | + * log4php.appender.A2.layout=LoggerLayoutTTCC |
|
| 286 | + * log4php.appender.A2.layout.ContextPrinting="true" |
|
| 287 | + * log4php.appender.A2.layout.DateFormat="%c" |
|
| 288 | + * |
|
| 289 | + * ; Root logger set to DEBUG using the A2 appender defined above. |
|
| 290 | + * log4php.rootLogger=DEBUG, A2 |
|
| 291 | + * |
|
| 292 | + * ; Logger definitions: |
|
| 293 | + * ; The SECURITY logger inherits is level from root. However, it's output |
|
| 294 | + * ; will go to A1 appender defined above. It's additivity is non-cumulative. |
|
| 295 | + * log4php.logger.SECURITY=INHERIT, A1 |
|
| 296 | + * log4php.additivity.SECURITY=false |
|
| 297 | + * |
|
| 298 | + * ; Only warnings or above will be logged for the logger "SECURITY.access". |
|
| 299 | + * ; Output will go to A1. |
|
| 300 | + * log4php.logger.SECURITY.access=WARN |
|
| 301 | + * |
|
| 302 | + * |
|
| 303 | + * ; The logger "class.of.the.day" inherits its level from the |
|
| 304 | + * ; logger hierarchy. Output will go to the appender's of the root |
|
| 305 | + * ; logger, A2 in this case. |
|
| 306 | + * log4php.logger.class.of.the.day=INHERIT |
|
| 307 | + * </pre> |
|
| 308 | + * |
|
| 309 | + * <p>Refer to the <b>setOption</b> method in each Appender and |
|
| 310 | + * Layout for class specific options.</p> |
|
| 311 | + * |
|
| 312 | + * <p>Use the <b>";"</b> character at the |
|
| 313 | + * beginning of a line for comments.</p> |
|
| 314 | + * |
|
| 315 | + * @param string $url The name of the configuration file where the |
|
| 316 | + * configuration information is stored. |
|
| 317 | + * @param LoggerHierarchy &$repository the repository to apply the configuration |
|
| 318 | + */ |
|
| 319 | + public function doConfigure($url, &$repository) |
|
| 320 | + { |
|
| 321 | + $properties = @parse_ini_file($url); |
|
| 322 | + if ($properties === false) { |
|
| 323 | + LoggerLog::warn("LoggerPropertyConfigurator::doConfigure() cannot load '$url' configuration."); |
|
| 324 | + return false; |
|
| 325 | + } |
|
| 326 | + return $this->doConfigureProperties($properties, $repository); |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | 329 | |
| 330 | - /** |
|
| 331 | - * Read configuration options from <b>properties</b>. |
|
| 332 | - * |
|
| 333 | - * @see doConfigure(). |
|
| 334 | - * @param array $properties |
|
| 335 | - * @param LoggerHierarchy &$hierarchy |
|
| 336 | - */ |
|
| 337 | - public function doConfigureProperties($properties, &$hierarchy) |
|
| 338 | - { |
|
| 339 | - $value = @$properties[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY]; |
|
| 330 | + /** |
|
| 331 | + * Read configuration options from <b>properties</b>. |
|
| 332 | + * |
|
| 333 | + * @see doConfigure(). |
|
| 334 | + * @param array $properties |
|
| 335 | + * @param LoggerHierarchy &$hierarchy |
|
| 336 | + */ |
|
| 337 | + public function doConfigureProperties($properties, &$hierarchy) |
|
| 338 | + { |
|
| 339 | + $value = @$properties[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY]; |
|
| 340 | 340 | |
| 341 | - if (!empty($value)) { |
|
| 342 | - LoggerLog::internalDebugging(LoggerOptionConverter::toBoolean($value, LoggerLog::internalDebugging())); |
|
| 343 | - } |
|
| 341 | + if (!empty($value)) { |
|
| 342 | + LoggerLog::internalDebugging(LoggerOptionConverter::toBoolean($value, LoggerLog::internalDebugging())); |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - $thresholdStr = @$properties[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX]; |
|
| 346 | - $hierarchy->setThreshold(LoggerOptionConverter::toLevel($thresholdStr, LoggerLevel::getLevelAll())); |
|
| 345 | + $thresholdStr = @$properties[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX]; |
|
| 346 | + $hierarchy->setThreshold(LoggerOptionConverter::toLevel($thresholdStr, LoggerLevel::getLevelAll())); |
|
| 347 | 347 | |
| 348 | - $this->configureRootCategory($properties, $hierarchy); |
|
| 349 | - $this->configureLoggerFactory($properties); |
|
| 350 | - $this->parseCatsAndRenderers($properties, $hierarchy); |
|
| 348 | + $this->configureRootCategory($properties, $hierarchy); |
|
| 349 | + $this->configureLoggerFactory($properties); |
|
| 350 | + $this->parseCatsAndRenderers($properties, $hierarchy); |
|
| 351 | 351 | |
| 352 | - LoggerLog::debug("LoggerPropertyConfigurator::doConfigureProperties() Finished configuring."); |
|
| 352 | + LoggerLog::debug("LoggerPropertyConfigurator::doConfigureProperties() Finished configuring."); |
|
| 353 | 353 | |
| 354 | - return true; |
|
| 355 | - } |
|
| 354 | + return true; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - // -------------------------------------------------------------------------- |
|
| 358 | - // Internal stuff |
|
| 359 | - // -------------------------------------------------------------------------- |
|
| 357 | + // -------------------------------------------------------------------------- |
|
| 358 | + // Internal stuff |
|
| 359 | + // -------------------------------------------------------------------------- |
|
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * Check the provided <b>Properties</b> object for a |
|
| 363 | - * {@link LoggerFactory} entry specified by |
|
| 364 | - * {@link LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY}. |
|
| 365 | - * |
|
| 366 | - * If such an entry exists, an attempt is made to create an instance using |
|
| 367 | - * the default constructor. |
|
| 368 | - * This instance is used for subsequent Category creations |
|
| 369 | - * within this configurator. |
|
| 370 | - * |
|
| 371 | - * @see parseCatsAndRenderers() |
|
| 372 | - * @param array $props array of properties |
|
| 373 | - */ |
|
| 374 | - public function configureLoggerFactory($props) |
|
| 375 | - { |
|
| 376 | - $factoryFqcn = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY]; |
|
| 377 | - if(!empty($factoryFqcn)) { |
|
| 378 | - $factoryClassName = basename($factoryFqcn); |
|
| 379 | - LoggerLog::debug( |
|
| 380 | - "LoggerPropertyConfigurator::configureLoggerFactory() Trying to load factory [" . |
|
| 381 | - $factoryClassName . |
|
| 382 | - "]." |
|
| 383 | - ); |
|
| 361 | + /** |
|
| 362 | + * Check the provided <b>Properties</b> object for a |
|
| 363 | + * {@link LoggerFactory} entry specified by |
|
| 364 | + * {@link LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY}. |
|
| 365 | + * |
|
| 366 | + * If such an entry exists, an attempt is made to create an instance using |
|
| 367 | + * the default constructor. |
|
| 368 | + * This instance is used for subsequent Category creations |
|
| 369 | + * within this configurator. |
|
| 370 | + * |
|
| 371 | + * @see parseCatsAndRenderers() |
|
| 372 | + * @param array $props array of properties |
|
| 373 | + */ |
|
| 374 | + public function configureLoggerFactory($props) |
|
| 375 | + { |
|
| 376 | + $factoryFqcn = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY]; |
|
| 377 | + if(!empty($factoryFqcn)) { |
|
| 378 | + $factoryClassName = basename($factoryFqcn); |
|
| 379 | + LoggerLog::debug( |
|
| 380 | + "LoggerPropertyConfigurator::configureLoggerFactory() Trying to load factory [" . |
|
| 381 | + $factoryClassName . |
|
| 382 | + "]." |
|
| 383 | + ); |
|
| 384 | 384 | |
| 385 | - if (!class_exists($factoryClassName)) |
|
| 386 | - @include_once("{$factoryFqcn}.php"); |
|
| 387 | - if (class_exists($factoryClassName)) { |
|
| 388 | - $loggerFactory = new $factoryClassName(); |
|
| 389 | - } else { |
|
| 390 | - LoggerLog::debug( |
|
| 391 | - "LoggerPropertyConfigurator::configureLoggerFactory() Unable to load factory [" . |
|
| 392 | - $factoryClassName . |
|
| 393 | - "]. Using default." |
|
| 394 | - ); |
|
| 395 | - $loggerFactory = $this->loggerFactory; |
|
| 396 | - } |
|
| 385 | + if (!class_exists($factoryClassName)) |
|
| 386 | + @include_once("{$factoryFqcn}.php"); |
|
| 387 | + if (class_exists($factoryClassName)) { |
|
| 388 | + $loggerFactory = new $factoryClassName(); |
|
| 389 | + } else { |
|
| 390 | + LoggerLog::debug( |
|
| 391 | + "LoggerPropertyConfigurator::configureLoggerFactory() Unable to load factory [" . |
|
| 392 | + $factoryClassName . |
|
| 393 | + "]. Using default." |
|
| 394 | + ); |
|
| 395 | + $loggerFactory = $this->loggerFactory; |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - LoggerLog::debug( |
|
| 399 | - "LoggerPropertyConfigurator::configureLoggerFactory() ". |
|
| 400 | - "Setting properties for category factory [" . get_class($loggerFactory) . "]." |
|
| 401 | - ); |
|
| 398 | + LoggerLog::debug( |
|
| 399 | + "LoggerPropertyConfigurator::configureLoggerFactory() ". |
|
| 400 | + "Setting properties for category factory [" . get_class($loggerFactory) . "]." |
|
| 401 | + ); |
|
| 402 | 402 | |
| 403 | - LoggerPropertySetter::setPropertiesByObject($loggerFactory, $props, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_FACTORY_PREFIX . "."); |
|
| 404 | - } |
|
| 405 | - } |
|
| 403 | + LoggerPropertySetter::setPropertiesByObject($loggerFactory, $props, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_FACTORY_PREFIX . "."); |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | - /** |
|
| 408 | - * @param array $props array of properties |
|
| 409 | - * @param LoggerHierarchy &$hierarchy |
|
| 410 | - */ |
|
| 411 | - public function configureRootCategory($props, &$hierarchy) |
|
| 412 | - { |
|
| 413 | - $effectivePrefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX; |
|
| 414 | - $value = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX]; |
|
| 407 | + /** |
|
| 408 | + * @param array $props array of properties |
|
| 409 | + * @param LoggerHierarchy &$hierarchy |
|
| 410 | + */ |
|
| 411 | + public function configureRootCategory($props, &$hierarchy) |
|
| 412 | + { |
|
| 413 | + $effectivePrefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX; |
|
| 414 | + $value = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX]; |
|
| 415 | 415 | |
| 416 | - if(empty($value)) { |
|
| 417 | - $value = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX]; |
|
| 418 | - $effectivePrefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX; |
|
| 419 | - } |
|
| 416 | + if(empty($value)) { |
|
| 417 | + $value = @$props[LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX]; |
|
| 418 | + $effectivePrefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX; |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | - if (empty($value)) { |
|
| 422 | - LoggerLog::debug( |
|
| 423 | - "LoggerPropertyConfigurator::configureRootCategory() ". |
|
| 424 | - "Could not find root logger information. Is this OK?" |
|
| 425 | - ); |
|
| 426 | - } else { |
|
| 427 | - $root =& $hierarchy->getRootLogger(); |
|
| 428 | - // synchronized(root) { |
|
| 429 | - $this->parseCategory( |
|
| 430 | - $props, |
|
| 431 | - $root, |
|
| 432 | - $effectivePrefix, |
|
| 433 | - LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME, |
|
| 434 | - $value |
|
| 435 | - ); |
|
| 436 | - // } |
|
| 437 | - } |
|
| 438 | - } |
|
| 421 | + if (empty($value)) { |
|
| 422 | + LoggerLog::debug( |
|
| 423 | + "LoggerPropertyConfigurator::configureRootCategory() ". |
|
| 424 | + "Could not find root logger information. Is this OK?" |
|
| 425 | + ); |
|
| 426 | + } else { |
|
| 427 | + $root =& $hierarchy->getRootLogger(); |
|
| 428 | + // synchronized(root) { |
|
| 429 | + $this->parseCategory( |
|
| 430 | + $props, |
|
| 431 | + $root, |
|
| 432 | + $effectivePrefix, |
|
| 433 | + LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME, |
|
| 434 | + $value |
|
| 435 | + ); |
|
| 436 | + // } |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | - /** |
|
| 441 | - * Parse non-root elements, such non-root categories and renderers. |
|
| 442 | - * |
|
| 443 | - * @param array $props array of properties |
|
| 444 | - * @param LoggerHierarchy &$hierarchy |
|
| 445 | - */ |
|
| 446 | - public function parseCatsAndRenderers($props, &$hierarchy) |
|
| 447 | - { |
|
| 448 | - while(list($key,$value) = each($props)) { |
|
| 449 | - if( strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0 || |
|
| 450 | - strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) { |
|
| 451 | - if(strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0) { |
|
| 452 | - $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX)); |
|
| 453 | - } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) { |
|
| 454 | - $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX)); |
|
| 455 | - } |
|
| 456 | - $logger =& $hierarchy->getLogger($loggerName, $this->loggerFactory); |
|
| 457 | - // synchronized(logger) { |
|
| 458 | - $this->parseCategory($props, $logger, $key, $loggerName, $value); |
|
| 459 | - $this->parseAdditivityForLogger($props, $logger, $loggerName); |
|
| 460 | - // } |
|
| 461 | - } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX) === 0) { |
|
| 462 | - $renderedClass = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX)); |
|
| 463 | - $renderingClass = $value; |
|
| 464 | - if (method_exists($hierarchy, 'addrenderer')) { |
|
| 465 | - LoggerRendererMap::addRenderer($hierarchy, $renderedClass, $renderingClass); |
|
| 466 | - } |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - } |
|
| 440 | + /** |
|
| 441 | + * Parse non-root elements, such non-root categories and renderers. |
|
| 442 | + * |
|
| 443 | + * @param array $props array of properties |
|
| 444 | + * @param LoggerHierarchy &$hierarchy |
|
| 445 | + */ |
|
| 446 | + public function parseCatsAndRenderers($props, &$hierarchy) |
|
| 447 | + { |
|
| 448 | + while(list($key,$value) = each($props)) { |
|
| 449 | + if( strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0 || |
|
| 450 | + strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) { |
|
| 451 | + if(strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0) { |
|
| 452 | + $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX)); |
|
| 453 | + } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) { |
|
| 454 | + $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX)); |
|
| 455 | + } |
|
| 456 | + $logger =& $hierarchy->getLogger($loggerName, $this->loggerFactory); |
|
| 457 | + // synchronized(logger) { |
|
| 458 | + $this->parseCategory($props, $logger, $key, $loggerName, $value); |
|
| 459 | + $this->parseAdditivityForLogger($props, $logger, $loggerName); |
|
| 460 | + // } |
|
| 461 | + } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX) === 0) { |
|
| 462 | + $renderedClass = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX)); |
|
| 463 | + $renderingClass = $value; |
|
| 464 | + if (method_exists($hierarchy, 'addrenderer')) { |
|
| 465 | + LoggerRendererMap::addRenderer($hierarchy, $renderedClass, $renderingClass); |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | - /** |
|
| 472 | - * Parse the additivity option for a non-root category. |
|
| 473 | - * |
|
| 474 | - * @param array $props array of properties |
|
| 475 | - * @param Logger &$cat |
|
| 476 | - * @param string $loggerName |
|
| 477 | - */ |
|
| 478 | - public function parseAdditivityForLogger($props, &$cat, $loggerName) |
|
| 479 | - { |
|
| 480 | - $value = LoggerOptionConverter::findAndSubst( |
|
| 481 | - LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName, |
|
| 471 | + /** |
|
| 472 | + * Parse the additivity option for a non-root category. |
|
| 473 | + * |
|
| 474 | + * @param array $props array of properties |
|
| 475 | + * @param Logger &$cat |
|
| 476 | + * @param string $loggerName |
|
| 477 | + */ |
|
| 478 | + public function parseAdditivityForLogger($props, &$cat, $loggerName) |
|
| 479 | + { |
|
| 480 | + $value = LoggerOptionConverter::findAndSubst( |
|
| 481 | + LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName, |
|
| 482 | 482 | $props |
| 483 | - ); |
|
| 484 | - LoggerLog::debug( |
|
| 485 | - "LoggerPropertyConfigurator::parseAdditivityForLogger() ". |
|
| 486 | - "Handling " . LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName . "=[{$value}]" |
|
| 487 | - ); |
|
| 488 | - // touch additivity only if necessary |
|
| 489 | - if(!empty($value)) { |
|
| 490 | - $additivity = LoggerOptionConverter::toBoolean($value, true); |
|
| 491 | - LoggerLog::debug( |
|
| 492 | - "LoggerPropertyConfigurator::parseAdditivityForLogger() ". |
|
| 493 | - "Setting additivity for [{$loggerName}] to [{$additivity}]" |
|
| 494 | - ); |
|
| 495 | - $cat->setAdditivity($additivity); |
|
| 496 | - } |
|
| 497 | - } |
|
| 483 | + ); |
|
| 484 | + LoggerLog::debug( |
|
| 485 | + "LoggerPropertyConfigurator::parseAdditivityForLogger() ". |
|
| 486 | + "Handling " . LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName . "=[{$value}]" |
|
| 487 | + ); |
|
| 488 | + // touch additivity only if necessary |
|
| 489 | + if(!empty($value)) { |
|
| 490 | + $additivity = LoggerOptionConverter::toBoolean($value, true); |
|
| 491 | + LoggerLog::debug( |
|
| 492 | + "LoggerPropertyConfigurator::parseAdditivityForLogger() ". |
|
| 493 | + "Setting additivity for [{$loggerName}] to [{$additivity}]" |
|
| 494 | + ); |
|
| 495 | + $cat->setAdditivity($additivity); |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | - /** |
|
| 500 | - * This method must work for the root category as well. |
|
| 501 | - * |
|
| 502 | - * @param array $props array of properties |
|
| 503 | - * @param Logger &$logger |
|
| 504 | - * @param string $optionKey |
|
| 505 | - * @param string $loggerName |
|
| 506 | - * @param string $value |
|
| 507 | - * @return Logger |
|
| 508 | - */ |
|
| 509 | - public function &parseCategory($props, &$logger, $optionKey, $loggerName, $value) |
|
| 510 | - { |
|
| 511 | - LoggerLog::debug( |
|
| 512 | - "LoggerPropertyConfigurator::parseCategory() ". |
|
| 513 | - "Parsing for [{$loggerName}] with value=[{$value}]." |
|
| 514 | - ); |
|
| 499 | + /** |
|
| 500 | + * This method must work for the root category as well. |
|
| 501 | + * |
|
| 502 | + * @param array $props array of properties |
|
| 503 | + * @param Logger &$logger |
|
| 504 | + * @param string $optionKey |
|
| 505 | + * @param string $loggerName |
|
| 506 | + * @param string $value |
|
| 507 | + * @return Logger |
|
| 508 | + */ |
|
| 509 | + public function &parseCategory($props, &$logger, $optionKey, $loggerName, $value) |
|
| 510 | + { |
|
| 511 | + LoggerLog::debug( |
|
| 512 | + "LoggerPropertyConfigurator::parseCategory() ". |
|
| 513 | + "Parsing for [{$loggerName}] with value=[{$value}]." |
|
| 514 | + ); |
|
| 515 | 515 | |
| 516 | - // We must skip over ',' but not white space |
|
| 517 | - $st = explode(',', $value); |
|
| 516 | + // We must skip over ',' but not white space |
|
| 517 | + $st = explode(',', $value); |
|
| 518 | 518 | |
| 519 | - // If value is not in the form ", appender.." or "", then we should set |
|
| 520 | - // the level of the loggeregory. |
|
| 519 | + // If value is not in the form ", appender.." or "", then we should set |
|
| 520 | + // the level of the loggeregory. |
|
| 521 | 521 | |
| 522 | - if(!(@$value{0} == ',' || empty($value))) { |
|
| 523 | - // just to be on the safe side... |
|
| 524 | - if(sizeof($st) == 0) |
|
| 525 | - return; |
|
| 522 | + if(!(@$value{0} == ',' || empty($value))) { |
|
| 523 | + // just to be on the safe side... |
|
| 524 | + if(sizeof($st) == 0) |
|
| 525 | + return; |
|
| 526 | 526 | |
| 527 | - $levelStr = current($st); |
|
| 528 | - LoggerLog::debug( |
|
| 529 | - "LoggerPropertyConfigurator::parseCategory() ". |
|
| 530 | - "Level token is [$levelStr]." |
|
| 531 | - ); |
|
| 527 | + $levelStr = current($st); |
|
| 528 | + LoggerLog::debug( |
|
| 529 | + "LoggerPropertyConfigurator::parseCategory() ". |
|
| 530 | + "Level token is [$levelStr]." |
|
| 531 | + ); |
|
| 532 | 532 | |
| 533 | - // If the level value is inherited, set category level value to |
|
| 534 | - // null. We also check that the user has not specified inherited for the |
|
| 535 | - // root category. |
|
| 536 | - if('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) { |
|
| 537 | - if ($loggerName == LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME) { |
|
| 538 | - LoggerLog::warn( |
|
| 539 | - "LoggerPropertyConfigurator::parseCategory() ". |
|
| 540 | - "The root logger cannot be set to null." |
|
| 541 | - ); |
|
| 542 | - } else { |
|
| 543 | - $logger->setLevel(null); |
|
| 544 | - } |
|
| 545 | - } else { |
|
| 546 | - $logger->setLevel(LoggerOptionConverter::toLevel($levelStr, LoggerLevel::getLevelDebug())); |
|
| 547 | - } |
|
| 548 | - } |
|
| 533 | + // If the level value is inherited, set category level value to |
|
| 534 | + // null. We also check that the user has not specified inherited for the |
|
| 535 | + // root category. |
|
| 536 | + if('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) { |
|
| 537 | + if ($loggerName == LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME) { |
|
| 538 | + LoggerLog::warn( |
|
| 539 | + "LoggerPropertyConfigurator::parseCategory() ". |
|
| 540 | + "The root logger cannot be set to null." |
|
| 541 | + ); |
|
| 542 | + } else { |
|
| 543 | + $logger->setLevel(null); |
|
| 544 | + } |
|
| 545 | + } else { |
|
| 546 | + $logger->setLevel(LoggerOptionConverter::toLevel($levelStr, LoggerLevel::getLevelDebug())); |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | - // Begin by removing all existing appenders. |
|
| 551 | - $logger->removeAllAppenders(); |
|
| 552 | - while($appenderName = next($st)) { |
|
| 553 | - $appenderName = trim($appenderName); |
|
| 554 | - if(empty($appenderName)) |
|
| 555 | - continue; |
|
| 556 | - LoggerLog::debug( |
|
| 557 | - "LoggerPropertyConfigurator::parseCategory() ". |
|
| 558 | - "Parsing appender named [{$appenderName}]." |
|
| 559 | - ); |
|
| 560 | - $appender =& $this->parseAppender($props, $appenderName); |
|
| 561 | - if($appender !== null) { |
|
| 562 | - $logger->addAppender($appender); |
|
| 563 | - } |
|
| 564 | - } |
|
| 565 | - } |
|
| 550 | + // Begin by removing all existing appenders. |
|
| 551 | + $logger->removeAllAppenders(); |
|
| 552 | + while($appenderName = next($st)) { |
|
| 553 | + $appenderName = trim($appenderName); |
|
| 554 | + if(empty($appenderName)) |
|
| 555 | + continue; |
|
| 556 | + LoggerLog::debug( |
|
| 557 | + "LoggerPropertyConfigurator::parseCategory() ". |
|
| 558 | + "Parsing appender named [{$appenderName}]." |
|
| 559 | + ); |
|
| 560 | + $appender =& $this->parseAppender($props, $appenderName); |
|
| 561 | + if($appender !== null) { |
|
| 562 | + $logger->addAppender($appender); |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - /** |
|
| 568 | - * @param array $props array of properties |
|
| 569 | - * @param string $appenderName |
|
| 570 | - * @return LoggerAppender |
|
| 571 | - */ |
|
| 572 | - public function &parseAppender($props, $appenderName) |
|
| 573 | - { |
|
| 574 | - $appender =& LoggerAppender::singleton($appenderName); |
|
| 575 | - if($appender !== null) { |
|
| 576 | - LoggerLog::debug( |
|
| 577 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 578 | - "Appender [{$appenderName}] was already parsed." |
|
| 579 | - ); |
|
| 580 | - return $appender; |
|
| 581 | - } |
|
| 582 | - // Appender was not previously initialized. |
|
| 583 | - $prefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX . $appenderName; |
|
| 584 | - $layoutPrefix = $prefix . ".layout"; |
|
| 585 | - $appenderClass = @$props[$prefix]; |
|
| 586 | - if (!empty($appenderClass)) { |
|
| 587 | - $appender =& LoggerAppender::singleton($appenderName, $appenderClass); |
|
| 588 | - if($appender === null) { |
|
| 589 | - LoggerLog::warn( |
|
| 590 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 591 | - "Could not instantiate appender named [$appenderName]." |
|
| 592 | - ); |
|
| 593 | - return null; |
|
| 594 | - } |
|
| 595 | - } else { |
|
| 596 | - LoggerLog::warn( |
|
| 597 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 598 | - "Could not instantiate appender named [$appenderName] with null className." |
|
| 599 | - ); |
|
| 600 | - return null; |
|
| 601 | - } |
|
| 567 | + /** |
|
| 568 | + * @param array $props array of properties |
|
| 569 | + * @param string $appenderName |
|
| 570 | + * @return LoggerAppender |
|
| 571 | + */ |
|
| 572 | + public function &parseAppender($props, $appenderName) |
|
| 573 | + { |
|
| 574 | + $appender =& LoggerAppender::singleton($appenderName); |
|
| 575 | + if($appender !== null) { |
|
| 576 | + LoggerLog::debug( |
|
| 577 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 578 | + "Appender [{$appenderName}] was already parsed." |
|
| 579 | + ); |
|
| 580 | + return $appender; |
|
| 581 | + } |
|
| 582 | + // Appender was not previously initialized. |
|
| 583 | + $prefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX . $appenderName; |
|
| 584 | + $layoutPrefix = $prefix . ".layout"; |
|
| 585 | + $appenderClass = @$props[$prefix]; |
|
| 586 | + if (!empty($appenderClass)) { |
|
| 587 | + $appender =& LoggerAppender::singleton($appenderName, $appenderClass); |
|
| 588 | + if($appender === null) { |
|
| 589 | + LoggerLog::warn( |
|
| 590 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 591 | + "Could not instantiate appender named [$appenderName]." |
|
| 592 | + ); |
|
| 593 | + return null; |
|
| 594 | + } |
|
| 595 | + } else { |
|
| 596 | + LoggerLog::warn( |
|
| 597 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 598 | + "Could not instantiate appender named [$appenderName] with null className." |
|
| 599 | + ); |
|
| 600 | + return null; |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - $appender->setName($appenderName); |
|
| 604 | - if( $appender->requiresLayout() ) { |
|
| 605 | - LoggerLog::debug( |
|
| 606 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 607 | - "Parsing layout section for [$appenderName]." |
|
| 608 | - ); |
|
| 609 | - $layoutClass = @$props[$layoutPrefix]; |
|
| 610 | - $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props); |
|
| 611 | - if (empty($layoutClass)) { |
|
| 612 | - LoggerLog::warn( |
|
| 613 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 614 | - "layout class is empty in '$layoutPrefix'. Using Simple layout" |
|
| 615 | - ); |
|
| 616 | - $layout = LoggerLayout::factory('LoggerLayoutSimple'); |
|
| 617 | - } else { |
|
| 618 | - $layout = LoggerLayout::factory($layoutClass); |
|
| 603 | + $appender->setName($appenderName); |
|
| 604 | + if( $appender->requiresLayout() ) { |
|
| 605 | + LoggerLog::debug( |
|
| 606 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 607 | + "Parsing layout section for [$appenderName]." |
|
| 608 | + ); |
|
| 609 | + $layoutClass = @$props[$layoutPrefix]; |
|
| 610 | + $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props); |
|
| 611 | + if (empty($layoutClass)) { |
|
| 612 | + LoggerLog::warn( |
|
| 613 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 614 | + "layout class is empty in '$layoutPrefix'. Using Simple layout" |
|
| 615 | + ); |
|
| 616 | + $layout = LoggerLayout::factory('LoggerLayoutSimple'); |
|
| 617 | + } else { |
|
| 618 | + $layout = LoggerLayout::factory($layoutClass); |
|
| 619 | 619 | |
| 620 | - if($layout === null) { |
|
| 621 | - LoggerLog::warn( |
|
| 622 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 623 | - "cannot create layout '$layoutClass'. Using Simple layout" |
|
| 624 | - ); |
|
| 625 | - $layout = LoggerLayout::factory('LoggerLayoutSimple'); |
|
| 626 | - } |
|
| 627 | - } |
|
| 620 | + if($layout === null) { |
|
| 621 | + LoggerLog::warn( |
|
| 622 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 623 | + "cannot create layout '$layoutClass'. Using Simple layout" |
|
| 624 | + ); |
|
| 625 | + $layout = LoggerLayout::factory('LoggerLayoutSimple'); |
|
| 626 | + } |
|
| 627 | + } |
|
| 628 | 628 | |
| 629 | - LoggerLog::debug( |
|
| 630 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 631 | - "Parsing layout options for [$appenderName]." |
|
| 632 | - ); |
|
| 633 | - LoggerPropertySetter::setPropertiesByObject($layout, $props, $layoutPrefix . "."); |
|
| 634 | - LoggerLog::debug( |
|
| 635 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 636 | - "End Parsing layout options for [$appenderName]." |
|
| 637 | - ); |
|
| 638 | - $appender->setLayout($layout); |
|
| 629 | + LoggerLog::debug( |
|
| 630 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 631 | + "Parsing layout options for [$appenderName]." |
|
| 632 | + ); |
|
| 633 | + LoggerPropertySetter::setPropertiesByObject($layout, $props, $layoutPrefix . "."); |
|
| 634 | + LoggerLog::debug( |
|
| 635 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 636 | + "End Parsing layout options for [$appenderName]." |
|
| 637 | + ); |
|
| 638 | + $appender->setLayout($layout); |
|
| 639 | 639 | |
| 640 | - } |
|
| 641 | - LoggerPropertySetter::setPropertiesByObject($appender, $props, $prefix . "."); |
|
| 642 | - LoggerLog::debug( |
|
| 643 | - "LoggerPropertyConfigurator::parseAppender() ". |
|
| 644 | - "Parsed [{$appenderName}] options." |
|
| 645 | - ); |
|
| 646 | - return $appender; |
|
| 647 | - } |
|
| 640 | + } |
|
| 641 | + LoggerPropertySetter::setPropertiesByObject($appender, $props, $prefix . "."); |
|
| 642 | + LoggerLog::debug( |
|
| 643 | + "LoggerPropertyConfigurator::parseAppender() ". |
|
| 644 | + "Parsed [{$appenderName}] options." |
|
| 645 | + ); |
|
| 646 | + return $appender; |
|
| 647 | + } |
|
| 648 | 648 | |
| 649 | 649 | } |
| 650 | 650 | ?> |
| 651 | 651 | \ No newline at end of file |
@@ -36,537 +36,537 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class LoggerCategory { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Additivity is set to true by default, that is children inherit the |
|
| 41 | - * appenders of their ancestors by default. |
|
| 42 | - * @var boolean |
|
| 43 | - */ |
|
| 44 | - public $additive = true; |
|
| 39 | + /** |
|
| 40 | + * Additivity is set to true by default, that is children inherit the |
|
| 41 | + * appenders of their ancestors by default. |
|
| 42 | + * @var boolean |
|
| 43 | + */ |
|
| 44 | + public $additive = true; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var string fully qualified class name |
|
| 48 | - */ |
|
| 49 | - public $fqcn = 'LoggerCategory'; |
|
| 46 | + /** |
|
| 47 | + * @var string fully qualified class name |
|
| 48 | + */ |
|
| 49 | + public $fqcn = 'LoggerCategory'; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var LoggerLevel The assigned level of this category. |
|
| 53 | - */ |
|
| 54 | - public $level = null; |
|
| 51 | + /** |
|
| 52 | + * @var LoggerLevel The assigned level of this category. |
|
| 53 | + */ |
|
| 54 | + public $level = null; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var string name of this category. |
|
| 58 | - */ |
|
| 59 | - public $name = ''; |
|
| 56 | + /** |
|
| 57 | + * @var string name of this category. |
|
| 58 | + */ |
|
| 59 | + public $name = ''; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var Logger The parent of this category. |
|
| 63 | - */ |
|
| 64 | - public $parent = null; |
|
| 61 | + /** |
|
| 62 | + * @var Logger The parent of this category. |
|
| 63 | + */ |
|
| 64 | + public $parent = null; |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @var LoggerHierarchy the object repository |
|
| 68 | - */ |
|
| 69 | - public $repository = null; |
|
| 66 | + /** |
|
| 67 | + * @var LoggerHierarchy the object repository |
|
| 68 | + */ |
|
| 69 | + public $repository = null; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @var array collection of appenders |
|
| 73 | - * @see LoggerAppender |
|
| 74 | - */ |
|
| 75 | - public $aai = array(); |
|
| 71 | + /** |
|
| 72 | + * @var array collection of appenders |
|
| 73 | + * @see LoggerAppender |
|
| 74 | + */ |
|
| 75 | + public $aai = array(); |
|
| 76 | 76 | |
| 77 | 77 | /* --------------------------------------------------------------------------*/ |
| 78 | 78 | /* --------------------------------------------------------------------------*/ |
| 79 | 79 | /* --------------------------------------------------------------------------*/ |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Constructor. |
|
| 83 | - * |
|
| 84 | - * @param string $name Category name |
|
| 85 | - */ |
|
| 86 | - public function LoggerCategory($name) |
|
| 87 | - { |
|
| 88 | - $this->name = $name; |
|
| 89 | - } |
|
| 81 | + /** |
|
| 82 | + * Constructor. |
|
| 83 | + * |
|
| 84 | + * @param string $name Category name |
|
| 85 | + */ |
|
| 86 | + public function LoggerCategory($name) |
|
| 87 | + { |
|
| 88 | + $this->name = $name; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Add a new Appender to the list of appenders of this Category instance. |
|
| 93 | - * |
|
| 94 | - * @param LoggerAppender $newAppender |
|
| 95 | - */ |
|
| 96 | - public function addAppender(&$newAppender) |
|
| 97 | - { |
|
| 98 | - $appenderName = $newAppender->getName(); |
|
| 99 | - $this->aai[$appenderName] =& $newAppender; |
|
| 100 | - } |
|
| 91 | + /** |
|
| 92 | + * Add a new Appender to the list of appenders of this Category instance. |
|
| 93 | + * |
|
| 94 | + * @param LoggerAppender $newAppender |
|
| 95 | + */ |
|
| 96 | + public function addAppender(&$newAppender) |
|
| 97 | + { |
|
| 98 | + $appenderName = $newAppender->getName(); |
|
| 99 | + $this->aai[$appenderName] =& $newAppender; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * If assertion parameter is false, then logs msg as an error statement. |
|
| 104 | - * |
|
| 105 | - * @param bool $assertion |
|
| 106 | - * @param string $msg message to log |
|
| 107 | - */ |
|
| 108 | - public function assertLog($assertion = true, $msg = '') |
|
| 109 | - { |
|
| 110 | - if ($assertion === false) { |
|
| 111 | - $this->error($msg); |
|
| 112 | - } |
|
| 113 | - } |
|
| 102 | + /** |
|
| 103 | + * If assertion parameter is false, then logs msg as an error statement. |
|
| 104 | + * |
|
| 105 | + * @param bool $assertion |
|
| 106 | + * @param string $msg message to log |
|
| 107 | + */ |
|
| 108 | + public function assertLog($assertion = true, $msg = '') |
|
| 109 | + { |
|
| 110 | + if ($assertion === false) { |
|
| 111 | + $this->error($msg); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Call the appenders in the hierarchy starting at this. |
|
| 117 | - * |
|
| 118 | - * @param LoggerLoggingEvent $event |
|
| 119 | - */ |
|
| 120 | - public function callAppenders($event) |
|
| 121 | - { |
|
| 122 | - if (sizeof($this->aai) > 0) { |
|
| 123 | - foreach (array_keys($this->aai) as $appenderName) { |
|
| 124 | - $this->aai[$appenderName]->doAppend($event); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - if ($this->parent != null && $this->getAdditivity()) { |
|
| 128 | - $this->parent->callAppenders($event); |
|
| 129 | - } |
|
| 130 | - } |
|
| 115 | + /** |
|
| 116 | + * Call the appenders in the hierarchy starting at this. |
|
| 117 | + * |
|
| 118 | + * @param LoggerLoggingEvent $event |
|
| 119 | + */ |
|
| 120 | + public function callAppenders($event) |
|
| 121 | + { |
|
| 122 | + if (sizeof($this->aai) > 0) { |
|
| 123 | + foreach (array_keys($this->aai) as $appenderName) { |
|
| 124 | + $this->aai[$appenderName]->doAppend($event); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + if ($this->parent != null && $this->getAdditivity()) { |
|
| 128 | + $this->parent->callAppenders($event); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Log a message object with the DEBUG level including the caller. |
|
| 134 | - * |
|
| 135 | - * @param mixed $message message |
|
| 136 | - * @param mixed $caller caller object or caller string id |
|
| 137 | - */ |
|
| 138 | - public function debug($message, $caller = null) |
|
| 139 | - { |
|
| 140 | - $debugLevel = LoggerLevel::getLevelDebug(); |
|
| 141 | - if ($this->repository->isDisabled($debugLevel)) { |
|
| 142 | - return; |
|
| 143 | - } |
|
| 144 | - if ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 145 | - $this->forcedLog($this->fqcn, $caller, $debugLevel, $message); |
|
| 146 | - } |
|
| 147 | - } |
|
| 132 | + /** |
|
| 133 | + * Log a message object with the DEBUG level including the caller. |
|
| 134 | + * |
|
| 135 | + * @param mixed $message message |
|
| 136 | + * @param mixed $caller caller object or caller string id |
|
| 137 | + */ |
|
| 138 | + public function debug($message, $caller = null) |
|
| 139 | + { |
|
| 140 | + $debugLevel = LoggerLevel::getLevelDebug(); |
|
| 141 | + if ($this->repository->isDisabled($debugLevel)) { |
|
| 142 | + return; |
|
| 143 | + } |
|
| 144 | + if ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 145 | + $this->forcedLog($this->fqcn, $caller, $debugLevel, $message); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Log a message object with the ERROR level including the caller. |
|
| 151 | - * |
|
| 152 | - * @param mixed $message message |
|
| 153 | - * @param mixed $caller caller object or caller string id |
|
| 154 | - */ |
|
| 155 | - public function error($message, $caller = null) |
|
| 156 | - { |
|
| 157 | - $errorLevel = LoggerLevel::getLevelError(); |
|
| 158 | - if ($this->repository->isDisabled($errorLevel)) { |
|
| 159 | - return; |
|
| 160 | - } |
|
| 161 | - if ($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 162 | - $this->forcedLog($this->fqcn, $caller, $errorLevel, $message); |
|
| 149 | + /** |
|
| 150 | + * Log a message object with the ERROR level including the caller. |
|
| 151 | + * |
|
| 152 | + * @param mixed $message message |
|
| 153 | + * @param mixed $caller caller object or caller string id |
|
| 154 | + */ |
|
| 155 | + public function error($message, $caller = null) |
|
| 156 | + { |
|
| 157 | + $errorLevel = LoggerLevel::getLevelError(); |
|
| 158 | + if ($this->repository->isDisabled($errorLevel)) { |
|
| 159 | + return; |
|
| 160 | + } |
|
| 161 | + if ($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 162 | + $this->forcedLog($this->fqcn, $caller, $errorLevel, $message); |
|
| 163 | 163 | $this->forcedLog($this->fqcn, $caller, $errorLevel, PHP_EOL.vtlib\Functions::getBacktrace(1)); |
| 164 | - } |
|
| 165 | - } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Deprecated. Please use LoggerManager::exists() instead. |
|
| 169 | - * |
|
| 170 | - * @param string $name |
|
| 171 | - * @see LoggerManager::exists() |
|
| 172 | - * @deprecated |
|
| 173 | - */ |
|
| 174 | - public function exists($name) |
|
| 175 | - { |
|
| 176 | - return LoggerManager::exists($name); |
|
| 177 | - } |
|
| 167 | + /** |
|
| 168 | + * Deprecated. Please use LoggerManager::exists() instead. |
|
| 169 | + * |
|
| 170 | + * @param string $name |
|
| 171 | + * @see LoggerManager::exists() |
|
| 172 | + * @deprecated |
|
| 173 | + */ |
|
| 174 | + public function exists($name) |
|
| 175 | + { |
|
| 176 | + return LoggerManager::exists($name); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Log a message object with the FATAL level including the caller. |
|
| 181 | - * |
|
| 182 | - * @param mixed $message message |
|
| 183 | - * @param mixed $caller caller object or caller string id |
|
| 184 | - */ |
|
| 185 | - public function fatal($message, $caller = null) |
|
| 186 | - { |
|
| 187 | - $fatalLevel = LoggerLevel::getLevelFatal(); |
|
| 188 | - if ($this->repository->isDisabled($fatalLevel)) { |
|
| 189 | - return; |
|
| 190 | - } |
|
| 191 | - if ($fatalLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 192 | - $this->forcedLog($this->fqcn, $caller, $fatalLevel, $message); |
|
| 193 | - } |
|
| 194 | - } |
|
| 179 | + /** |
|
| 180 | + * Log a message object with the FATAL level including the caller. |
|
| 181 | + * |
|
| 182 | + * @param mixed $message message |
|
| 183 | + * @param mixed $caller caller object or caller string id |
|
| 184 | + */ |
|
| 185 | + public function fatal($message, $caller = null) |
|
| 186 | + { |
|
| 187 | + $fatalLevel = LoggerLevel::getLevelFatal(); |
|
| 188 | + if ($this->repository->isDisabled($fatalLevel)) { |
|
| 189 | + return; |
|
| 190 | + } |
|
| 191 | + if ($fatalLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 192 | + $this->forcedLog($this->fqcn, $caller, $fatalLevel, $message); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * This method creates a new logging event and logs the event without further checks. |
|
| 198 | - * |
|
| 199 | - * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()}, |
|
| 200 | - * {@link error()} and {@link fatal()} wrappers. |
|
| 201 | - * |
|
| 202 | - * @param string $fqcn Fully Qualified Class Name of the Logger |
|
| 203 | - * @param mixed $caller caller object or caller string id |
|
| 204 | - * @param LoggerLevel $level log level |
|
| 205 | - * @param mixed $message message |
|
| 206 | - * @see LoggerLoggingEvent |
|
| 207 | - */ |
|
| 208 | - public function forcedLog($fqcn, $caller, $level, $message) |
|
| 209 | - { |
|
| 210 | - $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message)); |
|
| 211 | - } |
|
| 196 | + /** |
|
| 197 | + * This method creates a new logging event and logs the event without further checks. |
|
| 198 | + * |
|
| 199 | + * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()}, |
|
| 200 | + * {@link error()} and {@link fatal()} wrappers. |
|
| 201 | + * |
|
| 202 | + * @param string $fqcn Fully Qualified Class Name of the Logger |
|
| 203 | + * @param mixed $caller caller object or caller string id |
|
| 204 | + * @param LoggerLevel $level log level |
|
| 205 | + * @param mixed $message message |
|
| 206 | + * @see LoggerLoggingEvent |
|
| 207 | + */ |
|
| 208 | + public function forcedLog($fqcn, $caller, $level, $message) |
|
| 209 | + { |
|
| 210 | + $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message)); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Get the additivity flag for this Category instance. |
|
| 215 | - * @return boolean |
|
| 216 | - */ |
|
| 217 | - public function getAdditivity() |
|
| 218 | - { |
|
| 219 | - return $this->additive; |
|
| 220 | - } |
|
| 213 | + /** |
|
| 214 | + * Get the additivity flag for this Category instance. |
|
| 215 | + * @return boolean |
|
| 216 | + */ |
|
| 217 | + public function getAdditivity() |
|
| 218 | + { |
|
| 219 | + return $this->additive; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Get the appenders contained in this category as an array. |
|
| 224 | - * @return array collection of appenders |
|
| 225 | - */ |
|
| 226 | - public function &getAllAppenders() |
|
| 227 | - { |
|
| 228 | - $appenders = array(); |
|
| 229 | - $appenderNames = array_keys($this->aai); |
|
| 230 | - $enumAppenders = sizeof($appenderNames); |
|
| 231 | - for ($i = 0; $i < $enumAppenders; $i++) { |
|
| 232 | - $appenderName = $appenderNames[$i]; |
|
| 233 | - $appenders[] =& $this->aai[$appenderName]; |
|
| 234 | - } |
|
| 235 | - return $appenders; |
|
| 236 | - } |
|
| 222 | + /** |
|
| 223 | + * Get the appenders contained in this category as an array. |
|
| 224 | + * @return array collection of appenders |
|
| 225 | + */ |
|
| 226 | + public function &getAllAppenders() |
|
| 227 | + { |
|
| 228 | + $appenders = array(); |
|
| 229 | + $appenderNames = array_keys($this->aai); |
|
| 230 | + $enumAppenders = sizeof($appenderNames); |
|
| 231 | + for ($i = 0; $i < $enumAppenders; $i++) { |
|
| 232 | + $appenderName = $appenderNames[$i]; |
|
| 233 | + $appenders[] =& $this->aai[$appenderName]; |
|
| 234 | + } |
|
| 235 | + return $appenders; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Look for the appender named as name. |
|
| 240 | - * @return LoggerAppender |
|
| 241 | - */ |
|
| 242 | - public function &getAppender($name) |
|
| 243 | - { |
|
| 244 | - return $this->aai[$name]; |
|
| 245 | - } |
|
| 238 | + /** |
|
| 239 | + * Look for the appender named as name. |
|
| 240 | + * @return LoggerAppender |
|
| 241 | + */ |
|
| 242 | + public function &getAppender($name) |
|
| 243 | + { |
|
| 244 | + return $this->aai[$name]; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - /** |
|
| 248 | - * Please use the {@link getEffectiveLevel()} method instead. |
|
| 249 | - * @deprecated |
|
| 250 | - */ |
|
| 251 | - public function getChainedPriority() |
|
| 252 | - { |
|
| 253 | - return $this->getEffectiveLevel(); |
|
| 254 | - } |
|
| 247 | + /** |
|
| 248 | + * Please use the {@link getEffectiveLevel()} method instead. |
|
| 249 | + * @deprecated |
|
| 250 | + */ |
|
| 251 | + public function getChainedPriority() |
|
| 252 | + { |
|
| 253 | + return $this->getEffectiveLevel(); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * Please use {@link LoggerManager::getCurrentLoggers()} instead. |
|
| 258 | - * @deprecated |
|
| 259 | - */ |
|
| 260 | - public function getCurrentCategories() |
|
| 261 | - { |
|
| 262 | - return LoggerManager::getCurrentLoggers(); |
|
| 263 | - } |
|
| 256 | + /** |
|
| 257 | + * Please use {@link LoggerManager::getCurrentLoggers()} instead. |
|
| 258 | + * @deprecated |
|
| 259 | + */ |
|
| 260 | + public function getCurrentCategories() |
|
| 261 | + { |
|
| 262 | + return LoggerManager::getCurrentLoggers(); |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - /** |
|
| 266 | - * Please use {@link LoggerManager::getLoggerRepository()} instead. |
|
| 267 | - * @deprecated |
|
| 268 | - */ |
|
| 269 | - public function &getDefaultHierarchy() |
|
| 270 | - { |
|
| 271 | - return LoggerManager::getLoggerRepository(); |
|
| 272 | - } |
|
| 265 | + /** |
|
| 266 | + * Please use {@link LoggerManager::getLoggerRepository()} instead. |
|
| 267 | + * @deprecated |
|
| 268 | + */ |
|
| 269 | + public function &getDefaultHierarchy() |
|
| 270 | + { |
|
| 271 | + return LoggerManager::getLoggerRepository(); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * @deprecated Use {@link getLoggerRepository()} |
|
| 276 | - * @return LoggerHierarchy |
|
| 277 | - */ |
|
| 278 | - public function &getHierarchy() |
|
| 279 | - { |
|
| 280 | - return $this->getLoggerRepository(); |
|
| 281 | - } |
|
| 274 | + /** |
|
| 275 | + * @deprecated Use {@link getLoggerRepository()} |
|
| 276 | + * @return LoggerHierarchy |
|
| 277 | + */ |
|
| 278 | + public function &getHierarchy() |
|
| 279 | + { |
|
| 280 | + return $this->getLoggerRepository(); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - /** |
|
| 284 | - * Starting from this category, search the category hierarchy for a non-null level and return it. |
|
| 285 | - * @see LoggerLevel |
|
| 286 | - * @return LoggerLevel or null |
|
| 287 | - */ |
|
| 288 | - public function getEffectiveLevel() |
|
| 289 | - { |
|
| 290 | - for($c = $this; $c != null; $c = $c->parent) { |
|
| 291 | - if($c->level !== null) |
|
| 292 | - return $c->level; |
|
| 293 | - } |
|
| 294 | - return null; |
|
| 295 | - } |
|
| 283 | + /** |
|
| 284 | + * Starting from this category, search the category hierarchy for a non-null level and return it. |
|
| 285 | + * @see LoggerLevel |
|
| 286 | + * @return LoggerLevel or null |
|
| 287 | + */ |
|
| 288 | + public function getEffectiveLevel() |
|
| 289 | + { |
|
| 290 | + for($c = $this; $c != null; $c = $c->parent) { |
|
| 291 | + if($c->level !== null) |
|
| 292 | + return $c->level; |
|
| 293 | + } |
|
| 294 | + return null; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - /** |
|
| 298 | - * Retrieve a category with named as the name parameter. |
|
| 299 | - * @return Logger |
|
| 300 | - */ |
|
| 301 | - public function &getInstance($name) |
|
| 302 | - { |
|
| 303 | - return LoggerManager::getLogger($name); |
|
| 304 | - } |
|
| 297 | + /** |
|
| 298 | + * Retrieve a category with named as the name parameter. |
|
| 299 | + * @return Logger |
|
| 300 | + */ |
|
| 301 | + public function &getInstance($name) |
|
| 302 | + { |
|
| 303 | + return LoggerManager::getLogger($name); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - /** |
|
| 307 | - * Returns the assigned Level, if any, for this Category. |
|
| 308 | - * @return LoggerLevel or null |
|
| 309 | - */ |
|
| 310 | - public function getLevel() |
|
| 311 | - { |
|
| 312 | - return $this->level; |
|
| 313 | - } |
|
| 306 | + /** |
|
| 307 | + * Returns the assigned Level, if any, for this Category. |
|
| 308 | + * @return LoggerLevel or null |
|
| 309 | + */ |
|
| 310 | + public function getLevel() |
|
| 311 | + { |
|
| 312 | + return $this->level; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - /** |
|
| 316 | - * Return the the repository where this Category is attached. |
|
| 317 | - * @return LoggerHierarchy |
|
| 318 | - */ |
|
| 319 | - public function &getLoggerRepository() |
|
| 320 | - { |
|
| 321 | - return $this->repository; |
|
| 322 | - } |
|
| 315 | + /** |
|
| 316 | + * Return the the repository where this Category is attached. |
|
| 317 | + * @return LoggerHierarchy |
|
| 318 | + */ |
|
| 319 | + public function &getLoggerRepository() |
|
| 320 | + { |
|
| 321 | + return $this->repository; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - /** |
|
| 325 | - * Return the category name. |
|
| 326 | - * @return string |
|
| 327 | - */ |
|
| 328 | - public function getName() |
|
| 329 | - { |
|
| 330 | - return $this->name; |
|
| 331 | - } |
|
| 324 | + /** |
|
| 325 | + * Return the category name. |
|
| 326 | + * @return string |
|
| 327 | + */ |
|
| 328 | + public function getName() |
|
| 329 | + { |
|
| 330 | + return $this->name; |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - /** |
|
| 334 | - * Returns the parent of this category. |
|
| 335 | - * @return Logger |
|
| 336 | - */ |
|
| 337 | - public function &getParent() |
|
| 338 | - { |
|
| 339 | - return $this->parent; |
|
| 340 | - } |
|
| 333 | + /** |
|
| 334 | + * Returns the parent of this category. |
|
| 335 | + * @return Logger |
|
| 336 | + */ |
|
| 337 | + public function &getParent() |
|
| 338 | + { |
|
| 339 | + return $this->parent; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - /** |
|
| 343 | - * Please use getLevel() instead. |
|
| 344 | - * @deprecated |
|
| 345 | - */ |
|
| 346 | - public function getPriority() |
|
| 347 | - { |
|
| 348 | - return $this->getLevel(); |
|
| 349 | - } |
|
| 342 | + /** |
|
| 343 | + * Please use getLevel() instead. |
|
| 344 | + * @deprecated |
|
| 345 | + */ |
|
| 346 | + public function getPriority() |
|
| 347 | + { |
|
| 348 | + return $this->getLevel(); |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - /** |
|
| 352 | - * Return the inherited ResourceBundle for this category. |
|
| 353 | - */ |
|
| 354 | - public function getResourceBundle() |
|
| 355 | - { |
|
| 356 | - return; |
|
| 357 | - } |
|
| 351 | + /** |
|
| 352 | + * Return the inherited ResourceBundle for this category. |
|
| 353 | + */ |
|
| 354 | + public function getResourceBundle() |
|
| 355 | + { |
|
| 356 | + return; |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - /** |
|
| 360 | - * Returns the string resource coresponding to key in this category's inherited resource bundle. |
|
| 361 | - */ |
|
| 362 | - public function getResourceBundleString($key) |
|
| 363 | - { |
|
| 364 | - return; |
|
| 365 | - } |
|
| 359 | + /** |
|
| 360 | + * Returns the string resource coresponding to key in this category's inherited resource bundle. |
|
| 361 | + */ |
|
| 362 | + public function getResourceBundleString($key) |
|
| 363 | + { |
|
| 364 | + return; |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - /** |
|
| 368 | - * Return the root of the default category hierrachy. |
|
| 369 | - * @return LoggerRoot |
|
| 370 | - */ |
|
| 371 | - public function &getRoot() |
|
| 372 | - { |
|
| 373 | - return LoggerManager::getRootLogger(); |
|
| 374 | - } |
|
| 367 | + /** |
|
| 368 | + * Return the root of the default category hierrachy. |
|
| 369 | + * @return LoggerRoot |
|
| 370 | + */ |
|
| 371 | + public function &getRoot() |
|
| 372 | + { |
|
| 373 | + return LoggerManager::getRootLogger(); |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - /** |
|
| 377 | - * Log a message object with the INFO Level. |
|
| 378 | - * |
|
| 379 | - * @param mixed $message message |
|
| 380 | - * @param mixed $caller caller object or caller string id |
|
| 381 | - */ |
|
| 382 | - public function info($message, $caller = null) |
|
| 383 | - { |
|
| 384 | - $infoLevel = LoggerLevel::getLevelInfo(); |
|
| 385 | - if ($this->repository->isDisabled($infoLevel)) { |
|
| 386 | - return; |
|
| 387 | - } |
|
| 388 | - if ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 389 | - $this->forcedLog($this->fqcn, $caller, $infoLevel, $message); |
|
| 390 | - } |
|
| 391 | - } |
|
| 376 | + /** |
|
| 377 | + * Log a message object with the INFO Level. |
|
| 378 | + * |
|
| 379 | + * @param mixed $message message |
|
| 380 | + * @param mixed $caller caller object or caller string id |
|
| 381 | + */ |
|
| 382 | + public function info($message, $caller = null) |
|
| 383 | + { |
|
| 384 | + $infoLevel = LoggerLevel::getLevelInfo(); |
|
| 385 | + if ($this->repository->isDisabled($infoLevel)) { |
|
| 386 | + return; |
|
| 387 | + } |
|
| 388 | + if ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 389 | + $this->forcedLog($this->fqcn, $caller, $infoLevel, $message); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - /** |
|
| 394 | - * Is the appender passed as parameter attached to this category? |
|
| 395 | - * |
|
| 396 | - * @param LoggerAppender $appender |
|
| 397 | - */ |
|
| 398 | - public function isAttached($appender) |
|
| 399 | - { |
|
| 400 | - return in_array($appender->getName(), array_keys($this->aai)); |
|
| 401 | - } |
|
| 393 | + /** |
|
| 394 | + * Is the appender passed as parameter attached to this category? |
|
| 395 | + * |
|
| 396 | + * @param LoggerAppender $appender |
|
| 397 | + */ |
|
| 398 | + public function isAttached($appender) |
|
| 399 | + { |
|
| 400 | + return in_array($appender->getName(), array_keys($this->aai)); |
|
| 401 | + } |
|
| 402 | 402 | |
| 403 | - /** |
|
| 404 | - * Check whether this category is enabled for the DEBUG Level. |
|
| 405 | - * @return boolean |
|
| 406 | - */ |
|
| 407 | - public function isDebugEnabled() |
|
| 408 | - { |
|
| 409 | - $debugLevel = LoggerLevel::getLevelDebug(); |
|
| 410 | - if ($this->repository->isDisabled($debugLevel)) { |
|
| 411 | - return false; |
|
| 412 | - } |
|
| 413 | - return ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 414 | - } |
|
| 403 | + /** |
|
| 404 | + * Check whether this category is enabled for the DEBUG Level. |
|
| 405 | + * @return boolean |
|
| 406 | + */ |
|
| 407 | + public function isDebugEnabled() |
|
| 408 | + { |
|
| 409 | + $debugLevel = LoggerLevel::getLevelDebug(); |
|
| 410 | + if ($this->repository->isDisabled($debugLevel)) { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 413 | + return ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - /** |
|
| 417 | - * Check whether this category is enabled for a given Level passed as parameter. |
|
| 418 | - * |
|
| 419 | - * @param LoggerLevel level |
|
| 420 | - * @return boolean |
|
| 421 | - */ |
|
| 422 | - public function isEnabledFor($level) |
|
| 423 | - { |
|
| 424 | - if ($this->repository->isDisabled($level)) { |
|
| 425 | - return false; |
|
| 426 | - } |
|
| 427 | - return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 428 | - } |
|
| 416 | + /** |
|
| 417 | + * Check whether this category is enabled for a given Level passed as parameter. |
|
| 418 | + * |
|
| 419 | + * @param LoggerLevel level |
|
| 420 | + * @return boolean |
|
| 421 | + */ |
|
| 422 | + public function isEnabledFor($level) |
|
| 423 | + { |
|
| 424 | + if ($this->repository->isDisabled($level)) { |
|
| 425 | + return false; |
|
| 426 | + } |
|
| 427 | + return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - /** |
|
| 431 | - * Check whether this category is enabled for the info Level. |
|
| 432 | - * @return boolean |
|
| 433 | - * @see LoggerLevel |
|
| 434 | - */ |
|
| 435 | - public function isInfoEnabled() |
|
| 436 | - { |
|
| 437 | - $infoLevel = LoggerLevel::getLevelInfo(); |
|
| 438 | - if ($this->repository->isDisabled($infoLevel)) { |
|
| 439 | - return false; |
|
| 440 | - } |
|
| 441 | - return ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 442 | - } |
|
| 430 | + /** |
|
| 431 | + * Check whether this category is enabled for the info Level. |
|
| 432 | + * @return boolean |
|
| 433 | + * @see LoggerLevel |
|
| 434 | + */ |
|
| 435 | + public function isInfoEnabled() |
|
| 436 | + { |
|
| 437 | + $infoLevel = LoggerLevel::getLevelInfo(); |
|
| 438 | + if ($this->repository->isDisabled($infoLevel)) { |
|
| 439 | + return false; |
|
| 440 | + } |
|
| 441 | + return ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | - /** |
|
| 445 | - * Log a localized and parameterized message. |
|
| 446 | - */ |
|
| 447 | - public function l7dlog($priority, $key, $params, $t) |
|
| 448 | - { |
|
| 449 | - return; |
|
| 450 | - } |
|
| 444 | + /** |
|
| 445 | + * Log a localized and parameterized message. |
|
| 446 | + */ |
|
| 447 | + public function l7dlog($priority, $key, $params, $t) |
|
| 448 | + { |
|
| 449 | + return; |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * This generic form is intended to be used by wrappers. |
|
| 454 | - * |
|
| 455 | - * @param LoggerLevel $priority a valid level |
|
| 456 | - * @param mixed $message message |
|
| 457 | - * @param mixed $caller caller object or caller string id |
|
| 458 | - */ |
|
| 459 | - public function log($priority, $message, $caller = null) |
|
| 460 | - { |
|
| 461 | - if ($this->repository->isDisabled($priority)) { |
|
| 462 | - return; |
|
| 463 | - } |
|
| 464 | - if ($priority->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 465 | - $this->forcedLog($this->fqcn, $caller, $priority, $message); |
|
| 466 | - } |
|
| 467 | - } |
|
| 452 | + /** |
|
| 453 | + * This generic form is intended to be used by wrappers. |
|
| 454 | + * |
|
| 455 | + * @param LoggerLevel $priority a valid level |
|
| 456 | + * @param mixed $message message |
|
| 457 | + * @param mixed $caller caller object or caller string id |
|
| 458 | + */ |
|
| 459 | + public function log($priority, $message, $caller = null) |
|
| 460 | + { |
|
| 461 | + if ($this->repository->isDisabled($priority)) { |
|
| 462 | + return; |
|
| 463 | + } |
|
| 464 | + if ($priority->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 465 | + $this->forcedLog($this->fqcn, $caller, $priority, $message); |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - /** |
|
| 470 | - * Remove all previously added appenders from this Category instance. |
|
| 471 | - */ |
|
| 472 | - public function removeAllAppenders() |
|
| 473 | - { |
|
| 474 | - $appenderNames = array_keys($this->aai); |
|
| 475 | - $enumAppenders = sizeof($appenderNames); |
|
| 476 | - for ($i = 0; $i < $enumAppenders; $i++) { |
|
| 477 | - $this->removeAppender($appenderNames[$i]); |
|
| 478 | - } |
|
| 479 | - } |
|
| 469 | + /** |
|
| 470 | + * Remove all previously added appenders from this Category instance. |
|
| 471 | + */ |
|
| 472 | + public function removeAllAppenders() |
|
| 473 | + { |
|
| 474 | + $appenderNames = array_keys($this->aai); |
|
| 475 | + $enumAppenders = sizeof($appenderNames); |
|
| 476 | + for ($i = 0; $i < $enumAppenders; $i++) { |
|
| 477 | + $this->removeAppender($appenderNames[$i]); |
|
| 478 | + } |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - /** |
|
| 482 | - * Remove the appender passed as parameter form the list of appenders. |
|
| 483 | - * |
|
| 484 | - * @param mixed $appender can be an appender name or a {@link LoggerAppender} object |
|
| 485 | - */ |
|
| 486 | - public function removeAppender($appender) |
|
| 487 | - { |
|
| 488 | - if (is_a($appender, 'loggerappender')) { |
|
| 489 | - $appender->close(); |
|
| 490 | - unset($this->aai[$appender->getName()]); |
|
| 491 | - } elseif (is_string($appender) && isset($this->aai[$appender])) { |
|
| 492 | - $this->aai[$appender]->close(); |
|
| 493 | - unset($this->aai[$appender]); |
|
| 494 | - } |
|
| 495 | - } |
|
| 481 | + /** |
|
| 482 | + * Remove the appender passed as parameter form the list of appenders. |
|
| 483 | + * |
|
| 484 | + * @param mixed $appender can be an appender name or a {@link LoggerAppender} object |
|
| 485 | + */ |
|
| 486 | + public function removeAppender($appender) |
|
| 487 | + { |
|
| 488 | + if (is_a($appender, 'loggerappender')) { |
|
| 489 | + $appender->close(); |
|
| 490 | + unset($this->aai[$appender->getName()]); |
|
| 491 | + } elseif (is_string($appender) && isset($this->aai[$appender])) { |
|
| 492 | + $this->aai[$appender]->close(); |
|
| 493 | + unset($this->aai[$appender]); |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | - /** |
|
| 498 | - * Set the additivity flag for this Category instance. |
|
| 499 | - * |
|
| 500 | - * @param boolean $additive |
|
| 501 | - */ |
|
| 502 | - public function setAdditivity($additive) |
|
| 503 | - { |
|
| 504 | - $this->additive = (bool)$additive; |
|
| 505 | - } |
|
| 497 | + /** |
|
| 498 | + * Set the additivity flag for this Category instance. |
|
| 499 | + * |
|
| 500 | + * @param boolean $additive |
|
| 501 | + */ |
|
| 502 | + public function setAdditivity($additive) |
|
| 503 | + { |
|
| 504 | + $this->additive = (bool)$additive; |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - /** |
|
| 508 | - * @deprecated Please use {@link setLevel()} instead. |
|
| 509 | - * @see setLevel() |
|
| 510 | - */ |
|
| 511 | - public function setPriority($priority) |
|
| 512 | - { |
|
| 513 | - $this->setLevel($priority); |
|
| 514 | - } |
|
| 507 | + /** |
|
| 508 | + * @deprecated Please use {@link setLevel()} instead. |
|
| 509 | + * @see setLevel() |
|
| 510 | + */ |
|
| 511 | + public function setPriority($priority) |
|
| 512 | + { |
|
| 513 | + $this->setLevel($priority); |
|
| 514 | + } |
|
| 515 | 515 | |
| 516 | - /** |
|
| 517 | - * Only the Hiearchy class can set the hiearchy of a |
|
| 518 | - * category. |
|
| 519 | - * |
|
| 520 | - * @param LoggerHierarchy &$repository |
|
| 521 | - */ |
|
| 522 | - public function setHierarchy(&$repository) |
|
| 523 | - { |
|
| 524 | - $this->repository =& $repository; |
|
| 525 | - } |
|
| 516 | + /** |
|
| 517 | + * Only the Hiearchy class can set the hiearchy of a |
|
| 518 | + * category. |
|
| 519 | + * |
|
| 520 | + * @param LoggerHierarchy &$repository |
|
| 521 | + */ |
|
| 522 | + public function setHierarchy(&$repository) |
|
| 523 | + { |
|
| 524 | + $this->repository =& $repository; |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - /** |
|
| 528 | - * Set the level of this Category. |
|
| 529 | - * |
|
| 530 | - * @param LoggerLevel $level a level string or a level costant |
|
| 531 | - */ |
|
| 532 | - public function setLevel($level) |
|
| 533 | - { |
|
| 534 | - $this->level = $level; |
|
| 535 | - } |
|
| 527 | + /** |
|
| 528 | + * Set the level of this Category. |
|
| 529 | + * |
|
| 530 | + * @param LoggerLevel $level a level string or a level costant |
|
| 531 | + */ |
|
| 532 | + public function setLevel($level) |
|
| 533 | + { |
|
| 534 | + $this->level = $level; |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | - /** |
|
| 538 | - * Set the resource bundle to be used with localized logging methods |
|
| 539 | - */ |
|
| 540 | - public function setResourceBundle($bundle) |
|
| 541 | - { |
|
| 542 | - return; |
|
| 543 | - } |
|
| 537 | + /** |
|
| 538 | + * Set the resource bundle to be used with localized logging methods |
|
| 539 | + */ |
|
| 540 | + public function setResourceBundle($bundle) |
|
| 541 | + { |
|
| 542 | + return; |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | - /** |
|
| 546 | - * @deprecated use {@link LoggerManager::shutdown()} instead. |
|
| 547 | - * @see LoggerManager::shutdown() |
|
| 548 | - */ |
|
| 549 | - public function shutdown() |
|
| 550 | - { |
|
| 551 | - LoggerManager::shutdown(); |
|
| 552 | - } |
|
| 545 | + /** |
|
| 546 | + * @deprecated use {@link LoggerManager::shutdown()} instead. |
|
| 547 | + * @see LoggerManager::shutdown() |
|
| 548 | + */ |
|
| 549 | + public function shutdown() |
|
| 550 | + { |
|
| 551 | + LoggerManager::shutdown(); |
|
| 552 | + } |
|
| 553 | 553 | |
| 554 | - /** |
|
| 555 | - * Log a message with the WARN level. |
|
| 556 | - * |
|
| 557 | - * @param mixed $message message |
|
| 558 | - * @param mixed $caller caller object or caller string id |
|
| 559 | - */ |
|
| 560 | - public function warn($message, $caller = null) |
|
| 561 | - { |
|
| 562 | - $warnLevel = LoggerLevel::getLevelWarn(); |
|
| 563 | - if ($this->repository->isDisabled($warnLevel)) { |
|
| 564 | - return; |
|
| 565 | - } |
|
| 566 | - if ($warnLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 567 | - $this->forcedLog($this->fqcn, $caller, $warnLevel, $message); |
|
| 568 | - } |
|
| 569 | - } |
|
| 554 | + /** |
|
| 555 | + * Log a message with the WARN level. |
|
| 556 | + * |
|
| 557 | + * @param mixed $message message |
|
| 558 | + * @param mixed $caller caller object or caller string id |
|
| 559 | + */ |
|
| 560 | + public function warn($message, $caller = null) |
|
| 561 | + { |
|
| 562 | + $warnLevel = LoggerLevel::getLevelWarn(); |
|
| 563 | + if ($this->repository->isDisabled($warnLevel)) { |
|
| 564 | + return; |
|
| 565 | + } |
|
| 566 | + if ($warnLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 567 | + $this->forcedLog($this->fqcn, $caller, $warnLevel, $message); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | 571 | } |
| 572 | 572 | ?> |
@@ -41,38 +41,38 @@ discard block |
||
| 41 | 41 | * appenders of their ancestors by default. |
| 42 | 42 | * @var boolean |
| 43 | 43 | */ |
| 44 | - public $additive = true; |
|
| 44 | + public $additive = true; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @var string fully qualified class name |
| 48 | 48 | */ |
| 49 | - public $fqcn = 'LoggerCategory'; |
|
| 49 | + public $fqcn = 'LoggerCategory'; |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @var LoggerLevel The assigned level of this category. |
| 53 | 53 | */ |
| 54 | - public $level = null; |
|
| 54 | + public $level = null; |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @var string name of this category. |
| 58 | 58 | */ |
| 59 | - public $name = ''; |
|
| 59 | + public $name = ''; |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @var Logger The parent of this category. |
| 63 | 63 | */ |
| 64 | - public $parent = null; |
|
| 64 | + public $parent = null; |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * @var LoggerHierarchy the object repository |
| 68 | 68 | */ |
| 69 | - public $repository = null; |
|
| 69 | + public $repository = null; |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @var array collection of appenders |
| 73 | 73 | * @see LoggerAppender |
| 74 | 74 | */ |
| 75 | - public $aai = array(); |
|
| 75 | + public $aai = array(); |
|
| 76 | 76 | |
| 77 | 77 | /* --------------------------------------------------------------------------*/ |
| 78 | 78 | /* --------------------------------------------------------------------------*/ |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | public function addAppender(&$newAppender) |
| 97 | 97 | { |
| 98 | 98 | $appenderName = $newAppender->getName(); |
| 99 | - $this->aai[$appenderName] =& $newAppender; |
|
| 99 | + $this->aai[$appenderName] = & $newAppender; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | if ($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
| 162 | 162 | $this->forcedLog($this->fqcn, $caller, $errorLevel, $message); |
| 163 | - $this->forcedLog($this->fqcn, $caller, $errorLevel, PHP_EOL.vtlib\Functions::getBacktrace(1)); |
|
| 163 | + $this->forcedLog($this->fqcn, $caller, $errorLevel, PHP_EOL . vtlib\Functions::getBacktrace(1)); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $enumAppenders = sizeof($appenderNames); |
| 231 | 231 | for ($i = 0; $i < $enumAppenders; $i++) { |
| 232 | 232 | $appenderName = $appenderNames[$i]; |
| 233 | - $appenders[] =& $this->aai[$appenderName]; |
|
| 233 | + $appenders[] = & $this->aai[$appenderName]; |
|
| 234 | 234 | } |
| 235 | 235 | return $appenders; |
| 236 | 236 | } |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public function getEffectiveLevel() |
| 289 | 289 | { |
| 290 | - for($c = $this; $c != null; $c = $c->parent) { |
|
| 291 | - if($c->level !== null) |
|
| 290 | + for ($c = $this; $c != null; $c = $c->parent) { |
|
| 291 | + if ($c->level !== null) |
|
| 292 | 292 | return $c->level; |
| 293 | 293 | } |
| 294 | 294 | return null; |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | if ($this->repository->isDisabled($level)) { |
| 425 | 425 | return false; |
| 426 | 426 | } |
| 427 | - return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 427 | + return (bool) ($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | */ |
| 502 | 502 | public function setAdditivity($additive) |
| 503 | 503 | { |
| 504 | - $this->additive = (bool)$additive; |
|
| 504 | + $this->additive = (bool) $additive; |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | /** |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | */ |
| 522 | 522 | public function setHierarchy(&$repository) |
| 523 | 523 | { |
| 524 | - $this->repository =& $repository; |
|
| 524 | + $this->repository = & $repository; |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |