@@ -24,21 +24,21 @@ |
||
24 | 24 | */ |
25 | 25 | class LoggerCategoryPatternConverter extends LoggerNamedPatternConverter { |
26 | 26 | |
27 | - /** |
|
28 | - * Constructor |
|
29 | - * |
|
30 | - * @param string $formattingInfo |
|
31 | - * @param integer $precision |
|
32 | - */ |
|
33 | - public function __construct($formattingInfo, $precision) { |
|
34 | - parent::__construct($formattingInfo, $precision); |
|
35 | - } |
|
27 | + /** |
|
28 | + * Constructor |
|
29 | + * |
|
30 | + * @param string $formattingInfo |
|
31 | + * @param integer $precision |
|
32 | + */ |
|
33 | + public function __construct($formattingInfo, $precision) { |
|
34 | + parent::__construct($formattingInfo, $precision); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param LoggerLoggingEvent $event |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function getFullyQualifiedName($event) { |
|
42 | - return $event->getLoggerName(); |
|
43 | - } |
|
37 | + /** |
|
38 | + * @param LoggerLoggingEvent $event |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function getFullyQualifiedName($event) { |
|
42 | + return $event->getLoggerName(); |
|
43 | + } |
|
44 | 44 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | - * contributor license agreements. See the NOTICE file distributed with |
|
5 | - * this work for additional information regarding copyright ownership. |
|
6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | - * (the "License"); you may not use this file except in compliance with |
|
8 | - * the License. You may obtain a copy of the License at |
|
9 | - * |
|
10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | - * |
|
12 | - * Unless required by applicable law or agreed to in writing, software |
|
13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | - * See the License for the specific language governing permissions and |
|
16 | - * limitations under the License. |
|
17 | - * |
|
18 | - * @package log4php |
|
19 | - */ |
|
3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | + * contributor license agreements. See the NOTICE file distributed with |
|
5 | + * this work for additional information regarding copyright ownership. |
|
6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | + * (the "License"); you may not use this file except in compliance with |
|
8 | + * the License. You may obtain a copy of the License at |
|
9 | + * |
|
10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + * |
|
12 | + * Unless required by applicable law or agreed to in writing, software |
|
13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + * See the License for the specific language governing permissions and |
|
16 | + * limitations under the License. |
|
17 | + * |
|
18 | + * @package log4php |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @package log4php |
@@ -24,27 +24,27 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class LoggerMDCPatternConverter extends LoggerPatternConverter { |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - private $key; |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + private $key; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor |
|
34 | - * |
|
35 | - * @param string $formattingInfo |
|
36 | - * @param string $key |
|
37 | - */ |
|
38 | - public function __construct($formattingInfo, $key) { |
|
39 | - parent::__construct($formattingInfo); |
|
40 | - $this->key = $key; |
|
41 | - } |
|
32 | + /** |
|
33 | + * Constructor |
|
34 | + * |
|
35 | + * @param string $formattingInfo |
|
36 | + * @param string $key |
|
37 | + */ |
|
38 | + public function __construct($formattingInfo, $key) { |
|
39 | + parent::__construct($formattingInfo); |
|
40 | + $this->key = $key; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param LoggerLoggingEvent $event |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function convert($event) { |
|
48 | - return $event->getMDC($this->key); |
|
49 | - } |
|
43 | + /** |
|
44 | + * @param LoggerLoggingEvent $event |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function convert($event) { |
|
48 | + return $event->getMDC($this->key); |
|
49 | + } |
|
50 | 50 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | - * contributor license agreements. See the NOTICE file distributed with |
|
5 | - * this work for additional information regarding copyright ownership. |
|
6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | - * (the "License"); you may not use this file except in compliance with |
|
8 | - * the License. You may obtain a copy of the License at |
|
9 | - * |
|
10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | - * |
|
12 | - * Unless required by applicable law or agreed to in writing, software |
|
13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | - * See the License for the specific language governing permissions and |
|
16 | - * limitations under the License. |
|
17 | - * |
|
18 | - * @package log4php |
|
19 | - */ |
|
3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | + * contributor license agreements. See the NOTICE file distributed with |
|
5 | + * this work for additional information regarding copyright ownership. |
|
6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | + * (the "License"); you may not use this file except in compliance with |
|
8 | + * the License. You may obtain a copy of the License at |
|
9 | + * |
|
10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + * |
|
12 | + * Unless required by applicable law or agreed to in writing, software |
|
13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + * See the License for the specific language governing permissions and |
|
16 | + * limitations under the License. |
|
17 | + * |
|
18 | + * @package log4php |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @package log4php |
@@ -24,22 +24,22 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class LoggerClassNamePatternConverter extends LoggerNamedPatternConverter { |
26 | 26 | |
27 | - /** |
|
28 | - * Constructor |
|
29 | - * |
|
30 | - * @param string $formattingInfo |
|
31 | - * @param integer $precision |
|
32 | - */ |
|
33 | - public function __construct($formattingInfo, $precision) { |
|
34 | - parent::__construct($formattingInfo, $precision); |
|
35 | - } |
|
27 | + /** |
|
28 | + * Constructor |
|
29 | + * |
|
30 | + * @param string $formattingInfo |
|
31 | + * @param integer $precision |
|
32 | + */ |
|
33 | + public function __construct($formattingInfo, $precision) { |
|
34 | + parent::__construct($formattingInfo, $precision); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param LoggerLoggingEvent $event |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function getFullyQualifiedName($event) { |
|
42 | - return $event->fqcn; |
|
43 | - } |
|
37 | + /** |
|
38 | + * @param LoggerLoggingEvent $event |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function getFullyQualifiedName($event) { |
|
42 | + return $event->fqcn; |
|
43 | + } |
|
44 | 44 | } |
45 | 45 |
@@ -24,30 +24,30 @@ |
||
24 | 24 | */ |
25 | 25 | class LoggerDatePatternConverter extends LoggerPatternConverter { |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - private $df; |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + private $df; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor |
|
34 | - * |
|
35 | - * @param string $formattingInfo |
|
36 | - * @param string $df |
|
37 | - */ |
|
38 | - public function __construct($formattingInfo, $df) { |
|
39 | - parent::__construct($formattingInfo); |
|
40 | - $this->df = $df; |
|
41 | - } |
|
32 | + /** |
|
33 | + * Constructor |
|
34 | + * |
|
35 | + * @param string $formattingInfo |
|
36 | + * @param string $df |
|
37 | + */ |
|
38 | + public function __construct($formattingInfo, $df) { |
|
39 | + parent::__construct($formattingInfo); |
|
40 | + $this->df = $df; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param LoggerLoggingEvent $event |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function convert($event) { |
|
48 | - $timeStamp = $event->getTimeStamp(); |
|
49 | - $usecs = round(($timeStamp - (int)$timeStamp) * 1000); |
|
50 | - $this->df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df); |
|
51 | - return date($this->df, $event->getTimeStamp()); |
|
52 | - } |
|
43 | + /** |
|
44 | + * @param LoggerLoggingEvent $event |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function convert($event) { |
|
48 | + $timeStamp = $event->getTimeStamp(); |
|
49 | + $usecs = round(($timeStamp - (int)$timeStamp) * 1000); |
|
50 | + $this->df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df); |
|
51 | + return date($this->df, $event->getTimeStamp()); |
|
52 | + } |
|
53 | 53 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | - * contributor license agreements. See the NOTICE file distributed with |
|
5 | - * this work for additional information regarding copyright ownership. |
|
6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | - * (the "License"); you may not use this file except in compliance with |
|
8 | - * the License. You may obtain a copy of the License at |
|
9 | - * |
|
10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | - * |
|
12 | - * Unless required by applicable law or agreed to in writing, software |
|
13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | - * See the License for the specific language governing permissions and |
|
16 | - * limitations under the License. |
|
17 | - * |
|
18 | - * @package log4php |
|
19 | - */ |
|
3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | + * contributor license agreements. See the NOTICE file distributed with |
|
5 | + * this work for additional information regarding copyright ownership. |
|
6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | + * (the "License"); you may not use this file except in compliance with |
|
8 | + * the License. You may obtain a copy of the License at |
|
9 | + * |
|
10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + * |
|
12 | + * Unless required by applicable law or agreed to in writing, software |
|
13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + * See the License for the specific language governing permissions and |
|
16 | + * limitations under the License. |
|
17 | + * |
|
18 | + * @package log4php |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Most of the work of the {@link LoggerPatternLayout} class |
@@ -33,309 +33,309 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class LoggerPatternParser { |
35 | 35 | |
36 | - const ESCAPE_CHAR = '%'; |
|
36 | + const ESCAPE_CHAR = '%'; |
|
37 | 37 | |
38 | - const LITERAL_STATE = 0; |
|
39 | - const CONVERTER_STATE = 1; |
|
40 | - const MINUS_STATE = 2; |
|
41 | - const DOT_STATE = 3; |
|
42 | - const MIN_STATE = 4; |
|
43 | - const MAX_STATE = 5; |
|
38 | + const LITERAL_STATE = 0; |
|
39 | + const CONVERTER_STATE = 1; |
|
40 | + const MINUS_STATE = 2; |
|
41 | + const DOT_STATE = 3; |
|
42 | + const MIN_STATE = 4; |
|
43 | + const MAX_STATE = 5; |
|
44 | 44 | |
45 | - const FULL_LOCATION_CONVERTER = 1000; |
|
46 | - const METHOD_LOCATION_CONVERTER = 1001; |
|
47 | - const CLASS_LOCATION_CONVERTER = 1002; |
|
48 | - const FILE_LOCATION_CONVERTER = 1003; |
|
49 | - const LINE_LOCATION_CONVERTER = 1004; |
|
45 | + const FULL_LOCATION_CONVERTER = 1000; |
|
46 | + const METHOD_LOCATION_CONVERTER = 1001; |
|
47 | + const CLASS_LOCATION_CONVERTER = 1002; |
|
48 | + const FILE_LOCATION_CONVERTER = 1003; |
|
49 | + const LINE_LOCATION_CONVERTER = 1004; |
|
50 | 50 | |
51 | - const RELATIVE_TIME_CONVERTER = 2000; |
|
52 | - const THREAD_CONVERTER = 2001; |
|
53 | - const LEVEL_CONVERTER = 2002; |
|
54 | - const NDC_CONVERTER = 2003; |
|
55 | - const MESSAGE_CONVERTER = 2004; |
|
51 | + const RELATIVE_TIME_CONVERTER = 2000; |
|
52 | + const THREAD_CONVERTER = 2001; |
|
53 | + const LEVEL_CONVERTER = 2002; |
|
54 | + const NDC_CONVERTER = 2003; |
|
55 | + const MESSAGE_CONVERTER = 2004; |
|
56 | 56 | |
57 | - const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; |
|
58 | - const DATE_FORMAT_ABSOLUTE = 'H:i:s'; |
|
59 | - const DATE_FORMAT_DATE = 'd M Y H:i:s,u'; |
|
57 | + const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; |
|
58 | + const DATE_FORMAT_ABSOLUTE = 'H:i:s'; |
|
59 | + const DATE_FORMAT_DATE = 'd M Y H:i:s,u'; |
|
60 | 60 | |
61 | - private $state; |
|
62 | - private $currentLiteral; |
|
63 | - private $patternLength; |
|
64 | - private $i; |
|
61 | + private $state; |
|
62 | + private $currentLiteral; |
|
63 | + private $patternLength; |
|
64 | + private $i; |
|
65 | 65 | |
66 | - /** |
|
67 | - * @var LoggerPatternConverter |
|
68 | - */ |
|
69 | - private $head = null; |
|
66 | + /** |
|
67 | + * @var LoggerPatternConverter |
|
68 | + */ |
|
69 | + private $head = null; |
|
70 | 70 | |
71 | - /** |
|
72 | - * @var LoggerPatternConverter |
|
73 | - */ |
|
74 | - private $tail = null; |
|
71 | + /** |
|
72 | + * @var LoggerPatternConverter |
|
73 | + */ |
|
74 | + private $tail = null; |
|
75 | 75 | |
76 | - /** |
|
77 | - * @var LoggerFormattingInfo |
|
78 | - */ |
|
79 | - private $formattingInfo; |
|
76 | + /** |
|
77 | + * @var LoggerFormattingInfo |
|
78 | + */ |
|
79 | + private $formattingInfo; |
|
80 | 80 | |
81 | - /** |
|
82 | - * @var string pattern to parse |
|
83 | - */ |
|
84 | - private $pattern; |
|
81 | + /** |
|
82 | + * @var string pattern to parse |
|
83 | + */ |
|
84 | + private $pattern; |
|
85 | 85 | |
86 | - /** |
|
87 | - * Constructor |
|
88 | - * |
|
89 | - * @param string $pattern |
|
90 | - */ |
|
91 | - public function __construct($pattern) { |
|
92 | - $this->pattern = $pattern; |
|
93 | - $this->patternLength = strlen($pattern); |
|
94 | - $this->formattingInfo = new LoggerFormattingInfo(); |
|
95 | - $this->state = self::LITERAL_STATE; |
|
96 | - } |
|
86 | + /** |
|
87 | + * Constructor |
|
88 | + * |
|
89 | + * @param string $pattern |
|
90 | + */ |
|
91 | + public function __construct($pattern) { |
|
92 | + $this->pattern = $pattern; |
|
93 | + $this->patternLength = strlen($pattern); |
|
94 | + $this->formattingInfo = new LoggerFormattingInfo(); |
|
95 | + $this->state = self::LITERAL_STATE; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * @param LoggerPatternConverter $pc |
|
100 | - */ |
|
101 | - public function addToList($pc) { |
|
102 | - if($this->head == null) { |
|
103 | - $this->head = $pc; |
|
104 | - $this->tail = $this->head; |
|
105 | - } else { |
|
106 | - $this->tail->next = $pc; |
|
107 | - $this->tail = $this->tail->next; |
|
108 | - } |
|
109 | - } |
|
98 | + /** |
|
99 | + * @param LoggerPatternConverter $pc |
|
100 | + */ |
|
101 | + public function addToList($pc) { |
|
102 | + if($this->head == null) { |
|
103 | + $this->head = $pc; |
|
104 | + $this->tail = $this->head; |
|
105 | + } else { |
|
106 | + $this->tail->next = $pc; |
|
107 | + $this->tail = $this->tail->next; |
|
108 | + } |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function extractOption() { |
|
115 | - if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
116 | - $end = strpos($this->pattern, '}' , $this->i); |
|
117 | - if($end !== false) { |
|
118 | - $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
|
119 | - $this->i= $end + 1; |
|
120 | - return $r; |
|
121 | - } |
|
122 | - } |
|
123 | - return null; |
|
124 | - } |
|
111 | + /** |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function extractOption() { |
|
115 | + if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
116 | + $end = strpos($this->pattern, '}' , $this->i); |
|
117 | + if($end !== false) { |
|
118 | + $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
|
119 | + $this->i= $end + 1; |
|
120 | + return $r; |
|
121 | + } |
|
122 | + } |
|
123 | + return null; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * The option is expected to be in decimal and positive. In case of |
|
128 | - * error, zero is returned. |
|
129 | - */ |
|
130 | - public function extractPrecisionOption() { |
|
131 | - $opt = $this->extractOption(); |
|
132 | - $r = 0; |
|
133 | - if($opt !== null) { |
|
134 | - if(is_numeric($opt)) { |
|
135 | - $r = (int)$opt; |
|
136 | - if($r <= 0) { |
|
137 | - $r = 0; |
|
138 | - } |
|
139 | - } |
|
140 | - } |
|
141 | - return $r; |
|
142 | - } |
|
126 | + /** |
|
127 | + * The option is expected to be in decimal and positive. In case of |
|
128 | + * error, zero is returned. |
|
129 | + */ |
|
130 | + public function extractPrecisionOption() { |
|
131 | + $opt = $this->extractOption(); |
|
132 | + $r = 0; |
|
133 | + if($opt !== null) { |
|
134 | + if(is_numeric($opt)) { |
|
135 | + $r = (int)$opt; |
|
136 | + if($r <= 0) { |
|
137 | + $r = 0; |
|
138 | + } |
|
139 | + } |
|
140 | + } |
|
141 | + return $r; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | |
145 | - /** Parser. |
|
146 | - * |
|
147 | - * @return LoggerPatternConverter Returns $this->head. |
|
148 | - */ |
|
149 | - public function parse() { |
|
150 | - $c = ''; |
|
151 | - $this->i = 0; |
|
152 | - $this->currentLiteral = ''; |
|
153 | - while($this->i < $this->patternLength) { |
|
154 | - $c = $this->pattern{$this->i++}; |
|
145 | + /** Parser. |
|
146 | + * |
|
147 | + * @return LoggerPatternConverter Returns $this->head. |
|
148 | + */ |
|
149 | + public function parse() { |
|
150 | + $c = ''; |
|
151 | + $this->i = 0; |
|
152 | + $this->currentLiteral = ''; |
|
153 | + while($this->i < $this->patternLength) { |
|
154 | + $c = $this->pattern{$this->i++}; |
|
155 | 155 | |
156 | - switch($this->state) { |
|
157 | - case self::LITERAL_STATE: |
|
158 | - // In literal state, the last char is always a literal. |
|
159 | - if($this->i == $this->patternLength) { |
|
160 | - $this->currentLiteral .= $c; |
|
161 | - continue; |
|
162 | - } |
|
163 | - if($c == self::ESCAPE_CHAR) { |
|
164 | - // peek at the next char. |
|
165 | - switch($this->pattern{$this->i}) { |
|
166 | - case self::ESCAPE_CHAR: |
|
167 | - $this->currentLiteral .= $c; |
|
168 | - $this->i++; // move pointer |
|
169 | - break; |
|
170 | - case 'n': |
|
171 | - $this->currentLiteral .= PHP_EOL; |
|
172 | - $this->i++; // move pointer |
|
173 | - break; |
|
174 | - default: |
|
175 | - if(strlen($this->currentLiteral) != 0) { |
|
176 | - $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
177 | - } |
|
178 | - $this->currentLiteral = $c; |
|
179 | - $this->state = self::CONVERTER_STATE; |
|
180 | - $this->formattingInfo->reset(); |
|
181 | - } |
|
182 | - } else { |
|
183 | - $this->currentLiteral .= $c; |
|
184 | - } |
|
185 | - break; |
|
186 | - case self::CONVERTER_STATE: |
|
187 | - $this->currentLiteral .= $c; |
|
188 | - switch($c) { |
|
189 | - case '-': |
|
190 | - $this->formattingInfo->leftAlign = true; |
|
191 | - break; |
|
192 | - case '.': |
|
193 | - $this->state = self::DOT_STATE; |
|
194 | - break; |
|
195 | - default: |
|
196 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
197 | - $this->formattingInfo->min = ord($c) - ord('0'); |
|
198 | - $this->state = self::MIN_STATE; |
|
199 | - } else { |
|
200 | - $this->finalizeConverter($c); |
|
201 | - } |
|
202 | - } // switch |
|
203 | - break; |
|
204 | - case self::MIN_STATE: |
|
205 | - $this->currentLiteral .= $c; |
|
206 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
207 | - $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0')); |
|
208 | - } else if ($c == '.') { |
|
209 | - $this->state = self::DOT_STATE; |
|
210 | - } else { |
|
211 | - $this->finalizeConverter($c); |
|
212 | - } |
|
213 | - break; |
|
214 | - case self::DOT_STATE: |
|
215 | - $this->currentLiteral .= $c; |
|
216 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
217 | - $this->formattingInfo->max = ord($c) - ord('0'); |
|
218 | - $this->state = self::MAX_STATE; |
|
219 | - } else { |
|
220 | - $this->state = self::LITERAL_STATE; |
|
221 | - } |
|
222 | - break; |
|
223 | - case self::MAX_STATE: |
|
224 | - $this->currentLiteral .= $c; |
|
225 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
226 | - $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
|
227 | - } else { |
|
228 | - $this->finalizeConverter($c); |
|
229 | - $this->state = self::LITERAL_STATE; |
|
230 | - } |
|
231 | - break; |
|
232 | - } // switch |
|
233 | - } // while |
|
234 | - if(strlen($this->currentLiteral) != 0) { |
|
235 | - $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
236 | - } |
|
237 | - return $this->head; |
|
238 | - } |
|
156 | + switch($this->state) { |
|
157 | + case self::LITERAL_STATE: |
|
158 | + // In literal state, the last char is always a literal. |
|
159 | + if($this->i == $this->patternLength) { |
|
160 | + $this->currentLiteral .= $c; |
|
161 | + continue; |
|
162 | + } |
|
163 | + if($c == self::ESCAPE_CHAR) { |
|
164 | + // peek at the next char. |
|
165 | + switch($this->pattern{$this->i}) { |
|
166 | + case self::ESCAPE_CHAR: |
|
167 | + $this->currentLiteral .= $c; |
|
168 | + $this->i++; // move pointer |
|
169 | + break; |
|
170 | + case 'n': |
|
171 | + $this->currentLiteral .= PHP_EOL; |
|
172 | + $this->i++; // move pointer |
|
173 | + break; |
|
174 | + default: |
|
175 | + if(strlen($this->currentLiteral) != 0) { |
|
176 | + $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
177 | + } |
|
178 | + $this->currentLiteral = $c; |
|
179 | + $this->state = self::CONVERTER_STATE; |
|
180 | + $this->formattingInfo->reset(); |
|
181 | + } |
|
182 | + } else { |
|
183 | + $this->currentLiteral .= $c; |
|
184 | + } |
|
185 | + break; |
|
186 | + case self::CONVERTER_STATE: |
|
187 | + $this->currentLiteral .= $c; |
|
188 | + switch($c) { |
|
189 | + case '-': |
|
190 | + $this->formattingInfo->leftAlign = true; |
|
191 | + break; |
|
192 | + case '.': |
|
193 | + $this->state = self::DOT_STATE; |
|
194 | + break; |
|
195 | + default: |
|
196 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
197 | + $this->formattingInfo->min = ord($c) - ord('0'); |
|
198 | + $this->state = self::MIN_STATE; |
|
199 | + } else { |
|
200 | + $this->finalizeConverter($c); |
|
201 | + } |
|
202 | + } // switch |
|
203 | + break; |
|
204 | + case self::MIN_STATE: |
|
205 | + $this->currentLiteral .= $c; |
|
206 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
207 | + $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0')); |
|
208 | + } else if ($c == '.') { |
|
209 | + $this->state = self::DOT_STATE; |
|
210 | + } else { |
|
211 | + $this->finalizeConverter($c); |
|
212 | + } |
|
213 | + break; |
|
214 | + case self::DOT_STATE: |
|
215 | + $this->currentLiteral .= $c; |
|
216 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
217 | + $this->formattingInfo->max = ord($c) - ord('0'); |
|
218 | + $this->state = self::MAX_STATE; |
|
219 | + } else { |
|
220 | + $this->state = self::LITERAL_STATE; |
|
221 | + } |
|
222 | + break; |
|
223 | + case self::MAX_STATE: |
|
224 | + $this->currentLiteral .= $c; |
|
225 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
226 | + $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
|
227 | + } else { |
|
228 | + $this->finalizeConverter($c); |
|
229 | + $this->state = self::LITERAL_STATE; |
|
230 | + } |
|
231 | + break; |
|
232 | + } // switch |
|
233 | + } // while |
|
234 | + if(strlen($this->currentLiteral) != 0) { |
|
235 | + $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
236 | + } |
|
237 | + return $this->head; |
|
238 | + } |
|
239 | 239 | |
240 | - public function finalizeConverter($c) { |
|
241 | - $pc = null; |
|
242 | - switch($c) { |
|
243 | - case 'c': |
|
244 | - $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
245 | - $this->currentLiteral = ''; |
|
246 | - break; |
|
247 | - case 'C': |
|
248 | - $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
249 | - $this->currentLiteral = ''; |
|
250 | - break; |
|
251 | - case 'd': |
|
252 | - $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
|
253 | - $dOpt = $this->extractOption(); |
|
240 | + public function finalizeConverter($c) { |
|
241 | + $pc = null; |
|
242 | + switch($c) { |
|
243 | + case 'c': |
|
244 | + $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
245 | + $this->currentLiteral = ''; |
|
246 | + break; |
|
247 | + case 'C': |
|
248 | + $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
249 | + $this->currentLiteral = ''; |
|
250 | + break; |
|
251 | + case 'd': |
|
252 | + $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
|
253 | + $dOpt = $this->extractOption(); |
|
254 | 254 | |
255 | - if($dOpt !== null) |
|
256 | - $dateFormatStr = $dOpt; |
|
255 | + if($dOpt !== null) |
|
256 | + $dateFormatStr = $dOpt; |
|
257 | 257 | |
258 | - if($dateFormatStr == 'ISO8601') { |
|
259 | - $df = self::DATE_FORMAT_ISO8601; |
|
260 | - } else if($dateFormatStr == 'ABSOLUTE') { |
|
261 | - $df = self::DATE_FORMAT_ABSOLUTE; |
|
262 | - } else if($dateFormatStr == 'DATE') { |
|
263 | - $df = self::DATE_FORMAT_DATE; |
|
264 | - } else { |
|
265 | - $df = $dateFormatStr; |
|
266 | - if($df == null) { |
|
267 | - $df = self::DATE_FORMAT_ISO8601; |
|
268 | - } |
|
269 | - } |
|
270 | - $pc = new LoggerDatePatternConverter($this->formattingInfo, $df); |
|
271 | - $this->currentLiteral = ''; |
|
272 | - break; |
|
273 | - case 'F': |
|
274 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER); |
|
275 | - $this->currentLiteral = ''; |
|
276 | - break; |
|
277 | - case 'l': |
|
278 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER); |
|
279 | - $this->currentLiteral = ''; |
|
280 | - break; |
|
281 | - case 'L': |
|
282 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER); |
|
283 | - $this->currentLiteral = ''; |
|
284 | - break; |
|
285 | - case 'm': |
|
286 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER); |
|
287 | - $this->currentLiteral = ''; |
|
288 | - break; |
|
289 | - case 'M': |
|
290 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER); |
|
291 | - $this->currentLiteral = ''; |
|
292 | - break; |
|
293 | - case 'p': |
|
294 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER); |
|
295 | - $this->currentLiteral = ''; |
|
296 | - break; |
|
297 | - case 'r': |
|
298 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER); |
|
299 | - $this->currentLiteral = ''; |
|
300 | - break; |
|
301 | - case 't': |
|
302 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER); |
|
303 | - $this->currentLiteral = ''; |
|
304 | - break; |
|
305 | - case 'u': |
|
306 | - if($this->i < $this->patternLength) { |
|
307 | - $cNext = $this->pattern{$this->i}; |
|
308 | - if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
309 | - $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
310 | - $this->currentLiteral = ''; |
|
311 | - $this->i++; |
|
312 | - } |
|
313 | - } |
|
314 | - break; |
|
315 | - case 'x': |
|
316 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER); |
|
317 | - $this->currentLiteral = ''; |
|
318 | - break; |
|
319 | - case 'X': |
|
320 | - $xOpt = $this->extractOption(); |
|
321 | - $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt); |
|
322 | - $this->currentLiteral = ''; |
|
323 | - break; |
|
324 | - default: |
|
325 | - $pc = new LoggerLiteralPatternConverter($this->currentLiteral); |
|
326 | - $this->currentLiteral = ''; |
|
327 | - } |
|
328 | - $this->addConverter($pc); |
|
329 | - } |
|
258 | + if($dateFormatStr == 'ISO8601') { |
|
259 | + $df = self::DATE_FORMAT_ISO8601; |
|
260 | + } else if($dateFormatStr == 'ABSOLUTE') { |
|
261 | + $df = self::DATE_FORMAT_ABSOLUTE; |
|
262 | + } else if($dateFormatStr == 'DATE') { |
|
263 | + $df = self::DATE_FORMAT_DATE; |
|
264 | + } else { |
|
265 | + $df = $dateFormatStr; |
|
266 | + if($df == null) { |
|
267 | + $df = self::DATE_FORMAT_ISO8601; |
|
268 | + } |
|
269 | + } |
|
270 | + $pc = new LoggerDatePatternConverter($this->formattingInfo, $df); |
|
271 | + $this->currentLiteral = ''; |
|
272 | + break; |
|
273 | + case 'F': |
|
274 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER); |
|
275 | + $this->currentLiteral = ''; |
|
276 | + break; |
|
277 | + case 'l': |
|
278 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER); |
|
279 | + $this->currentLiteral = ''; |
|
280 | + break; |
|
281 | + case 'L': |
|
282 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER); |
|
283 | + $this->currentLiteral = ''; |
|
284 | + break; |
|
285 | + case 'm': |
|
286 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER); |
|
287 | + $this->currentLiteral = ''; |
|
288 | + break; |
|
289 | + case 'M': |
|
290 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER); |
|
291 | + $this->currentLiteral = ''; |
|
292 | + break; |
|
293 | + case 'p': |
|
294 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER); |
|
295 | + $this->currentLiteral = ''; |
|
296 | + break; |
|
297 | + case 'r': |
|
298 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER); |
|
299 | + $this->currentLiteral = ''; |
|
300 | + break; |
|
301 | + case 't': |
|
302 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER); |
|
303 | + $this->currentLiteral = ''; |
|
304 | + break; |
|
305 | + case 'u': |
|
306 | + if($this->i < $this->patternLength) { |
|
307 | + $cNext = $this->pattern{$this->i}; |
|
308 | + if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
309 | + $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
310 | + $this->currentLiteral = ''; |
|
311 | + $this->i++; |
|
312 | + } |
|
313 | + } |
|
314 | + break; |
|
315 | + case 'x': |
|
316 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER); |
|
317 | + $this->currentLiteral = ''; |
|
318 | + break; |
|
319 | + case 'X': |
|
320 | + $xOpt = $this->extractOption(); |
|
321 | + $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt); |
|
322 | + $this->currentLiteral = ''; |
|
323 | + break; |
|
324 | + default: |
|
325 | + $pc = new LoggerLiteralPatternConverter($this->currentLiteral); |
|
326 | + $this->currentLiteral = ''; |
|
327 | + } |
|
328 | + $this->addConverter($pc); |
|
329 | + } |
|
330 | 330 | |
331 | - public function addConverter($pc) { |
|
332 | - $this->currentLiteral = ''; |
|
333 | - // Add the pattern converter to the list. |
|
334 | - $this->addToList($pc); |
|
335 | - // Next pattern is assumed to be a literal. |
|
336 | - $this->state = self::LITERAL_STATE; |
|
337 | - // Reset formatting info |
|
338 | - $this->formattingInfo->reset(); |
|
339 | - } |
|
331 | + public function addConverter($pc) { |
|
332 | + $this->currentLiteral = ''; |
|
333 | + // Add the pattern converter to the list. |
|
334 | + $this->addToList($pc); |
|
335 | + // Next pattern is assumed to be a literal. |
|
336 | + $this->state = self::LITERAL_STATE; |
|
337 | + // Reset formatting info |
|
338 | + $this->formattingInfo->reset(); |
|
339 | + } |
|
340 | 340 | } |
341 | 341 |
@@ -25,53 +25,53 @@ |
||
25 | 25 | */ |
26 | 26 | class LoggerNamedPatternConverter extends LoggerPatternConverter { |
27 | 27 | |
28 | - /** |
|
29 | - * @var integer |
|
30 | - */ |
|
31 | - private $precision; |
|
28 | + /** |
|
29 | + * @var integer |
|
30 | + */ |
|
31 | + private $precision; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor |
|
35 | - * |
|
36 | - * @param string $formattingInfo |
|
37 | - * @param integer $precision |
|
38 | - */ |
|
39 | - public function __construct($formattingInfo, $precision) { |
|
40 | - parent::__construct($formattingInfo); |
|
41 | - $this->precision = $precision; |
|
42 | - } |
|
33 | + /** |
|
34 | + * Constructor |
|
35 | + * |
|
36 | + * @param string $formattingInfo |
|
37 | + * @param integer $precision |
|
38 | + */ |
|
39 | + public function __construct($formattingInfo, $precision) { |
|
40 | + parent::__construct($formattingInfo); |
|
41 | + $this->precision = $precision; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param LoggerLoggingEvent $event |
|
46 | - * @return string |
|
47 | - * @abstract |
|
48 | - */ |
|
49 | - public function getFullyQualifiedName($event) { |
|
50 | - // abstract |
|
51 | - return; |
|
52 | - } |
|
44 | + /** |
|
45 | + * @param LoggerLoggingEvent $event |
|
46 | + * @return string |
|
47 | + * @abstract |
|
48 | + */ |
|
49 | + public function getFullyQualifiedName($event) { |
|
50 | + // abstract |
|
51 | + return; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param LoggerLoggingEvent $event |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - function convert($event) { |
|
59 | - $n = $this->getFullyQualifiedName($event); |
|
60 | - if($this->precision <= 0) { |
|
61 | - return $n; |
|
62 | - } else { |
|
63 | - $len = strlen($n); |
|
64 | - // We substract 1 from 'len' when assigning to 'end' to avoid out of |
|
65 | - // bounds exception in return r.substring(end+1, len). This can happen if |
|
66 | - // precision is 1 and the category name ends with a dot. |
|
67 | - $end = $len -1 ; |
|
68 | - for($i = $this->precision; $i > 0; $i--) { |
|
69 | - $end = strrpos(substr($n, 0, ($end - 1)), '.'); |
|
70 | - if($end == false) { |
|
71 | - return $n; |
|
72 | - } |
|
73 | - } |
|
74 | - return substr($n, ($end + 1), $len); |
|
75 | - } |
|
76 | - } |
|
54 | + /** |
|
55 | + * @param LoggerLoggingEvent $event |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + function convert($event) { |
|
59 | + $n = $this->getFullyQualifiedName($event); |
|
60 | + if($this->precision <= 0) { |
|
61 | + return $n; |
|
62 | + } else { |
|
63 | + $len = strlen($n); |
|
64 | + // We substract 1 from 'len' when assigning to 'end' to avoid out of |
|
65 | + // bounds exception in return r.substring(end+1, len). This can happen if |
|
66 | + // precision is 1 and the category name ends with a dot. |
|
67 | + $end = $len -1 ; |
|
68 | + for($i = $this->precision; $i > 0; $i--) { |
|
69 | + $end = strrpos(substr($n, 0, ($end - 1)), '.'); |
|
70 | + if($end == false) { |
|
71 | + return $n; |
|
72 | + } |
|
73 | + } |
|
74 | + return substr($n, ($end + 1), $len); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | - * contributor license agreements. See the NOTICE file distributed with |
|
5 | - * this work for additional information regarding copyright ownership. |
|
6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | - * (the "License"); you may not use this file except in compliance with |
|
8 | - * the License. You may obtain a copy of the License at |
|
9 | - * |
|
10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | - * |
|
12 | - * Unless required by applicable law or agreed to in writing, software |
|
13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | - * See the License for the specific language governing permissions and |
|
16 | - * limitations under the License. |
|
17 | - * |
|
18 | - * @package log4php |
|
19 | - */ |
|
3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | + * contributor license agreements. See the NOTICE file distributed with |
|
5 | + * this work for additional information regarding copyright ownership. |
|
6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | + * (the "License"); you may not use this file except in compliance with |
|
8 | + * the License. You may obtain a copy of the License at |
|
9 | + * |
|
10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + * |
|
12 | + * Unless required by applicable law or agreed to in writing, software |
|
13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + * See the License for the specific language governing permissions and |
|
16 | + * limitations under the License. |
|
17 | + * |
|
18 | + * @package log4php |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * The internal representation of caller location information. |
@@ -26,85 +26,85 @@ discard block |
||
26 | 26 | * @since 0.3 |
27 | 27 | */ |
28 | 28 | class LoggerLocationInfo { |
29 | - /** |
|
30 | - * When location information is not available the constant |
|
31 | - * <i>NA</i> is returned. Current value of this string |
|
32 | - * constant is <b>?</b>. |
|
33 | - */ |
|
34 | - const LOCATION_INFO_NA = 'NA'; |
|
29 | + /** |
|
30 | + * When location information is not available the constant |
|
31 | + * <i>NA</i> is returned. Current value of this string |
|
32 | + * constant is <b>?</b>. |
|
33 | + */ |
|
34 | + const LOCATION_INFO_NA = 'NA'; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var string Caller's line number. |
|
38 | - */ |
|
39 | - protected $lineNumber = null; |
|
36 | + /** |
|
37 | + * @var string Caller's line number. |
|
38 | + */ |
|
39 | + protected $lineNumber = null; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var string Caller's file name. |
|
43 | - */ |
|
44 | - protected $fileName = null; |
|
41 | + /** |
|
42 | + * @var string Caller's file name. |
|
43 | + */ |
|
44 | + protected $fileName = null; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var string Caller's fully qualified class name. |
|
48 | - */ |
|
49 | - protected $className = null; |
|
46 | + /** |
|
47 | + * @var string Caller's fully qualified class name. |
|
48 | + */ |
|
49 | + protected $className = null; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string Caller's method name. |
|
53 | - */ |
|
54 | - protected $methodName = null; |
|
51 | + /** |
|
52 | + * @var string Caller's method name. |
|
53 | + */ |
|
54 | + protected $methodName = null; |
|
55 | 55 | |
56 | - /** |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - protected $fullInfo = null; |
|
56 | + /** |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + protected $fullInfo = null; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}. |
|
63 | - * |
|
64 | - * @param array $trace |
|
65 | - * @param mixed $caller |
|
66 | - */ |
|
67 | - public function __construct($trace, $fqcn = null) { |
|
68 | - $this->lineNumber = isset($trace['line']) ? $trace['line'] : null; |
|
69 | - $this->fileName = isset($trace['file']) ? $trace['file'] : null; |
|
70 | - $this->className = isset($trace['class']) ? $trace['class'] : null; |
|
71 | - $this->methodName = isset($trace['function']) ? $trace['function'] : null; |
|
72 | - $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . |
|
73 | - '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')'; |
|
74 | - } |
|
61 | + /** |
|
62 | + * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}. |
|
63 | + * |
|
64 | + * @param array $trace |
|
65 | + * @param mixed $caller |
|
66 | + */ |
|
67 | + public function __construct($trace, $fqcn = null) { |
|
68 | + $this->lineNumber = isset($trace['line']) ? $trace['line'] : null; |
|
69 | + $this->fileName = isset($trace['file']) ? $trace['file'] : null; |
|
70 | + $this->className = isset($trace['class']) ? $trace['class'] : null; |
|
71 | + $this->methodName = isset($trace['function']) ? $trace['function'] : null; |
|
72 | + $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . |
|
73 | + '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')'; |
|
74 | + } |
|
75 | 75 | |
76 | - public function getClassName() { |
|
77 | - return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className; |
|
78 | - } |
|
76 | + public function getClassName() { |
|
77 | + return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Return the file name of the caller. |
|
82 | - * <p>This information is not always available. |
|
83 | - */ |
|
84 | - public function getFileName() { |
|
85 | - return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName; |
|
86 | - } |
|
80 | + /** |
|
81 | + * Return the file name of the caller. |
|
82 | + * <p>This information is not always available. |
|
83 | + */ |
|
84 | + public function getFileName() { |
|
85 | + return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Returns the line number of the caller. |
|
90 | - * <p>This information is not always available. |
|
91 | - */ |
|
92 | - public function getLineNumber() { |
|
93 | - return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber; |
|
94 | - } |
|
88 | + /** |
|
89 | + * Returns the line number of the caller. |
|
90 | + * <p>This information is not always available. |
|
91 | + */ |
|
92 | + public function getLineNumber() { |
|
93 | + return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Returns the method name of the caller. |
|
98 | - */ |
|
99 | - public function getMethodName() { |
|
100 | - return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName; |
|
101 | - } |
|
96 | + /** |
|
97 | + * Returns the method name of the caller. |
|
98 | + */ |
|
99 | + public function getMethodName() { |
|
100 | + return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Returns the full information of the caller. |
|
105 | - */ |
|
106 | - public function getFullInfo() { |
|
107 | - return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo; |
|
108 | - } |
|
103 | + /** |
|
104 | + * Returns the full information of the caller. |
|
105 | + */ |
|
106 | + public function getFullInfo() { |
|
107 | + return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | } |
@@ -43,14 +43,14 @@ |
||
43 | 43 | */ |
44 | 44 | class LoggerFilterDenyAll extends LoggerFilter { |
45 | 45 | |
46 | - /** |
|
47 | - * Always returns the integer constant {@link LoggerFilter::DENY} |
|
48 | - * regardless of the {@link LoggerLoggingEvent} parameter. |
|
49 | - * |
|
50 | - * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter. |
|
51 | - * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY} |
|
52 | - */ |
|
53 | - public function decide(LoggerLoggingEvent $event) { |
|
54 | - return LoggerFilter::DENY; |
|
55 | - } |
|
46 | + /** |
|
47 | + * Always returns the integer constant {@link LoggerFilter::DENY} |
|
48 | + * regardless of the {@link LoggerLoggingEvent} parameter. |
|
49 | + * |
|
50 | + * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter. |
|
51 | + * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY} |
|
52 | + */ |
|
53 | + public function decide(LoggerLoggingEvent $event) { |
|
54 | + return LoggerFilter::DENY; |
|
55 | + } |
|
56 | 56 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | - * contributor license agreements. See the NOTICE file distributed with |
|
5 | - * this work for additional information regarding copyright ownership. |
|
6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | - * (the "License"); you may not use this file except in compliance with |
|
8 | - * the License. You may obtain a copy of the License at |
|
9 | - * |
|
10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | - * |
|
12 | - * Unless required by applicable law or agreed to in writing, software |
|
13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | - * See the License for the specific language governing permissions and |
|
16 | - * limitations under the License. |
|
17 | - * |
|
18 | - * @package log4php |
|
19 | - */ |
|
3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | + * contributor license agreements. See the NOTICE file distributed with |
|
5 | + * this work for additional information regarding copyright ownership. |
|
6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | + * (the "License"); you may not use this file except in compliance with |
|
8 | + * the License. You may obtain a copy of the License at |
|
9 | + * |
|
10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + * |
|
12 | + * Unless required by applicable law or agreed to in writing, software |
|
13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + * See the License for the specific language governing permissions and |
|
16 | + * limitations under the License. |
|
17 | + * |
|
18 | + * @package log4php |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * This is a very simple filter based on level matching, which can be |
@@ -64,83 +64,83 @@ discard block |
||
64 | 64 | */ |
65 | 65 | class LoggerFilterLevelRange extends LoggerFilter { |
66 | 66 | |
67 | - /** |
|
68 | - * @var boolean |
|
69 | - */ |
|
70 | - private $acceptOnMatch = true; |
|
67 | + /** |
|
68 | + * @var boolean |
|
69 | + */ |
|
70 | + private $acceptOnMatch = true; |
|
71 | 71 | |
72 | - /** |
|
73 | - * @var LoggerLevel |
|
74 | - */ |
|
75 | - private $levelMin; |
|
72 | + /** |
|
73 | + * @var LoggerLevel |
|
74 | + */ |
|
75 | + private $levelMin; |
|
76 | 76 | |
77 | - /** |
|
78 | - * @var LoggerLevel |
|
79 | - */ |
|
80 | - private $levelMax; |
|
77 | + /** |
|
78 | + * @var LoggerLevel |
|
79 | + */ |
|
80 | + private $levelMax; |
|
81 | 81 | |
82 | - /** |
|
83 | - * @param boolean $acceptOnMatch |
|
84 | - */ |
|
85 | - public function setAcceptOnMatch($acceptOnMatch) { |
|
86 | - $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
87 | - } |
|
82 | + /** |
|
83 | + * @param boolean $acceptOnMatch |
|
84 | + */ |
|
85 | + public function setAcceptOnMatch($acceptOnMatch) { |
|
86 | + $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param string $l the level min to match |
|
91 | - */ |
|
92 | - public function setLevelMin($l) { |
|
93 | - if($l instanceof LoggerLevel) { |
|
94 | - $this->levelMin = $l; |
|
95 | - } else { |
|
96 | - $this->levelMin = LoggerOptionConverter::toLevel($l, null); |
|
97 | - } |
|
98 | - } |
|
89 | + /** |
|
90 | + * @param string $l the level min to match |
|
91 | + */ |
|
92 | + public function setLevelMin($l) { |
|
93 | + if($l instanceof LoggerLevel) { |
|
94 | + $this->levelMin = $l; |
|
95 | + } else { |
|
96 | + $this->levelMin = LoggerOptionConverter::toLevel($l, null); |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @param string $l the level max to match |
|
102 | - */ |
|
103 | - public function setLevelMax($l) { |
|
104 | - if($l instanceof LoggerLevel) { |
|
105 | - $this->levelMax = $l; |
|
106 | - } else { |
|
107 | - $this->levelMax = LoggerOptionConverter::toLevel($l, null); |
|
108 | - } |
|
109 | - } |
|
100 | + /** |
|
101 | + * @param string $l the level max to match |
|
102 | + */ |
|
103 | + public function setLevelMax($l) { |
|
104 | + if($l instanceof LoggerLevel) { |
|
105 | + $this->levelMax = $l; |
|
106 | + } else { |
|
107 | + $this->levelMax = LoggerOptionConverter::toLevel($l, null); |
|
108 | + } |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Return the decision of this filter. |
|
113 | - * |
|
114 | - * @param LoggerLoggingEvent $event |
|
115 | - * @return integer |
|
116 | - */ |
|
117 | - public function decide(LoggerLoggingEvent $event) { |
|
118 | - $level = $event->getLevel(); |
|
111 | + /** |
|
112 | + * Return the decision of this filter. |
|
113 | + * |
|
114 | + * @param LoggerLoggingEvent $event |
|
115 | + * @return integer |
|
116 | + */ |
|
117 | + public function decide(LoggerLoggingEvent $event) { |
|
118 | + $level = $event->getLevel(); |
|
119 | 119 | |
120 | - if($this->levelMin !== null) { |
|
121 | - if($level->isGreaterOrEqual($this->levelMin) == false) { |
|
122 | - // level of event is less than minimum |
|
123 | - return LoggerFilter::DENY; |
|
124 | - } |
|
125 | - } |
|
120 | + if($this->levelMin !== null) { |
|
121 | + if($level->isGreaterOrEqual($this->levelMin) == false) { |
|
122 | + // level of event is less than minimum |
|
123 | + return LoggerFilter::DENY; |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | - if($this->levelMax !== null) { |
|
128 | - if($level->toInt() > $this->levelMax->toInt()) { |
|
129 | - // level of event is greater than maximum |
|
130 | - // Alas, there is no Level.isGreater method. and using |
|
131 | - // a combo of isGreaterOrEqual && !Equal seems worse than |
|
132 | - // checking the int values of the level objects.. |
|
133 | - return LoggerFilter::DENY; |
|
134 | - } |
|
135 | - } |
|
127 | + if($this->levelMax !== null) { |
|
128 | + if($level->toInt() > $this->levelMax->toInt()) { |
|
129 | + // level of event is greater than maximum |
|
130 | + // Alas, there is no Level.isGreater method. and using |
|
131 | + // a combo of isGreaterOrEqual && !Equal seems worse than |
|
132 | + // checking the int values of the level objects.. |
|
133 | + return LoggerFilter::DENY; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - if($this->acceptOnMatch) { |
|
138 | - // this filter set up to bypass later filters and always return |
|
139 | - // accept if level in range |
|
140 | - return LoggerFilter::ACCEPT; |
|
141 | - } else { |
|
142 | - // event is ok for this filter; allow later filters to have a look.. |
|
143 | - return LoggerFilter::NEUTRAL; |
|
144 | - } |
|
145 | - } |
|
137 | + if($this->acceptOnMatch) { |
|
138 | + // this filter set up to bypass later filters and always return |
|
139 | + // accept if level in range |
|
140 | + return LoggerFilter::ACCEPT; |
|
141 | + } else { |
|
142 | + // event is ok for this filter; allow later filters to have a look.. |
|
143 | + return LoggerFilter::NEUTRAL; |
|
144 | + } |
|
145 | + } |
|
146 | 146 | } |