@@ -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 | } |
@@ -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 | } |
@@ -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 string matching. |
@@ -47,43 +47,43 @@ discard block |
||
47 | 47 | */ |
48 | 48 | class LoggerFilterStringMatch extends LoggerFilter { |
49 | 49 | |
50 | - /** |
|
51 | - * @var boolean |
|
52 | - */ |
|
53 | - private $acceptOnMatch = true; |
|
50 | + /** |
|
51 | + * @var boolean |
|
52 | + */ |
|
53 | + private $acceptOnMatch = true; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - private $stringToMatch = null; |
|
55 | + /** |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + private $stringToMatch = null; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false') |
|
62 | - */ |
|
63 | - public function setAcceptOnMatch($acceptOnMatch) { |
|
64 | - $this->acceptOnMatch = is_bool($acceptOnMatch) ? $acceptOnMatch : (bool)(strtolower($acceptOnMatch) == 'true'); |
|
65 | - } |
|
60 | + /** |
|
61 | + * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false') |
|
62 | + */ |
|
63 | + public function setAcceptOnMatch($acceptOnMatch) { |
|
64 | + $this->acceptOnMatch = is_bool($acceptOnMatch) ? $acceptOnMatch : (bool)(strtolower($acceptOnMatch) == 'true'); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @param string $s the string to match |
|
69 | - */ |
|
70 | - public function setStringToMatch($s) { |
|
71 | - $this->stringToMatch = $s; |
|
72 | - } |
|
67 | + /** |
|
68 | + * @param string $s the string to match |
|
69 | + */ |
|
70 | + public function setStringToMatch($s) { |
|
71 | + $this->stringToMatch = $s; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. |
|
76 | - */ |
|
77 | - public function decide(LoggerLoggingEvent $event) { |
|
78 | - $msg = $event->getRenderedMessage(); |
|
74 | + /** |
|
75 | + * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. |
|
76 | + */ |
|
77 | + public function decide(LoggerLoggingEvent $event) { |
|
78 | + $msg = $event->getRenderedMessage(); |
|
79 | 79 | |
80 | - if($msg === null or $this->stringToMatch === null) { |
|
81 | - return LoggerFilter::NEUTRAL; |
|
82 | - } |
|
80 | + if($msg === null or $this->stringToMatch === null) { |
|
81 | + return LoggerFilter::NEUTRAL; |
|
82 | + } |
|
83 | 83 | |
84 | - if(strpos($msg, $this->stringToMatch) !== false ) { |
|
85 | - return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY; |
|
86 | - } |
|
87 | - return LoggerFilter::NEUTRAL; |
|
88 | - } |
|
84 | + if(strpos($msg, $this->stringToMatch) !== false ) { |
|
85 | + return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY; |
|
86 | + } |
|
87 | + return LoggerFilter::NEUTRAL; |
|
88 | + } |
|
89 | 89 | } |
@@ -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. |
@@ -47,58 +47,58 @@ discard block |
||
47 | 47 | */ |
48 | 48 | class LoggerFilterLevelMatch extends LoggerFilter { |
49 | 49 | |
50 | - /** |
|
51 | - * Indicates if this event should be accepted or denied on match |
|
52 | - * @var boolean |
|
53 | - */ |
|
54 | - private $acceptOnMatch = true; |
|
50 | + /** |
|
51 | + * Indicates if this event should be accepted or denied on match |
|
52 | + * @var boolean |
|
53 | + */ |
|
54 | + private $acceptOnMatch = true; |
|
55 | 55 | |
56 | - /** |
|
57 | - * The level, when to match |
|
58 | - * @var LoggerLevel |
|
59 | - */ |
|
60 | - private $levelToMatch; |
|
56 | + /** |
|
57 | + * The level, when to match |
|
58 | + * @var LoggerLevel |
|
59 | + */ |
|
60 | + private $levelToMatch; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param boolean $acceptOnMatch |
|
64 | - */ |
|
65 | - public function setAcceptOnMatch($acceptOnMatch) { |
|
66 | - $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
67 | - } |
|
62 | + /** |
|
63 | + * @param boolean $acceptOnMatch |
|
64 | + */ |
|
65 | + public function setAcceptOnMatch($acceptOnMatch) { |
|
66 | + $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $l the level to match |
|
71 | - */ |
|
72 | - public function setLevelToMatch($l) { |
|
73 | - if($l instanceof LoggerLevel) { |
|
74 | - $this->levelToMatch = $l; |
|
75 | - } else { |
|
76 | - $this->levelToMatch = LoggerOptionConverter::toLevel($l, null); |
|
77 | - } |
|
78 | - } |
|
69 | + /** |
|
70 | + * @param string $l the level to match |
|
71 | + */ |
|
72 | + public function setLevelToMatch($l) { |
|
73 | + if($l instanceof LoggerLevel) { |
|
74 | + $this->levelToMatch = $l; |
|
75 | + } else { |
|
76 | + $this->levelToMatch = LoggerOptionConverter::toLevel($l, null); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Return the decision of this filter. |
|
82 | - * |
|
83 | - * Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b> |
|
84 | - * option is not set or if there is not match. Otherwise, if there is a |
|
85 | - * match, then the returned decision is {@link LoggerFilter::ACCEPT} if the |
|
86 | - * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The |
|
87 | - * returned decision is {@link LoggerFilter::DENY} if the |
|
88 | - * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>. |
|
89 | - * |
|
90 | - * @param LoggerLoggingEvent $event |
|
91 | - * @return integer |
|
92 | - */ |
|
93 | - public function decide(LoggerLoggingEvent $event) { |
|
94 | - if($this->levelToMatch === null) { |
|
95 | - return LoggerFilter::NEUTRAL; |
|
96 | - } |
|
80 | + /** |
|
81 | + * Return the decision of this filter. |
|
82 | + * |
|
83 | + * Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b> |
|
84 | + * option is not set or if there is not match. Otherwise, if there is a |
|
85 | + * match, then the returned decision is {@link LoggerFilter::ACCEPT} if the |
|
86 | + * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The |
|
87 | + * returned decision is {@link LoggerFilter::DENY} if the |
|
88 | + * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>. |
|
89 | + * |
|
90 | + * @param LoggerLoggingEvent $event |
|
91 | + * @return integer |
|
92 | + */ |
|
93 | + public function decide(LoggerLoggingEvent $event) { |
|
94 | + if($this->levelToMatch === null) { |
|
95 | + return LoggerFilter::NEUTRAL; |
|
96 | + } |
|
97 | 97 | |
98 | - if($this->levelToMatch->equals($event->getLevel())) { |
|
99 | - return $this->acceptOnMatch ? LoggerFilter::ACCEPT : LoggerFilter::DENY; |
|
100 | - } else { |
|
101 | - return LoggerFilter::NEUTRAL; |
|
102 | - } |
|
103 | - } |
|
98 | + if($this->levelToMatch->equals($event->getLevel())) { |
|
99 | + return $this->acceptOnMatch ? LoggerFilter::ACCEPT : LoggerFilter::DENY; |
|
100 | + } else { |
|
101 | + return LoggerFilter::NEUTRAL; |
|
102 | + } |
|
103 | + } |
|
104 | 104 | } |
@@ -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 class is specialized in retrieving loggers by name and also maintaining |
@@ -47,199 +47,199 @@ discard block |
||
47 | 47 | * @version $Revision: 822448 $ |
48 | 48 | * @package log4php |
49 | 49 | */ |
50 | - /* |
|
50 | + /* |
|
51 | 51 | * TODO: |
52 | 52 | * - addHierarchyEventListener($listener) not supported |
53 | 53 | * - emitNoAppenderWarning($cat) not supported |
54 | 54 | * - fireAddAppenderEvent not supported |
55 | 55 | */ |
56 | 56 | class LoggerHierarchy { |
57 | - /** Default Factory */ |
|
58 | - protected $defaultFactory; |
|
57 | + /** Default Factory */ |
|
58 | + protected $defaultFactory; |
|
59 | 59 | |
60 | - /** array hierarchy tree. saves here all loggers */ |
|
61 | - protected $ht = array(); |
|
60 | + /** array hierarchy tree. saves here all loggers */ |
|
61 | + protected $ht = array(); |
|
62 | 62 | |
63 | - /** The root Logger */ |
|
64 | - protected $root = null; |
|
63 | + /** The root Logger */ |
|
64 | + protected $root = null; |
|
65 | 65 | |
66 | - /** LoggerRendererMap */ |
|
67 | - protected $rendererMap; |
|
66 | + /** LoggerRendererMap */ |
|
67 | + protected $rendererMap; |
|
68 | 68 | |
69 | - /** LoggerLevel main level threshold */ |
|
70 | - protected $threshold; |
|
69 | + /** LoggerLevel main level threshold */ |
|
70 | + protected $threshold; |
|
71 | 71 | |
72 | - /** |
|
73 | - * Create a new logger hierarchy. |
|
74 | - * @param object $root the root logger |
|
75 | - */ |
|
76 | - public function __construct(LoggerRoot $root) { |
|
77 | - $this->root = $root; |
|
78 | - $this->setThreshold(LoggerLevel::getLevelAll()); |
|
79 | - $this->rendererMap = new LoggerRendererMap(); |
|
80 | - } |
|
72 | + /** |
|
73 | + * Create a new logger hierarchy. |
|
74 | + * @param object $root the root logger |
|
75 | + */ |
|
76 | + public function __construct(LoggerRoot $root) { |
|
77 | + $this->root = $root; |
|
78 | + $this->setThreshold(LoggerLevel::getLevelAll()); |
|
79 | + $this->rendererMap = new LoggerRendererMap(); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * This call will clear all logger definitions from the internal hashtable. |
|
84 | - */ |
|
85 | - public function clear() { |
|
86 | - $this->ht = array(); |
|
87 | - } |
|
82 | + /** |
|
83 | + * This call will clear all logger definitions from the internal hashtable. |
|
84 | + */ |
|
85 | + public function clear() { |
|
86 | + $this->ht = array(); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Check if the named logger exists in the hierarchy. |
|
91 | - * @param string $name |
|
92 | - * @return boolean |
|
93 | - */ |
|
94 | - public function exists($name) { |
|
95 | - return isset($this->ht[$name]); |
|
96 | - } |
|
89 | + /** |
|
90 | + * Check if the named logger exists in the hierarchy. |
|
91 | + * @param string $name |
|
92 | + * @return boolean |
|
93 | + */ |
|
94 | + public function exists($name) { |
|
95 | + return isset($this->ht[$name]); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Returns all the currently defined categories in this hierarchy as an array. |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function getCurrentLoggers() { |
|
103 | - return array_values($this->ht); |
|
104 | - } |
|
98 | + /** |
|
99 | + * Returns all the currently defined categories in this hierarchy as an array. |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function getCurrentLoggers() { |
|
103 | + return array_values($this->ht); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Return a new logger instance named as the first parameter using the default factory. |
|
108 | - * |
|
109 | - * @param string $name logger name |
|
110 | - * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
111 | - * @return Logger |
|
112 | - */ |
|
113 | - public function getLogger($name) { |
|
114 | - if(!isset($this->ht[$name])) { |
|
115 | - $this->ht[$name] = new Logger($name);; |
|
116 | - // TODO: isn't necessary, access via singleton? |
|
117 | - // $this->ht[$name]->setHierarchy($this); |
|
118 | - $nodes = explode('.', $name); |
|
119 | - $firstNode = array_shift($nodes); |
|
106 | + /** |
|
107 | + * Return a new logger instance named as the first parameter using the default factory. |
|
108 | + * |
|
109 | + * @param string $name logger name |
|
110 | + * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
111 | + * @return Logger |
|
112 | + */ |
|
113 | + public function getLogger($name) { |
|
114 | + if(!isset($this->ht[$name])) { |
|
115 | + $this->ht[$name] = new Logger($name);; |
|
116 | + // TODO: isn't necessary, access via singleton? |
|
117 | + // $this->ht[$name]->setHierarchy($this); |
|
118 | + $nodes = explode('.', $name); |
|
119 | + $firstNode = array_shift($nodes); |
|
120 | 120 | |
121 | - // if name is not a first node but another first node is their |
|
122 | - if($firstNode != $name and isset($this->ht[$firstNode])) { |
|
123 | - $this->ht[$name]->setParent($this->ht[$firstNode]); |
|
124 | - } else { |
|
125 | - // if there is no father, set root logger as father |
|
126 | - $this->ht[$name]->setParent($this->root); |
|
127 | - } |
|
121 | + // if name is not a first node but another first node is their |
|
122 | + if($firstNode != $name and isset($this->ht[$firstNode])) { |
|
123 | + $this->ht[$name]->setParent($this->ht[$firstNode]); |
|
124 | + } else { |
|
125 | + // if there is no father, set root logger as father |
|
126 | + $this->ht[$name]->setParent($this->root); |
|
127 | + } |
|
128 | 128 | |
129 | - // if there are more nodes than one |
|
130 | - if(count($nodes) > 0) { |
|
131 | - // find parent node |
|
132 | - foreach($nodes as $node) { |
|
133 | - $parentNode = "$firstNode.$node"; |
|
134 | - if(isset($this->ht[$parentNode]) and $parentNode != $name) { |
|
129 | + // if there are more nodes than one |
|
130 | + if(count($nodes) > 0) { |
|
131 | + // find parent node |
|
132 | + foreach($nodes as $node) { |
|
133 | + $parentNode = "$firstNode.$node"; |
|
134 | + if(isset($this->ht[$parentNode]) and $parentNode != $name) { |
|
135 | 135 | |
136 | - $this->ht[$name]->setParent($this->ht[$parentNode]); |
|
137 | - } |
|
138 | - $firstNode .= ".$node"; |
|
139 | - } |
|
140 | - } |
|
141 | - } |
|
136 | + $this->ht[$name]->setParent($this->ht[$parentNode]); |
|
137 | + } |
|
138 | + $firstNode .= ".$node"; |
|
139 | + } |
|
140 | + } |
|
141 | + } |
|
142 | 142 | |
143 | - return $this->ht[$name]; |
|
144 | - } |
|
143 | + return $this->ht[$name]; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @return LoggerRendererMap Get the renderer map for this hierarchy. |
|
148 | - */ |
|
149 | - public function getRendererMap() { |
|
150 | - return $this->rendererMap; |
|
151 | - } |
|
146 | + /** |
|
147 | + * @return LoggerRendererMap Get the renderer map for this hierarchy. |
|
148 | + */ |
|
149 | + public function getRendererMap() { |
|
150 | + return $this->rendererMap; |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * @return LoggerRoot Get the root of this hierarchy. |
|
155 | - */ |
|
156 | - public function getRootLogger() { |
|
157 | - if(!isset($this->root) or $this->root == null) { |
|
158 | - $this->root = new LoggerRoot(); |
|
159 | - } |
|
160 | - return $this->root; |
|
161 | - } |
|
153 | + /** |
|
154 | + * @return LoggerRoot Get the root of this hierarchy. |
|
155 | + */ |
|
156 | + public function getRootLogger() { |
|
157 | + if(!isset($this->root) or $this->root == null) { |
|
158 | + $this->root = new LoggerRoot(); |
|
159 | + } |
|
160 | + return $this->root; |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * @return LoggerLevel Returns the threshold Level. |
|
165 | - */ |
|
166 | - public function getThreshold() { |
|
167 | - return $this->threshold; |
|
168 | - } |
|
163 | + /** |
|
164 | + * @return LoggerLevel Returns the threshold Level. |
|
165 | + */ |
|
166 | + public function getThreshold() { |
|
167 | + return $this->threshold; |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * This method will return true if this repository is disabled |
|
172 | - * for level object passed as parameter and false otherwise. |
|
173 | - * @return boolean |
|
174 | - */ |
|
175 | - public function isDisabled(LoggerLevel $level) { |
|
176 | - return ($this->threshold->toInt() > $level->toInt()); |
|
177 | - } |
|
170 | + /** |
|
171 | + * This method will return true if this repository is disabled |
|
172 | + * for level object passed as parameter and false otherwise. |
|
173 | + * @return boolean |
|
174 | + */ |
|
175 | + public function isDisabled(LoggerLevel $level) { |
|
176 | + return ($this->threshold->toInt() > $level->toInt()); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Reset all values contained in this hierarchy instance to their |
|
181 | - * default. |
|
182 | - * |
|
183 | - * This removes all appenders from all categories, sets |
|
184 | - * the level of all non-root categories to <i>null</i>, |
|
185 | - * sets their additivity flag to <i>true</i> and sets the level |
|
186 | - * of the root logger to {@link LOGGER_LEVEL_DEBUG}. Moreover, |
|
187 | - * message disabling is set its default "off" value. |
|
188 | - * |
|
189 | - * <p>Existing categories are not removed. They are just reset. |
|
190 | - * |
|
191 | - * <p>This method should be used sparingly and with care as it will |
|
192 | - * block all logging until it is completed.</p> |
|
193 | - */ |
|
194 | - public function resetConfiguration() { |
|
195 | - $root = $this->getRootLogger(); |
|
179 | + /** |
|
180 | + * Reset all values contained in this hierarchy instance to their |
|
181 | + * default. |
|
182 | + * |
|
183 | + * This removes all appenders from all categories, sets |
|
184 | + * the level of all non-root categories to <i>null</i>, |
|
185 | + * sets their additivity flag to <i>true</i> and sets the level |
|
186 | + * of the root logger to {@link LOGGER_LEVEL_DEBUG}. Moreover, |
|
187 | + * message disabling is set its default "off" value. |
|
188 | + * |
|
189 | + * <p>Existing categories are not removed. They are just reset. |
|
190 | + * |
|
191 | + * <p>This method should be used sparingly and with care as it will |
|
192 | + * block all logging until it is completed.</p> |
|
193 | + */ |
|
194 | + public function resetConfiguration() { |
|
195 | + $root = $this->getRootLogger(); |
|
196 | 196 | |
197 | - $root->setLevel(LoggerLevel::getLevelDebug()); |
|
198 | - $this->setThreshold(LoggerLevel::getLevelAll()); |
|
199 | - $this->shutDown(); |
|
200 | - $loggers = $this->getCurrentLoggers(); |
|
201 | - $enumLoggers = count($loggers); |
|
202 | - for($i = 0; $i < $enumLoggers; $i++) { |
|
203 | - $loggers[$i]->setLevel(null); |
|
204 | - $loggers[$i]->setAdditivity(true); |
|
205 | - $loggers[$i]->removeAllAppenders(); |
|
206 | - } |
|
207 | - $this->rendererMap->clear(); |
|
208 | - } |
|
197 | + $root->setLevel(LoggerLevel::getLevelDebug()); |
|
198 | + $this->setThreshold(LoggerLevel::getLevelAll()); |
|
199 | + $this->shutDown(); |
|
200 | + $loggers = $this->getCurrentLoggers(); |
|
201 | + $enumLoggers = count($loggers); |
|
202 | + for($i = 0; $i < $enumLoggers; $i++) { |
|
203 | + $loggers[$i]->setLevel(null); |
|
204 | + $loggers[$i]->setAdditivity(true); |
|
205 | + $loggers[$i]->removeAllAppenders(); |
|
206 | + } |
|
207 | + $this->rendererMap->clear(); |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * set a new threshold level |
|
212 | - * |
|
213 | - * @param LoggerLevel $l |
|
214 | - */ |
|
215 | - public function setThreshold(LoggerLevel $l) { |
|
216 | - if($l !== null) { |
|
217 | - $this->threshold = $l; |
|
218 | - } |
|
219 | - } |
|
210 | + /** |
|
211 | + * set a new threshold level |
|
212 | + * |
|
213 | + * @param LoggerLevel $l |
|
214 | + */ |
|
215 | + public function setThreshold(LoggerLevel $l) { |
|
216 | + if($l !== null) { |
|
217 | + $this->threshold = $l; |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Shutting down a hierarchy will <i>safely</i> close and remove |
|
223 | - * all appenders in all categories including the root logger. |
|
224 | - * |
|
225 | - * <p>Some appenders such as {@link LoggerSocketAppender} |
|
226 | - * need to be closed before the |
|
227 | - * application exists. Otherwise, pending logging events might be |
|
228 | - * lost. |
|
229 | - * |
|
230 | - * <p>The shutdown method is careful to close nested |
|
231 | - * appenders before closing regular appenders. This is allows |
|
232 | - * configurations where a regular appender is attached to a logger |
|
233 | - * and again to a nested appender. |
|
234 | - */ |
|
235 | - public function shutdown() { |
|
236 | - $this->root->removeAllAppenders(); |
|
237 | - $cats = $this->getCurrentLoggers(); |
|
238 | - $enumCats = count($cats); |
|
239 | - if($enumCats > 0) { |
|
240 | - for($i = 0; $i < $enumCats; $i++) { |
|
241 | - $cats[$i]->removeAllAppenders(); |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
221 | + /** |
|
222 | + * Shutting down a hierarchy will <i>safely</i> close and remove |
|
223 | + * all appenders in all categories including the root logger. |
|
224 | + * |
|
225 | + * <p>Some appenders such as {@link LoggerSocketAppender} |
|
226 | + * need to be closed before the |
|
227 | + * application exists. Otherwise, pending logging events might be |
|
228 | + * lost. |
|
229 | + * |
|
230 | + * <p>The shutdown method is careful to close nested |
|
231 | + * appenders before closing regular appenders. This is allows |
|
232 | + * configurations where a regular appender is attached to a logger |
|
233 | + * and again to a nested appender. |
|
234 | + */ |
|
235 | + public function shutdown() { |
|
236 | + $this->root->removeAllAppenders(); |
|
237 | + $cats = $this->getCurrentLoggers(); |
|
238 | + $enumCats = count($cats); |
|
239 | + if($enumCats > 0) { |
|
240 | + for($i = 0; $i < $enumCats; $i++) { |
|
241 | + $cats[$i]->removeAllAppenders(); |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | 245 | } |
@@ -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 | * LoggerConfiguratorPhp class |
@@ -38,97 +38,97 @@ discard block |
||
38 | 38 | */ |
39 | 39 | class LoggerConfiguratorPhp implements LoggerConfigurator { |
40 | 40 | |
41 | - public function configure(LoggerHierarchy $hierarchy, $url = '') { |
|
42 | - return $this->doConfigure($url, $hierarchy); |
|
43 | - } |
|
41 | + public function configure(LoggerHierarchy $hierarchy, $url = '') { |
|
42 | + return $this->doConfigure($url, $hierarchy); |
|
43 | + } |
|
44 | 44 | |
45 | - private function doConfigure($url, LoggerHierarchy $hierarchy) { |
|
45 | + private function doConfigure($url, LoggerHierarchy $hierarchy) { |
|
46 | 46 | |
47 | - $config = require $url; |
|
47 | + $config = require $url; |
|
48 | 48 | |
49 | - // set threshold |
|
50 | - if(isset($config['threshold'])) { |
|
51 | - $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll())); |
|
52 | - } |
|
49 | + // set threshold |
|
50 | + if(isset($config['threshold'])) { |
|
51 | + $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll())); |
|
52 | + } |
|
53 | 53 | |
54 | - // parse and create appenders |
|
55 | - if(isset($config['appenders'])) { |
|
54 | + // parse and create appenders |
|
55 | + if(isset($config['appenders'])) { |
|
56 | 56 | |
57 | - foreach($config['appenders'] as $appenderName => $appenderProperties) { |
|
57 | + foreach($config['appenders'] as $appenderName => $appenderProperties) { |
|
58 | 58 | |
59 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']); |
|
59 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']); |
|
60 | 60 | |
61 | - if($appender->requiresLayout()) { |
|
61 | + if($appender->requiresLayout()) { |
|
62 | 62 | |
63 | - if(isset($appenderProperties['layout'])) { |
|
63 | + if(isset($appenderProperties['layout'])) { |
|
64 | 64 | |
65 | - if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) { |
|
66 | - $layoutClass = $appenderProperties['layout']['class']; |
|
67 | - } else { |
|
68 | - $layoutClass = 'LoggerLayoutSimple'; |
|
69 | - } |
|
65 | + if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) { |
|
66 | + $layoutClass = $appenderProperties['layout']['class']; |
|
67 | + } else { |
|
68 | + $layoutClass = 'LoggerLayoutSimple'; |
|
69 | + } |
|
70 | 70 | |
71 | - $layout = LoggerReflectionUtils::createObject($layoutClass); |
|
72 | - if($layout === null) { |
|
73 | - $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
74 | - } |
|
71 | + $layout = LoggerReflectionUtils::createObject($layoutClass); |
|
72 | + if($layout === null) { |
|
73 | + $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
74 | + } |
|
75 | 75 | |
76 | - if($layout instanceof LoggerLayoutPattern) { |
|
77 | - $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']); |
|
78 | - } |
|
76 | + if($layout instanceof LoggerLayoutPattern) { |
|
77 | + $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']); |
|
78 | + } |
|
79 | 79 | |
80 | - $appender->setLayout($layout); |
|
80 | + $appender->setLayout($layout); |
|
81 | 81 | |
82 | - } else { |
|
83 | - // TODO: throw exception? |
|
84 | - } |
|
82 | + } else { |
|
83 | + // TODO: throw exception? |
|
84 | + } |
|
85 | 85 | |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - // parse and create root logger |
|
93 | - if(isset($config['rootLogger'])) { |
|
94 | - $rootLogger = $hierarchy->getRootLogger(); |
|
95 | - if(isset($config['rootLogger']['level'])) { |
|
96 | - $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug())); |
|
97 | - if(isset($config['rootLogger']['appenders'])) { |
|
98 | - foreach($config['rootLogger']['appenders'] as $appenderName) { |
|
99 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
100 | - if($appender !== null) { |
|
101 | - $rootLogger->addAppender($appender); |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - } |
|
92 | + // parse and create root logger |
|
93 | + if(isset($config['rootLogger'])) { |
|
94 | + $rootLogger = $hierarchy->getRootLogger(); |
|
95 | + if(isset($config['rootLogger']['level'])) { |
|
96 | + $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug())); |
|
97 | + if(isset($config['rootLogger']['appenders'])) { |
|
98 | + foreach($config['rootLogger']['appenders'] as $appenderName) { |
|
99 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
100 | + if($appender !== null) { |
|
101 | + $rootLogger->addAppender($appender); |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - // parse and create loggers |
|
109 | - if(isset($config['loggers'])) { |
|
110 | - foreach($config['loggers'] as $loggerName => $loggerProperties) { |
|
111 | - if(is_string($loggerName)) { |
|
112 | - $logger = $hierarchy->getLogger($loggerName); |
|
108 | + // parse and create loggers |
|
109 | + if(isset($config['loggers'])) { |
|
110 | + foreach($config['loggers'] as $loggerName => $loggerProperties) { |
|
111 | + if(is_string($loggerName)) { |
|
112 | + $logger = $hierarchy->getLogger($loggerName); |
|
113 | 113 | |
114 | - if(isset($loggerProperties['level'])) { |
|
115 | - $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug())); |
|
116 | - if(isset($loggerProperties['appenders'])) { |
|
117 | - foreach($loggerProperties['appenders'] as $appenderName) { |
|
118 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
119 | - if($appender !== null) { |
|
120 | - $logger->addAppender($appender); |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - } |
|
125 | - } else { |
|
126 | - // TODO: throw exception |
|
127 | - } |
|
128 | - } |
|
129 | - } |
|
114 | + if(isset($loggerProperties['level'])) { |
|
115 | + $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug())); |
|
116 | + if(isset($loggerProperties['appenders'])) { |
|
117 | + foreach($loggerProperties['appenders'] as $appenderName) { |
|
118 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
119 | + if($appender !== null) { |
|
120 | + $logger->addAppender($appender); |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + } |
|
125 | + } else { |
|
126 | + // TODO: throw exception |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - return true; |
|
132 | - } |
|
131 | + return true; |
|
132 | + } |
|
133 | 133 | |
134 | 134 | } |
@@ -33,224 +33,224 @@ |
||
33 | 33 | */ |
34 | 34 | class LoggerLevel { |
35 | 35 | |
36 | - const OFF = 2147483647; |
|
37 | - const FATAL = 50000; |
|
38 | - const ERROR = 40000; |
|
39 | - const WARN = 30000; |
|
40 | - const INFO = 20000; |
|
41 | - const DEBUG = 10000; |
|
42 | - const ALL = -2147483647; |
|
36 | + const OFF = 2147483647; |
|
37 | + const FATAL = 50000; |
|
38 | + const ERROR = 40000; |
|
39 | + const WARN = 30000; |
|
40 | + const INFO = 20000; |
|
41 | + const DEBUG = 10000; |
|
42 | + const ALL = -2147483647; |
|
43 | 43 | |
44 | - /** |
|
45 | - * TODO: check if still necessary or to be refactored |
|
46 | - * @var integer |
|
47 | - */ |
|
48 | - private $level; |
|
44 | + /** |
|
45 | + * TODO: check if still necessary or to be refactored |
|
46 | + * @var integer |
|
47 | + */ |
|
48 | + private $level; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Contains a list of instantiated levels |
|
52 | - */ |
|
53 | - private static $levelMap; |
|
50 | + /** |
|
51 | + * Contains a list of instantiated levels |
|
52 | + */ |
|
53 | + private static $levelMap; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - private $levelStr; |
|
55 | + /** |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + private $levelStr; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var integer |
|
62 | - */ |
|
63 | - private $syslogEquivalent; |
|
60 | + /** |
|
61 | + * @var integer |
|
62 | + */ |
|
63 | + private $syslogEquivalent; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Constructor |
|
67 | - * |
|
68 | - * @param integer $level |
|
69 | - * @param string $levelStr |
|
70 | - * @param integer $syslogEquivalent |
|
71 | - */ |
|
72 | - private function __construct($level, $levelStr, $syslogEquivalent) { |
|
73 | - $this->level = $level; |
|
74 | - $this->levelStr = $levelStr; |
|
75 | - $this->syslogEquivalent = $syslogEquivalent; |
|
76 | - } |
|
65 | + /** |
|
66 | + * Constructor |
|
67 | + * |
|
68 | + * @param integer $level |
|
69 | + * @param string $levelStr |
|
70 | + * @param integer $syslogEquivalent |
|
71 | + */ |
|
72 | + private function __construct($level, $levelStr, $syslogEquivalent) { |
|
73 | + $this->level = $level; |
|
74 | + $this->levelStr = $levelStr; |
|
75 | + $this->syslogEquivalent = $syslogEquivalent; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Two priorities are equal if their level fields are equal. |
|
80 | - * |
|
81 | - * @param object $o |
|
82 | - * @return boolean |
|
83 | - */ |
|
84 | - public function equals($o) { |
|
85 | - if($o instanceof LoggerLevel) { |
|
86 | - if($this->level == $o->level) { |
|
87 | - return true; |
|
88 | - } |
|
89 | - } else { |
|
90 | - return false; |
|
91 | - } |
|
92 | - } |
|
78 | + /** |
|
79 | + * Two priorities are equal if their level fields are equal. |
|
80 | + * |
|
81 | + * @param object $o |
|
82 | + * @return boolean |
|
83 | + */ |
|
84 | + public function equals($o) { |
|
85 | + if($o instanceof LoggerLevel) { |
|
86 | + if($this->level == $o->level) { |
|
87 | + return true; |
|
88 | + } |
|
89 | + } else { |
|
90 | + return false; |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Returns an Off Level |
|
96 | - * @static |
|
97 | - * @return LoggerLevel |
|
98 | - */ |
|
99 | - public static function getLevelOff() { |
|
100 | - if(!isset(self::$levelMap[LoggerLevel::OFF])) { |
|
101 | - self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0); |
|
102 | - } |
|
103 | - return self::$levelMap[LoggerLevel::OFF]; |
|
104 | - } |
|
94 | + /** |
|
95 | + * Returns an Off Level |
|
96 | + * @static |
|
97 | + * @return LoggerLevel |
|
98 | + */ |
|
99 | + public static function getLevelOff() { |
|
100 | + if(!isset(self::$levelMap[LoggerLevel::OFF])) { |
|
101 | + self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0); |
|
102 | + } |
|
103 | + return self::$levelMap[LoggerLevel::OFF]; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Returns a Fatal Level |
|
108 | - * @static |
|
109 | - * @return LoggerLevel |
|
110 | - */ |
|
111 | - public static function getLevelFatal() { |
|
112 | - if(!isset(self::$levelMap[LoggerLevel::FATAL])) { |
|
113 | - self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0); |
|
114 | - } |
|
115 | - return self::$levelMap[LoggerLevel::FATAL]; |
|
116 | - } |
|
106 | + /** |
|
107 | + * Returns a Fatal Level |
|
108 | + * @static |
|
109 | + * @return LoggerLevel |
|
110 | + */ |
|
111 | + public static function getLevelFatal() { |
|
112 | + if(!isset(self::$levelMap[LoggerLevel::FATAL])) { |
|
113 | + self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0); |
|
114 | + } |
|
115 | + return self::$levelMap[LoggerLevel::FATAL]; |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Returns an Error Level |
|
120 | - * @static |
|
121 | - * @return LoggerLevel |
|
122 | - */ |
|
123 | - public static function getLevelError() { |
|
124 | - if(!isset(self::$levelMap[LoggerLevel::ERROR])) { |
|
125 | - self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3); |
|
126 | - } |
|
127 | - return self::$levelMap[LoggerLevel::ERROR]; |
|
128 | - } |
|
118 | + /** |
|
119 | + * Returns an Error Level |
|
120 | + * @static |
|
121 | + * @return LoggerLevel |
|
122 | + */ |
|
123 | + public static function getLevelError() { |
|
124 | + if(!isset(self::$levelMap[LoggerLevel::ERROR])) { |
|
125 | + self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3); |
|
126 | + } |
|
127 | + return self::$levelMap[LoggerLevel::ERROR]; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Returns a Warn Level |
|
132 | - * @static |
|
133 | - * @return LoggerLevel |
|
134 | - */ |
|
135 | - public static function getLevelWarn() { |
|
136 | - if(!isset(self::$levelMap[LoggerLevel::WARN])) { |
|
137 | - self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4); |
|
138 | - } |
|
139 | - return self::$levelMap[LoggerLevel::WARN]; |
|
140 | - } |
|
130 | + /** |
|
131 | + * Returns a Warn Level |
|
132 | + * @static |
|
133 | + * @return LoggerLevel |
|
134 | + */ |
|
135 | + public static function getLevelWarn() { |
|
136 | + if(!isset(self::$levelMap[LoggerLevel::WARN])) { |
|
137 | + self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4); |
|
138 | + } |
|
139 | + return self::$levelMap[LoggerLevel::WARN]; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * Returns an Info Level |
|
144 | - * @static |
|
145 | - * @return LoggerLevel |
|
146 | - */ |
|
147 | - public static function getLevelInfo() { |
|
148 | - if(!isset(self::$levelMap[LoggerLevel::INFO])) { |
|
149 | - self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6); |
|
150 | - } |
|
151 | - return self::$levelMap[LoggerLevel::INFO]; |
|
152 | - } |
|
142 | + /** |
|
143 | + * Returns an Info Level |
|
144 | + * @static |
|
145 | + * @return LoggerLevel |
|
146 | + */ |
|
147 | + public static function getLevelInfo() { |
|
148 | + if(!isset(self::$levelMap[LoggerLevel::INFO])) { |
|
149 | + self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6); |
|
150 | + } |
|
151 | + return self::$levelMap[LoggerLevel::INFO]; |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Returns a Debug Level |
|
156 | - * @static |
|
157 | - * @return LoggerLevel |
|
158 | - */ |
|
159 | - public static function getLevelDebug() { |
|
160 | - if(!isset(self::$levelMap[LoggerLevel::DEBUG])) { |
|
161 | - self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7); |
|
162 | - } |
|
163 | - return self::$levelMap[LoggerLevel::DEBUG]; |
|
164 | - } |
|
154 | + /** |
|
155 | + * Returns a Debug Level |
|
156 | + * @static |
|
157 | + * @return LoggerLevel |
|
158 | + */ |
|
159 | + public static function getLevelDebug() { |
|
160 | + if(!isset(self::$levelMap[LoggerLevel::DEBUG])) { |
|
161 | + self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7); |
|
162 | + } |
|
163 | + return self::$levelMap[LoggerLevel::DEBUG]; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * Returns an All Level |
|
168 | - * @static |
|
169 | - * @return LoggerLevel |
|
170 | - */ |
|
171 | - public static function getLevelAll() { |
|
172 | - if(!isset(self::$levelMap[LoggerLevel::ALL])) { |
|
173 | - self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7); |
|
174 | - } |
|
175 | - return self::$levelMap[LoggerLevel::ALL]; |
|
176 | - } |
|
166 | + /** |
|
167 | + * Returns an All Level |
|
168 | + * @static |
|
169 | + * @return LoggerLevel |
|
170 | + */ |
|
171 | + public static function getLevelAll() { |
|
172 | + if(!isset(self::$levelMap[LoggerLevel::ALL])) { |
|
173 | + self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7); |
|
174 | + } |
|
175 | + return self::$levelMap[LoggerLevel::ALL]; |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Return the syslog equivalent of this priority as an integer. |
|
180 | - * @final |
|
181 | - * @return integer |
|
182 | - */ |
|
183 | - public function getSyslogEquivalent() { |
|
184 | - return $this->syslogEquivalent; |
|
185 | - } |
|
178 | + /** |
|
179 | + * Return the syslog equivalent of this priority as an integer. |
|
180 | + * @final |
|
181 | + * @return integer |
|
182 | + */ |
|
183 | + public function getSyslogEquivalent() { |
|
184 | + return $this->syslogEquivalent; |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * Returns <i>true</i> if this level has a higher or equal |
|
189 | - * level than the level passed as argument, <i>false</i> |
|
190 | - * otherwise. |
|
191 | - * |
|
192 | - * <p>You should think twice before overriding the default |
|
193 | - * implementation of <i>isGreaterOrEqual</i> method. |
|
194 | - * |
|
195 | - * @param LoggerLevel $r |
|
196 | - * @return boolean |
|
197 | - */ |
|
198 | - public function isGreaterOrEqual($r) { |
|
199 | - return $this->level >= $r->level; |
|
200 | - } |
|
187 | + /** |
|
188 | + * Returns <i>true</i> if this level has a higher or equal |
|
189 | + * level than the level passed as argument, <i>false</i> |
|
190 | + * otherwise. |
|
191 | + * |
|
192 | + * <p>You should think twice before overriding the default |
|
193 | + * implementation of <i>isGreaterOrEqual</i> method. |
|
194 | + * |
|
195 | + * @param LoggerLevel $r |
|
196 | + * @return boolean |
|
197 | + */ |
|
198 | + public function isGreaterOrEqual($r) { |
|
199 | + return $this->level >= $r->level; |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * Returns the string representation of this priority. |
|
204 | - * @return string |
|
205 | - * @final |
|
206 | - */ |
|
207 | - public function toString() { |
|
208 | - return $this->levelStr; |
|
209 | - } |
|
202 | + /** |
|
203 | + * Returns the string representation of this priority. |
|
204 | + * @return string |
|
205 | + * @final |
|
206 | + */ |
|
207 | + public function toString() { |
|
208 | + return $this->levelStr; |
|
209 | + } |
|
210 | 210 | |
211 | - /** |
|
212 | - * Returns the integer representation of this level. |
|
213 | - * @return integer |
|
214 | - */ |
|
215 | - public function toInt() { |
|
216 | - return $this->level; |
|
217 | - } |
|
211 | + /** |
|
212 | + * Returns the integer representation of this level. |
|
213 | + * @return integer |
|
214 | + */ |
|
215 | + public function toInt() { |
|
216 | + return $this->level; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * Convert the string passed as argument to a level. If the |
|
221 | - * conversion fails, then this method returns a DEBUG Level. |
|
222 | - * |
|
223 | - * @param mixed $arg |
|
224 | - * @param LoggerLevel $default |
|
225 | - * @static |
|
226 | - */ |
|
227 | - public static function toLevel($arg, $defaultLevel = null) { |
|
228 | - if($defaultLevel === null) { |
|
229 | - return self::toLevel($arg, self::getLevelDebug()); |
|
230 | - } else { |
|
231 | - if(is_int($arg)) { |
|
232 | - switch($arg) { |
|
233 | - case self::ALL: return self::getLevelAll(); |
|
234 | - case self::DEBUG: return self::getLevelDebug(); |
|
235 | - case self::INFO: return self::getLevelInfo(); |
|
236 | - case self::WARN: return self::getLevelWarn(); |
|
237 | - case self::ERROR: return self::getLevelError(); |
|
238 | - case self::FATAL: return self::getLevelFatal(); |
|
239 | - case self::OFF: return self::getLevelOff(); |
|
240 | - default: return $defaultLevel; |
|
241 | - } |
|
242 | - } else { |
|
243 | - switch(strtoupper($arg)) { |
|
244 | - case 'ALL': return self::getLevelAll(); |
|
245 | - case 'DEBUG': return self::getLevelDebug(); |
|
246 | - case 'INFO': return self::getLevelInfo(); |
|
247 | - case 'WARN': return self::getLevelWarn(); |
|
248 | - case 'ERROR': return self::getLevelError(); |
|
249 | - case 'FATAL': return self::getLevelFatal(); |
|
250 | - case 'OFF': return self::getLevelOff(); |
|
251 | - default: return $defaultLevel; |
|
252 | - } |
|
253 | - } |
|
254 | - } |
|
255 | - } |
|
219 | + /** |
|
220 | + * Convert the string passed as argument to a level. If the |
|
221 | + * conversion fails, then this method returns a DEBUG Level. |
|
222 | + * |
|
223 | + * @param mixed $arg |
|
224 | + * @param LoggerLevel $default |
|
225 | + * @static |
|
226 | + */ |
|
227 | + public static function toLevel($arg, $defaultLevel = null) { |
|
228 | + if($defaultLevel === null) { |
|
229 | + return self::toLevel($arg, self::getLevelDebug()); |
|
230 | + } else { |
|
231 | + if(is_int($arg)) { |
|
232 | + switch($arg) { |
|
233 | + case self::ALL: return self::getLevelAll(); |
|
234 | + case self::DEBUG: return self::getLevelDebug(); |
|
235 | + case self::INFO: return self::getLevelInfo(); |
|
236 | + case self::WARN: return self::getLevelWarn(); |
|
237 | + case self::ERROR: return self::getLevelError(); |
|
238 | + case self::FATAL: return self::getLevelFatal(); |
|
239 | + case self::OFF: return self::getLevelOff(); |
|
240 | + default: return $defaultLevel; |
|
241 | + } |
|
242 | + } else { |
|
243 | + switch(strtoupper($arg)) { |
|
244 | + case 'ALL': return self::getLevelAll(); |
|
245 | + case 'DEBUG': return self::getLevelDebug(); |
|
246 | + case 'INFO': return self::getLevelInfo(); |
|
247 | + case 'WARN': return self::getLevelWarn(); |
|
248 | + case 'ERROR': return self::getLevelError(); |
|
249 | + case 'FATAL': return self::getLevelFatal(); |
|
250 | + case 'OFF': return self::getLevelOff(); |
|
251 | + default: return $defaultLevel; |
|
252 | + } |
|
253 | + } |
|
254 | + } |
|
255 | + } |
|
256 | 256 | } |
@@ -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 | * Extend this abstract class to create your own log layout format. |
@@ -26,45 +26,45 @@ discard block |
||
26 | 26 | * @abstract |
27 | 27 | */ |
28 | 28 | abstract class LoggerLayout { |
29 | - /** |
|
30 | - * Activates options for this layout. |
|
31 | - * Override this method if you have options to be activated. |
|
32 | - */ |
|
33 | - public function activateOptions() { |
|
34 | - return true; |
|
35 | - } |
|
29 | + /** |
|
30 | + * Activates options for this layout. |
|
31 | + * Override this method if you have options to be activated. |
|
32 | + */ |
|
33 | + public function activateOptions() { |
|
34 | + return true; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Override this method to create your own layout format. |
|
39 | - * |
|
40 | - * @param LoggerLoggingEvent |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function format(LoggerLoggingEvent $event) { |
|
44 | - return $event->getRenderedMessage(); |
|
45 | - } |
|
37 | + /** |
|
38 | + * Override this method to create your own layout format. |
|
39 | + * |
|
40 | + * @param LoggerLoggingEvent |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function format(LoggerLoggingEvent $event) { |
|
44 | + return $event->getRenderedMessage(); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Returns the content type output by this layout. |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function getContentType() { |
|
52 | - return "text/plain"; |
|
53 | - } |
|
47 | + /** |
|
48 | + * Returns the content type output by this layout. |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function getContentType() { |
|
52 | + return "text/plain"; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Returns the footer for the layout format. |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function getFooter() { |
|
60 | - return null; |
|
61 | - } |
|
55 | + /** |
|
56 | + * Returns the footer for the layout format. |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function getFooter() { |
|
60 | + return null; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Returns the header for the layout format. |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function getHeader() { |
|
68 | - return null; |
|
69 | - } |
|
63 | + /** |
|
64 | + * Returns the header for the layout format. |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function getHeader() { |
|
68 | + return null; |
|
69 | + } |
|
70 | 70 | } |