@@ -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 | * 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 | } |
@@ -31,17 +31,17 @@ |
||
31 | 31 | */ |
32 | 32 | class LoggerConfiguratorBasic implements LoggerConfigurator { |
33 | 33 | |
34 | - /** |
|
35 | - * Add a {@link LoggerAppenderConsole} that uses |
|
36 | - * the {@link LoggerLayoutTTCC} to the root category. |
|
37 | - * |
|
38 | - * @param string $url not used here |
|
39 | - */ |
|
40 | - public function configure(LoggerHierarchy $hierarchy, $url = null) { |
|
41 | - $root = $hierarchy->getRootLogger(); |
|
42 | - $appender = new LoggerAppenderConsole('A1'); |
|
43 | - $appender->setLayout( new LoggerLayoutTTCC() ); |
|
44 | - $appender->activateOptions(); |
|
45 | - $root->addAppender($appender); |
|
46 | - } |
|
34 | + /** |
|
35 | + * Add a {@link LoggerAppenderConsole} that uses |
|
36 | + * the {@link LoggerLayoutTTCC} to the root category. |
|
37 | + * |
|
38 | + * @param string $url not used here |
|
39 | + */ |
|
40 | + public function configure(LoggerHierarchy $hierarchy, $url = null) { |
|
41 | + $root = $hierarchy->getRootLogger(); |
|
42 | + $appender = new LoggerAppenderConsole('A1'); |
|
43 | + $appender->setLayout( new LoggerLayoutTTCC() ); |
|
44 | + $appender->activateOptions(); |
|
45 | + $root->addAppender($appender); |
|
46 | + } |
|
47 | 47 | } |
@@ -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 | * Use this class to initialize the log4php environment using XML files. |
@@ -44,19 +44,19 @@ discard block |
||
44 | 44 | * @since 0.4 |
45 | 45 | */ |
46 | 46 | class LoggerConfiguratorXml implements LoggerConfigurator { |
47 | - const APPENDER_STATE = 1000; |
|
48 | - const LAYOUT_STATE = 1010; |
|
49 | - const ROOT_STATE = 1020; |
|
50 | - const LOGGER_STATE = 1030; |
|
51 | - const FILTER_STATE = 1040; |
|
47 | + const APPENDER_STATE = 1000; |
|
48 | + const LAYOUT_STATE = 1010; |
|
49 | + const ROOT_STATE = 1020; |
|
50 | + const LOGGER_STATE = 1030; |
|
51 | + const FILTER_STATE = 1040; |
|
52 | 52 | |
53 | - const DEFAULT_FILENAME = './log4php.xml'; |
|
53 | + const DEFAULT_FILENAME = './log4php.xml'; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var string the default configuration document |
|
57 | - */ |
|
58 | - const DEFAULT_CONFIGURATION = |
|
59 | - '<?xml version="1.0" ?> |
|
55 | + /** |
|
56 | + * @var string the default configuration document |
|
57 | + */ |
|
58 | + const DEFAULT_CONFIGURATION = |
|
59 | + '<?xml version="1.0" ?> |
|
60 | 60 | <log4php:configuration threshold="all"> |
61 | 61 | <appender name="A1" class="LoggerAppenderEcho"> |
62 | 62 | <layout class="LoggerLayoutSimple" /> |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | </root> |
68 | 68 | </log4php:configuration>'; |
69 | 69 | |
70 | - /** |
|
71 | - * @var string the elements namespace |
|
72 | - */ |
|
73 | - const XMLNS = 'HTTP://LOGGING.APACHE.ORG/LOG4PHP/'; |
|
70 | + /** |
|
71 | + * @var string the elements namespace |
|
72 | + */ |
|
73 | + const XMLNS = 'HTTP://LOGGING.APACHE.ORG/LOG4PHP/'; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @var LoggerHierarchy |
@@ -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 | } |
@@ -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 | * Log objects using customized renderers that implement {@link LoggerRendererObject}. |
@@ -36,114 +36,114 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class LoggerRendererMap { |
38 | 38 | |
39 | - /** |
|
40 | - * @var array |
|
41 | - */ |
|
42 | - private $map; |
|
39 | + /** |
|
40 | + * @var array |
|
41 | + */ |
|
42 | + private $map; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var LoggerDefaultRenderer |
|
46 | - */ |
|
47 | - private $defaultRenderer; |
|
44 | + /** |
|
45 | + * @var LoggerDefaultRenderer |
|
46 | + */ |
|
47 | + private $defaultRenderer; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Constructor |
|
51 | - */ |
|
52 | - public function __construct() { |
|
53 | - $this->map = array(); |
|
54 | - $this->defaultRenderer = new LoggerRendererDefault(); |
|
55 | - } |
|
49 | + /** |
|
50 | + * Constructor |
|
51 | + */ |
|
52 | + public function __construct() { |
|
53 | + $this->map = array(); |
|
54 | + $this->defaultRenderer = new LoggerRendererDefault(); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Add a renderer to a hierarchy passed as parameter. |
|
59 | - * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
|
60 | - * |
|
61 | - * @param LoggerHierarchy $repository a logger repository. |
|
62 | - * @param string $renderedClassName |
|
63 | - * @param string $renderingClassName |
|
64 | - * @static |
|
65 | - */ |
|
66 | - public function addRenderer($renderedClassName, $renderingClassName) { |
|
67 | - $renderer = LoggerReflectionUtils::createObject($renderingClassName); |
|
68 | - if($renderer == null) { |
|
69 | - return; |
|
70 | - } else { |
|
71 | - $this->put($renderedClassName, $renderer); |
|
72 | - } |
|
73 | - } |
|
57 | + /** |
|
58 | + * Add a renderer to a hierarchy passed as parameter. |
|
59 | + * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
|
60 | + * |
|
61 | + * @param LoggerHierarchy $repository a logger repository. |
|
62 | + * @param string $renderedClassName |
|
63 | + * @param string $renderingClassName |
|
64 | + * @static |
|
65 | + */ |
|
66 | + public function addRenderer($renderedClassName, $renderingClassName) { |
|
67 | + $renderer = LoggerReflectionUtils::createObject($renderingClassName); |
|
68 | + if($renderer == null) { |
|
69 | + return; |
|
70 | + } else { |
|
71 | + $this->put($renderedClassName, $renderer); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * Find the appropriate renderer for the class type of the |
|
78 | - * <var>o</var> parameter. |
|
79 | - * |
|
80 | - * This is accomplished by calling the {@link getByObject()} |
|
81 | - * method if <var>o</var> is object or using {@link LoggerRendererDefault}. |
|
82 | - * Once a renderer is found, it is applied on the object <var>o</var> and |
|
83 | - * the result is returned as a string. |
|
84 | - * |
|
85 | - * @param mixed $o |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function findAndRender($o) { |
|
89 | - if($o == null) { |
|
90 | - return null; |
|
91 | - } else { |
|
92 | - if(is_object($o)) { |
|
93 | - $renderer = $this->getByObject($o); |
|
94 | - if($renderer !== null) { |
|
95 | - return $renderer->render($o); |
|
96 | - } else { |
|
97 | - return null; |
|
98 | - } |
|
99 | - } else { |
|
100 | - $renderer = $this->defaultRenderer; |
|
101 | - return $renderer->render($o); |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
76 | + /** |
|
77 | + * Find the appropriate renderer for the class type of the |
|
78 | + * <var>o</var> parameter. |
|
79 | + * |
|
80 | + * This is accomplished by calling the {@link getByObject()} |
|
81 | + * method if <var>o</var> is object or using {@link LoggerRendererDefault}. |
|
82 | + * Once a renderer is found, it is applied on the object <var>o</var> and |
|
83 | + * the result is returned as a string. |
|
84 | + * |
|
85 | + * @param mixed $o |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function findAndRender($o) { |
|
89 | + if($o == null) { |
|
90 | + return null; |
|
91 | + } else { |
|
92 | + if(is_object($o)) { |
|
93 | + $renderer = $this->getByObject($o); |
|
94 | + if($renderer !== null) { |
|
95 | + return $renderer->render($o); |
|
96 | + } else { |
|
97 | + return null; |
|
98 | + } |
|
99 | + } else { |
|
100 | + $renderer = $this->defaultRenderer; |
|
101 | + return $renderer->render($o); |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the |
|
108 | - * class of the object parameter. |
|
109 | - * |
|
110 | - * @param mixed $o |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public function getByObject($o) { |
|
114 | - return ($o == null) ? null : $this->getByClassName(get_class($o)); |
|
115 | - } |
|
106 | + /** |
|
107 | + * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the |
|
108 | + * class of the object parameter. |
|
109 | + * |
|
110 | + * @param mixed $o |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public function getByObject($o) { |
|
114 | + return ($o == null) ? null : $this->getByClassName(get_class($o)); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * Search the parents of <var>clazz</var> for a renderer. |
|
120 | - * |
|
121 | - * The renderer closest in the hierarchy will be returned. If no |
|
122 | - * renderers could be found, then the default renderer is returned. |
|
123 | - * |
|
124 | - * @param string $class |
|
125 | - * @return LoggerRendererObject |
|
126 | - */ |
|
127 | - public function getByClassName($class) { |
|
128 | - $r = null; |
|
129 | - for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
130 | - if(isset($this->map[$c])) { |
|
131 | - return $this->map[$c]; |
|
132 | - } |
|
133 | - } |
|
134 | - return $this->defaultRenderer; |
|
135 | - } |
|
118 | + /** |
|
119 | + * Search the parents of <var>clazz</var> for a renderer. |
|
120 | + * |
|
121 | + * The renderer closest in the hierarchy will be returned. If no |
|
122 | + * renderers could be found, then the default renderer is returned. |
|
123 | + * |
|
124 | + * @param string $class |
|
125 | + * @return LoggerRendererObject |
|
126 | + */ |
|
127 | + public function getByClassName($class) { |
|
128 | + $r = null; |
|
129 | + for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
130 | + if(isset($this->map[$c])) { |
|
131 | + return $this->map[$c]; |
|
132 | + } |
|
133 | + } |
|
134 | + return $this->defaultRenderer; |
|
135 | + } |
|
136 | 136 | |
137 | - public function clear() { |
|
138 | - $this->map = array(); |
|
139 | - } |
|
137 | + public function clear() { |
|
138 | + $this->map = array(); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Register a {@link LoggerRendererObject} for <var>clazz</var>. |
|
143 | - * @param string $class |
|
144 | - * @param LoggerRendererObject $or |
|
145 | - */ |
|
146 | - private function put($class, $or) { |
|
147 | - $this->map[strtolower($class)] = $or; |
|
148 | - } |
|
141 | + /** |
|
142 | + * Register a {@link LoggerRendererObject} for <var>clazz</var>. |
|
143 | + * @param string $class |
|
144 | + * @param LoggerRendererObject $or |
|
145 | + */ |
|
146 | + private function put($class, $or) { |
|
147 | + $this->map[strtolower($class)] = $or; |
|
148 | + } |
|
149 | 149 | } |
@@ -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 default Renderer renders objects by type casting. |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | */ |
40 | 40 | class LoggerRendererDefault implements LoggerRendererObject { |
41 | 41 | |
42 | - /** |
|
43 | - * Render objects by type casting |
|
44 | - * |
|
45 | - * @param mixed $o the object to render |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function render($o) { |
|
49 | - return var_export($o, true); |
|
50 | - } |
|
42 | + /** |
|
43 | + * Render objects by type casting |
|
44 | + * |
|
45 | + * @param mixed $o the object to render |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function render($o) { |
|
49 | + return var_export($o, true); |
|
50 | + } |
|
51 | 51 | } |
@@ -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 | * Implement this interface in order to render objects as strings using {@link LoggerRendererMap}. |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | * @since 0.3 |
38 | 38 | */ |
39 | 39 | interface LoggerRendererObject { |
40 | - /** |
|
41 | - * Render the entity passed as parameter as a String. |
|
42 | - * @param mixed $o entity to render |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function render($o); |
|
40 | + /** |
|
41 | + * Render the entity passed as parameter as a String. |
|
42 | + * @param mixed $o entity to render |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function render($o); |
|
46 | 46 | } |
@@ -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 logging event. |
@@ -26,334 +26,334 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class LoggerLoggingEvent { |
28 | 28 | |
29 | - private static $startTime; |
|
29 | + private static $startTime; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @var string Fully Qualified Class Name of the calling category class. |
|
33 | - */ |
|
34 | - private $fqcn; |
|
31 | + /** |
|
32 | + * @var string Fully Qualified Class Name of the calling category class. |
|
33 | + */ |
|
34 | + private $fqcn; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var Logger reference |
|
38 | - */ |
|
39 | - private $logger = null; |
|
36 | + /** |
|
37 | + * @var Logger reference |
|
38 | + */ |
|
39 | + private $logger = null; |
|
40 | 40 | |
41 | - /** |
|
42 | - * The category (logger) name. |
|
43 | - * This field will be marked as private in future |
|
44 | - * releases. Please do not access it directly. |
|
45 | - * Use the {@link getLoggerName()} method instead. |
|
46 | - * @deprecated |
|
47 | - */ |
|
48 | - private $categoryName; |
|
41 | + /** |
|
42 | + * The category (logger) name. |
|
43 | + * This field will be marked as private in future |
|
44 | + * releases. Please do not access it directly. |
|
45 | + * Use the {@link getLoggerName()} method instead. |
|
46 | + * @deprecated |
|
47 | + */ |
|
48 | + private $categoryName; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Level of logging event. |
|
52 | - * <p> This field should not be accessed directly. You shoud use the |
|
53 | - * {@link getLevel()} method instead. |
|
54 | - * |
|
55 | - * @deprecated |
|
56 | - * @var LoggerLevel |
|
57 | - */ |
|
58 | - protected $level; |
|
50 | + /** |
|
51 | + * Level of logging event. |
|
52 | + * <p> This field should not be accessed directly. You shoud use the |
|
53 | + * {@link getLevel()} method instead. |
|
54 | + * |
|
55 | + * @deprecated |
|
56 | + * @var LoggerLevel |
|
57 | + */ |
|
58 | + protected $level; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var string The nested diagnostic context (NDC) of logging event. |
|
62 | - */ |
|
63 | - private $ndc; |
|
60 | + /** |
|
61 | + * @var string The nested diagnostic context (NDC) of logging event. |
|
62 | + */ |
|
63 | + private $ndc; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Have we tried to do an NDC lookup? If we did, there is no need |
|
67 | - * to do it again. Note that its value is always false when |
|
68 | - * serialized. Thus, a receiving SocketNode will never use it's own |
|
69 | - * (incorrect) NDC. See also writeObject method. |
|
70 | - * @var boolean |
|
71 | - */ |
|
72 | - private $ndcLookupRequired = true; |
|
65 | + /** |
|
66 | + * Have we tried to do an NDC lookup? If we did, there is no need |
|
67 | + * to do it again. Note that its value is always false when |
|
68 | + * serialized. Thus, a receiving SocketNode will never use it's own |
|
69 | + * (incorrect) NDC. See also writeObject method. |
|
70 | + * @var boolean |
|
71 | + */ |
|
72 | + private $ndcLookupRequired = true; |
|
73 | 73 | |
74 | - /** |
|
75 | - * Have we tried to do an MDC lookup? If we did, there is no need |
|
76 | - * to do it again. Note that its value is always false when |
|
77 | - * serialized. See also the getMDC and getMDCCopy methods. |
|
78 | - * @var boolean |
|
79 | - */ |
|
80 | - private $mdcCopyLookupRequired = true; |
|
74 | + /** |
|
75 | + * Have we tried to do an MDC lookup? If we did, there is no need |
|
76 | + * to do it again. Note that its value is always false when |
|
77 | + * serialized. See also the getMDC and getMDCCopy methods. |
|
78 | + * @var boolean |
|
79 | + */ |
|
80 | + private $mdcCopyLookupRequired = true; |
|
81 | 81 | |
82 | - /** |
|
83 | - * @var mixed The application supplied message of logging event. |
|
84 | - */ |
|
85 | - private $message; |
|
82 | + /** |
|
83 | + * @var mixed The application supplied message of logging event. |
|
84 | + */ |
|
85 | + private $message; |
|
86 | 86 | |
87 | - /** |
|
88 | - * The application supplied message rendered through the log4php |
|
89 | - * objet rendering mechanism. At present renderedMessage == message. |
|
90 | - * @var string |
|
91 | - */ |
|
92 | - private $renderedMessage = null; |
|
87 | + /** |
|
88 | + * The application supplied message rendered through the log4php |
|
89 | + * objet rendering mechanism. At present renderedMessage == message. |
|
90 | + * @var string |
|
91 | + */ |
|
92 | + private $renderedMessage = null; |
|
93 | 93 | |
94 | - /** |
|
95 | - * The name of thread in which this logging event was generated. |
|
96 | - * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} |
|
97 | - * @var mixed |
|
98 | - */ |
|
99 | - private $threadName = null; |
|
94 | + /** |
|
95 | + * The name of thread in which this logging event was generated. |
|
96 | + * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} |
|
97 | + * @var mixed |
|
98 | + */ |
|
99 | + private $threadName = null; |
|
100 | 100 | |
101 | - /** |
|
102 | - * The number of seconds elapsed from 1/1/1970 until logging event |
|
103 | - * was created plus microseconds if available. |
|
104 | - * @var float |
|
105 | - */ |
|
106 | - public $timeStamp; |
|
101 | + /** |
|
102 | + * The number of seconds elapsed from 1/1/1970 until logging event |
|
103 | + * was created plus microseconds if available. |
|
104 | + * @var float |
|
105 | + */ |
|
106 | + public $timeStamp; |
|
107 | 107 | |
108 | - /** |
|
109 | - * @var LoggerLocationInfo Location information for the caller. |
|
110 | - */ |
|
111 | - private $locationInfo = null; |
|
108 | + /** |
|
109 | + * @var LoggerLocationInfo Location information for the caller. |
|
110 | + */ |
|
111 | + private $locationInfo = null; |
|
112 | 112 | |
113 | - /** |
|
114 | - * Instantiate a LoggingEvent from the supplied parameters. |
|
115 | - * |
|
116 | - * <p>Except {@link $timeStamp} all the other fields of |
|
117 | - * LoggerLoggingEvent are filled when actually needed. |
|
118 | - * |
|
119 | - * @param string $fqcn name of the caller class. |
|
120 | - * @param mixed $logger The {@link Logger} category of this event or the logger name. |
|
121 | - * @param LoggerLevel $priority The level of this event. |
|
122 | - * @param mixed $message The message of this event. |
|
123 | - * @param integer $timeStamp the timestamp of this logging event. |
|
124 | - */ |
|
125 | - public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) { |
|
126 | - $this->fqcn = $fqcn; |
|
127 | - if($logger instanceof Logger) { |
|
128 | - $this->logger = $logger; |
|
129 | - $this->categoryName = $logger->getName(); |
|
130 | - } else { |
|
131 | - $this->categoryName = strval($logger); |
|
132 | - } |
|
133 | - $this->level = $priority; |
|
134 | - $this->message = $message; |
|
135 | - if($timeStamp !== null && is_float($timeStamp)) { |
|
136 | - $this->timeStamp = $timeStamp; |
|
137 | - } else { |
|
138 | - if(function_exists('microtime')) { |
|
139 | - // get microtime as float |
|
140 | - $this->timeStamp = microtime(true); |
|
141 | - } else { |
|
142 | - $this->timeStamp = floatval(time()); |
|
143 | - } |
|
144 | - } |
|
145 | - } |
|
113 | + /** |
|
114 | + * Instantiate a LoggingEvent from the supplied parameters. |
|
115 | + * |
|
116 | + * <p>Except {@link $timeStamp} all the other fields of |
|
117 | + * LoggerLoggingEvent are filled when actually needed. |
|
118 | + * |
|
119 | + * @param string $fqcn name of the caller class. |
|
120 | + * @param mixed $logger The {@link Logger} category of this event or the logger name. |
|
121 | + * @param LoggerLevel $priority The level of this event. |
|
122 | + * @param mixed $message The message of this event. |
|
123 | + * @param integer $timeStamp the timestamp of this logging event. |
|
124 | + */ |
|
125 | + public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) { |
|
126 | + $this->fqcn = $fqcn; |
|
127 | + if($logger instanceof Logger) { |
|
128 | + $this->logger = $logger; |
|
129 | + $this->categoryName = $logger->getName(); |
|
130 | + } else { |
|
131 | + $this->categoryName = strval($logger); |
|
132 | + } |
|
133 | + $this->level = $priority; |
|
134 | + $this->message = $message; |
|
135 | + if($timeStamp !== null && is_float($timeStamp)) { |
|
136 | + $this->timeStamp = $timeStamp; |
|
137 | + } else { |
|
138 | + if(function_exists('microtime')) { |
|
139 | + // get microtime as float |
|
140 | + $this->timeStamp = microtime(true); |
|
141 | + } else { |
|
142 | + $this->timeStamp = floatval(time()); |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Set the location information for this logging event. The collected |
|
149 | - * information is cached for future use. |
|
150 | - * |
|
151 | - * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists) |
|
152 | - * to collect informations about caller.</p> |
|
153 | - * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p> |
|
154 | - * @return LoggerLocationInfo |
|
155 | - */ |
|
156 | - public function getLocationInformation() { |
|
157 | - if($this->locationInfo === null) { |
|
147 | + /** |
|
148 | + * Set the location information for this logging event. The collected |
|
149 | + * information is cached for future use. |
|
150 | + * |
|
151 | + * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists) |
|
152 | + * to collect informations about caller.</p> |
|
153 | + * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p> |
|
154 | + * @return LoggerLocationInfo |
|
155 | + */ |
|
156 | + public function getLocationInformation() { |
|
157 | + if($this->locationInfo === null) { |
|
158 | 158 | |
159 | - $locationInfo = array(); |
|
159 | + $locationInfo = array(); |
|
160 | 160 | |
161 | - if(function_exists('debug_backtrace')) { |
|
162 | - $trace = debug_backtrace(); |
|
163 | - $prevHop = null; |
|
164 | - // make a downsearch to identify the caller |
|
165 | - $hop = array_pop($trace); |
|
166 | - while($hop !== null) { |
|
167 | - if(isset($hop['class'])) { |
|
168 | - // we are sometimes in functions = no class available: avoid php warning here |
|
169 | - $className = strtolower($hop['class']); |
|
170 | - if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or |
|
171 | - strtolower(get_parent_class($className)) == 'logger' or |
|
172 | - strtolower(get_parent_class($className)) == 'loggercategory')) { |
|
173 | - $locationInfo['line'] = $hop['line']; |
|
174 | - $locationInfo['file'] = $hop['file']; |
|
175 | - break; |
|
176 | - } |
|
177 | - } |
|
178 | - $prevHop = $hop; |
|
179 | - $hop = array_pop($trace); |
|
180 | - } |
|
181 | - $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; |
|
182 | - if(isset($prevHop['function']) and |
|
183 | - $prevHop['function'] !== 'include' and |
|
184 | - $prevHop['function'] !== 'include_once' and |
|
185 | - $prevHop['function'] !== 'require' and |
|
186 | - $prevHop['function'] !== 'require_once') { |
|
161 | + if(function_exists('debug_backtrace')) { |
|
162 | + $trace = debug_backtrace(); |
|
163 | + $prevHop = null; |
|
164 | + // make a downsearch to identify the caller |
|
165 | + $hop = array_pop($trace); |
|
166 | + while($hop !== null) { |
|
167 | + if(isset($hop['class'])) { |
|
168 | + // we are sometimes in functions = no class available: avoid php warning here |
|
169 | + $className = strtolower($hop['class']); |
|
170 | + if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or |
|
171 | + strtolower(get_parent_class($className)) == 'logger' or |
|
172 | + strtolower(get_parent_class($className)) == 'loggercategory')) { |
|
173 | + $locationInfo['line'] = $hop['line']; |
|
174 | + $locationInfo['file'] = $hop['file']; |
|
175 | + break; |
|
176 | + } |
|
177 | + } |
|
178 | + $prevHop = $hop; |
|
179 | + $hop = array_pop($trace); |
|
180 | + } |
|
181 | + $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; |
|
182 | + if(isset($prevHop['function']) and |
|
183 | + $prevHop['function'] !== 'include' and |
|
184 | + $prevHop['function'] !== 'include_once' and |
|
185 | + $prevHop['function'] !== 'require' and |
|
186 | + $prevHop['function'] !== 'require_once') { |
|
187 | 187 | |
188 | - $locationInfo['function'] = $prevHop['function']; |
|
189 | - } else { |
|
190 | - $locationInfo['function'] = 'main'; |
|
191 | - } |
|
192 | - } |
|
188 | + $locationInfo['function'] = $prevHop['function']; |
|
189 | + } else { |
|
190 | + $locationInfo['function'] = 'main'; |
|
191 | + } |
|
192 | + } |
|
193 | 193 | |
194 | - $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn); |
|
195 | - } |
|
196 | - return $this->locationInfo; |
|
197 | - } |
|
194 | + $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn); |
|
195 | + } |
|
196 | + return $this->locationInfo; |
|
197 | + } |
|
198 | 198 | |
199 | - /** |
|
200 | - * Return the level of this event. Use this form instead of directly |
|
201 | - * accessing the {@link $level} field. |
|
202 | - * @return LoggerLevel |
|
203 | - */ |
|
204 | - public function getLevel() { |
|
205 | - return $this->level; |
|
206 | - } |
|
199 | + /** |
|
200 | + * Return the level of this event. Use this form instead of directly |
|
201 | + * accessing the {@link $level} field. |
|
202 | + * @return LoggerLevel |
|
203 | + */ |
|
204 | + public function getLevel() { |
|
205 | + return $this->level; |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * Return the name of the logger. Use this form instead of directly |
|
210 | - * accessing the {@link $categoryName} field. |
|
211 | - * @return string |
|
212 | - */ |
|
213 | - public function getLoggerName() { |
|
214 | - return $this->categoryName; |
|
215 | - } |
|
208 | + /** |
|
209 | + * Return the name of the logger. Use this form instead of directly |
|
210 | + * accessing the {@link $categoryName} field. |
|
211 | + * @return string |
|
212 | + */ |
|
213 | + public function getLoggerName() { |
|
214 | + return $this->categoryName; |
|
215 | + } |
|
216 | 216 | |
217 | - /** |
|
218 | - * Return the message for this logging event. |
|
219 | - * |
|
220 | - * <p>Before serialization, the returned object is the message |
|
221 | - * passed by the user to generate the logging event. After |
|
222 | - * serialization, the returned value equals the String form of the |
|
223 | - * message possibly after object rendering. |
|
224 | - * @return mixed |
|
225 | - */ |
|
226 | - public function getMessage() { |
|
227 | - if($this->message !== null) { |
|
228 | - return $this->message; |
|
229 | - } else { |
|
230 | - return $this->getRenderedMessage(); |
|
231 | - } |
|
232 | - } |
|
217 | + /** |
|
218 | + * Return the message for this logging event. |
|
219 | + * |
|
220 | + * <p>Before serialization, the returned object is the message |
|
221 | + * passed by the user to generate the logging event. After |
|
222 | + * serialization, the returned value equals the String form of the |
|
223 | + * message possibly after object rendering. |
|
224 | + * @return mixed |
|
225 | + */ |
|
226 | + public function getMessage() { |
|
227 | + if($this->message !== null) { |
|
228 | + return $this->message; |
|
229 | + } else { |
|
230 | + return $this->getRenderedMessage(); |
|
231 | + } |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * This method returns the NDC for this event. It will return the |
|
236 | - * correct content even if the event was generated in a different |
|
237 | - * thread or even on a different machine. The {@link LoggerNDC::get()} method |
|
238 | - * should <b>never</b> be called directly. |
|
239 | - * @return string |
|
240 | - */ |
|
241 | - public function getNDC() { |
|
242 | - if($this->ndcLookupRequired) { |
|
243 | - $this->ndcLookupRequired = false; |
|
244 | - $this->ndc = implode(' ', LoggerNDC::get()); |
|
245 | - } |
|
246 | - return $this->ndc; |
|
247 | - } |
|
234 | + /** |
|
235 | + * This method returns the NDC for this event. It will return the |
|
236 | + * correct content even if the event was generated in a different |
|
237 | + * thread or even on a different machine. The {@link LoggerNDC::get()} method |
|
238 | + * should <b>never</b> be called directly. |
|
239 | + * @return string |
|
240 | + */ |
|
241 | + public function getNDC() { |
|
242 | + if($this->ndcLookupRequired) { |
|
243 | + $this->ndcLookupRequired = false; |
|
244 | + $this->ndc = implode(' ', LoggerNDC::get()); |
|
245 | + } |
|
246 | + return $this->ndc; |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * Returns the the context corresponding to the <code>key</code> |
|
251 | - * parameter. |
|
252 | - * @return string |
|
253 | - */ |
|
254 | - public function getMDC($key) { |
|
255 | - return LoggerMDC::get($key); |
|
256 | - } |
|
249 | + /** |
|
250 | + * Returns the the context corresponding to the <code>key</code> |
|
251 | + * parameter. |
|
252 | + * @return string |
|
253 | + */ |
|
254 | + public function getMDC($key) { |
|
255 | + return LoggerMDC::get($key); |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * Render message. |
|
260 | - * @return string |
|
261 | - */ |
|
262 | - public function getRenderedMessage() { |
|
263 | - if($this->renderedMessage === null and $this->message !== null) { |
|
264 | - if(is_string($this->message)) { |
|
265 | - $this->renderedMessage = $this->message; |
|
266 | - } else { |
|
267 | - // $this->logger might be null or an instance of Logger or RootLogger |
|
268 | - // But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is |
|
269 | - // no need figure out which one is $this->logger part of. |
|
270 | - // TODO: Logger::getHierarchy() is marked @deprecated! |
|
271 | - $repository = Logger::getHierarchy(); |
|
272 | - $rendererMap = $repository->getRendererMap(); |
|
273 | - $this->renderedMessage= $rendererMap->findAndRender($this->message); |
|
274 | - } |
|
275 | - } |
|
276 | - return $this->renderedMessage; |
|
277 | - } |
|
258 | + /** |
|
259 | + * Render message. |
|
260 | + * @return string |
|
261 | + */ |
|
262 | + public function getRenderedMessage() { |
|
263 | + if($this->renderedMessage === null and $this->message !== null) { |
|
264 | + if(is_string($this->message)) { |
|
265 | + $this->renderedMessage = $this->message; |
|
266 | + } else { |
|
267 | + // $this->logger might be null or an instance of Logger or RootLogger |
|
268 | + // But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is |
|
269 | + // no need figure out which one is $this->logger part of. |
|
270 | + // TODO: Logger::getHierarchy() is marked @deprecated! |
|
271 | + $repository = Logger::getHierarchy(); |
|
272 | + $rendererMap = $repository->getRendererMap(); |
|
273 | + $this->renderedMessage= $rendererMap->findAndRender($this->message); |
|
274 | + } |
|
275 | + } |
|
276 | + return $this->renderedMessage; |
|
277 | + } |
|
278 | 278 | |
279 | - /** |
|
280 | - * Returns the time when the application started, in seconds |
|
281 | - * elapsed since 01.01.1970 plus microseconds if available. |
|
282 | - * |
|
283 | - * @return float |
|
284 | - * @static |
|
285 | - */ |
|
286 | - public static function getStartTime() { |
|
287 | - if(!isset(self::$startTime)) { |
|
288 | - if (function_exists('microtime')) { |
|
289 | - // microtime as float |
|
290 | - self::$startTime = microtime(true); |
|
291 | - } else { |
|
292 | - self::$startTime = floatval(time()); |
|
293 | - } |
|
294 | - } |
|
295 | - return self::$startTime; |
|
296 | - } |
|
279 | + /** |
|
280 | + * Returns the time when the application started, in seconds |
|
281 | + * elapsed since 01.01.1970 plus microseconds if available. |
|
282 | + * |
|
283 | + * @return float |
|
284 | + * @static |
|
285 | + */ |
|
286 | + public static function getStartTime() { |
|
287 | + if(!isset(self::$startTime)) { |
|
288 | + if (function_exists('microtime')) { |
|
289 | + // microtime as float |
|
290 | + self::$startTime = microtime(true); |
|
291 | + } else { |
|
292 | + self::$startTime = floatval(time()); |
|
293 | + } |
|
294 | + } |
|
295 | + return self::$startTime; |
|
296 | + } |
|
297 | 297 | |
298 | - /** |
|
299 | - * @return float |
|
300 | - */ |
|
301 | - public function getTimeStamp() { |
|
302 | - return $this->timeStamp; |
|
303 | - } |
|
298 | + /** |
|
299 | + * @return float |
|
300 | + */ |
|
301 | + public function getTimeStamp() { |
|
302 | + return $this->timeStamp; |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * Calculates the time of this event. |
|
307 | - * @return the time after event starttime when this event has occured |
|
308 | - */ |
|
309 | - public function getTime() { |
|
305 | + /** |
|
306 | + * Calculates the time of this event. |
|
307 | + * @return the time after event starttime when this event has occured |
|
308 | + */ |
|
309 | + public function getTime() { |
|
310 | 310 | $eventTime = (float)$this->getTimeStamp(); |
311 | 311 | $eventStartTime = (float)LoggerLoggingEvent::getStartTime(); |
312 | 312 | return number_format(($eventTime - $eventStartTime) * 1000, 0, '', ''); |
313 | 313 | } |
314 | 314 | |
315 | - /** |
|
316 | - * @return mixed |
|
317 | - */ |
|
318 | - public function getThreadName() { |
|
319 | - if ($this->threadName === null) { |
|
320 | - $this->threadName = (string)getmypid(); |
|
321 | - } |
|
322 | - return $this->threadName; |
|
323 | - } |
|
315 | + /** |
|
316 | + * @return mixed |
|
317 | + */ |
|
318 | + public function getThreadName() { |
|
319 | + if ($this->threadName === null) { |
|
320 | + $this->threadName = (string)getmypid(); |
|
321 | + } |
|
322 | + return $this->threadName; |
|
323 | + } |
|
324 | 324 | |
325 | - /** |
|
326 | - * @return mixed null |
|
327 | - */ |
|
328 | - public function getThrowableInformation() { |
|
329 | - return null; |
|
330 | - } |
|
325 | + /** |
|
326 | + * @return mixed null |
|
327 | + */ |
|
328 | + public function getThrowableInformation() { |
|
329 | + return null; |
|
330 | + } |
|
331 | 331 | |
332 | - /** |
|
333 | - * Serialize this object |
|
334 | - * @return string |
|
335 | - */ |
|
336 | - public function toString() { |
|
337 | - serialize($this); |
|
338 | - } |
|
332 | + /** |
|
333 | + * Serialize this object |
|
334 | + * @return string |
|
335 | + */ |
|
336 | + public function toString() { |
|
337 | + serialize($this); |
|
338 | + } |
|
339 | 339 | |
340 | - /** |
|
341 | - * Avoid serialization of the {@link $logger} object |
|
342 | - */ |
|
343 | - public function __sleep() { |
|
344 | - return array( |
|
345 | - 'fqcn', |
|
346 | - 'categoryName', |
|
347 | - 'level', |
|
348 | - 'ndc', |
|
349 | - 'ndcLookupRequired', |
|
350 | - 'message', |
|
351 | - 'renderedMessage', |
|
352 | - 'threadName', |
|
353 | - 'timeStamp', |
|
354 | - 'locationInfo', |
|
355 | - ); |
|
356 | - } |
|
340 | + /** |
|
341 | + * Avoid serialization of the {@link $logger} object |
|
342 | + */ |
|
343 | + public function __sleep() { |
|
344 | + return array( |
|
345 | + 'fqcn', |
|
346 | + 'categoryName', |
|
347 | + 'level', |
|
348 | + 'ndc', |
|
349 | + 'ndcLookupRequired', |
|
350 | + 'message', |
|
351 | + 'renderedMessage', |
|
352 | + 'threadName', |
|
353 | + 'timeStamp', |
|
354 | + 'locationInfo', |
|
355 | + ); |
|
356 | + } |
|
357 | 357 | |
358 | 358 | } |
359 | 359 |