@@ -55,62 +55,62 @@ |
||
55 | 55 | * @package log4php |
56 | 56 | */ |
57 | 57 | class LoggerMDC { |
58 | - /** |
|
59 | - * Put a context value as identified with the key parameter into the current thread's |
|
60 | - * context map. |
|
61 | - * |
|
62 | - * <p>If the current thread does not have a context map it is |
|
63 | - * created as a side effect.</p> |
|
64 | - * |
|
65 | - * <p>Note that you cannot put more than {@link self::HT_SIZE} keys.</p> |
|
66 | - * |
|
67 | - * @param string $key the key |
|
68 | - * @param string $value the value |
|
69 | - * @static |
|
70 | - */ |
|
71 | - public static function put($key, $value) { |
|
72 | - $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value; |
|
73 | - } |
|
58 | + /** |
|
59 | + * Put a context value as identified with the key parameter into the current thread's |
|
60 | + * context map. |
|
61 | + * |
|
62 | + * <p>If the current thread does not have a context map it is |
|
63 | + * created as a side effect.</p> |
|
64 | + * |
|
65 | + * <p>Note that you cannot put more than {@link self::HT_SIZE} keys.</p> |
|
66 | + * |
|
67 | + * @param string $key the key |
|
68 | + * @param string $value the value |
|
69 | + * @static |
|
70 | + */ |
|
71 | + public static function put($key, $value) { |
|
72 | + $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Get the context identified by the key parameter. |
|
77 | - * |
|
78 | - * <p>You can use special key identifiers to map values in |
|
79 | - * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.' |
|
80 | - * followed by the var name you want to refer.</p> |
|
81 | - * |
|
82 | - * <p>This method has no side effects.</p> |
|
83 | - * |
|
84 | - * @param string $key |
|
85 | - * @return string |
|
86 | - * @static |
|
87 | - */ |
|
88 | - public static function get($key) { |
|
89 | - if(!empty($key)) { |
|
90 | - if(strpos($key, 'server.') === 0) { |
|
91 | - $varName = substr($key, 7); |
|
92 | - return @$_SERVER[$varName]; |
|
93 | - } else if(strpos($key, 'env.') === 0) { |
|
94 | - $varName = substr($key, 4); |
|
95 | - return @$_ENV[$varName]; |
|
96 | - } else if (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) { |
|
97 | - return $GLOBALS['log4php.LoggerMDC.ht'][$key]; |
|
98 | - } |
|
99 | - } |
|
100 | - return ''; |
|
101 | - } |
|
75 | + /** |
|
76 | + * Get the context identified by the key parameter. |
|
77 | + * |
|
78 | + * <p>You can use special key identifiers to map values in |
|
79 | + * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.' |
|
80 | + * followed by the var name you want to refer.</p> |
|
81 | + * |
|
82 | + * <p>This method has no side effects.</p> |
|
83 | + * |
|
84 | + * @param string $key |
|
85 | + * @return string |
|
86 | + * @static |
|
87 | + */ |
|
88 | + public static function get($key) { |
|
89 | + if(!empty($key)) { |
|
90 | + if(strpos($key, 'server.') === 0) { |
|
91 | + $varName = substr($key, 7); |
|
92 | + return @$_SERVER[$varName]; |
|
93 | + } else if(strpos($key, 'env.') === 0) { |
|
94 | + $varName = substr($key, 4); |
|
95 | + return @$_ENV[$varName]; |
|
96 | + } else if (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) { |
|
97 | + return $GLOBALS['log4php.LoggerMDC.ht'][$key]; |
|
98 | + } |
|
99 | + } |
|
100 | + return ''; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Remove the the context identified by the key parameter. |
|
105 | - * |
|
106 | - * It only affects user mappings. |
|
107 | - * |
|
108 | - * @param string $key |
|
109 | - * @return string |
|
110 | - * @static |
|
111 | - */ |
|
112 | - public static function remove($key) { |
|
113 | - unset($GLOBALS['log4php.LoggerMDC.ht'][$key]); |
|
114 | - } |
|
103 | + /** |
|
104 | + * Remove the the context identified by the key parameter. |
|
105 | + * |
|
106 | + * It only affects user mappings. |
|
107 | + * |
|
108 | + * @param string $key |
|
109 | + * @return string |
|
110 | + * @static |
|
111 | + */ |
|
112 | + public static function remove($key) { |
|
113 | + unset($GLOBALS['log4php.LoggerMDC.ht'][$key]); |
|
114 | + } |
|
115 | 115 | |
116 | 116 | } |
@@ -26,45 +26,45 @@ |
||
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 | } |
@@ -47,58 +47,58 @@ |
||
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 | } |
@@ -136,61 +136,61 @@ |
||
136 | 136 | * @since 0.3 |
137 | 137 | */ |
138 | 138 | class LoggerLayoutPattern extends LoggerLayout { |
139 | - /** Default conversion Pattern */ |
|
140 | - const DEFAULT_CONVERSION_PATTERN = '%m%n'; |
|
139 | + /** Default conversion Pattern */ |
|
140 | + const DEFAULT_CONVERSION_PATTERN = '%m%n'; |
|
141 | 141 | |
142 | - /** Default conversion TTCC Pattern */ |
|
143 | - const TTCC_CONVERSION_PATTERN = '%r [%t] %p %c %x - %m%n'; |
|
142 | + /** Default conversion TTCC Pattern */ |
|
143 | + const TTCC_CONVERSION_PATTERN = '%r [%t] %p %c %x - %m%n'; |
|
144 | 144 | |
145 | - /** The pattern. |
|
146 | - * @var string */ |
|
147 | - private $pattern; |
|
145 | + /** The pattern. |
|
146 | + * @var string */ |
|
147 | + private $pattern; |
|
148 | 148 | |
149 | - /** Head of a chain of Converters. |
|
150 | - * @var LoggerPatternConverter */ |
|
151 | - private $head; |
|
149 | + /** Head of a chain of Converters. |
|
150 | + * @var LoggerPatternConverter */ |
|
151 | + private $head; |
|
152 | 152 | |
153 | - private $timezone; |
|
153 | + private $timezone; |
|
154 | 154 | |
155 | - /** |
|
156 | - * Constructs a PatternLayout using the |
|
157 | - * {@link DEFAULT_LAYOUT_PATTERN}. |
|
158 | - * The default pattern just produces the application supplied message. |
|
159 | - */ |
|
160 | - public function __construct($pattern = null) { |
|
161 | - if ($pattern === null) { |
|
162 | - $this->pattern = self :: DEFAULT_CONVERSION_PATTERN; |
|
163 | - } else { |
|
164 | - $this->pattern = $pattern; |
|
165 | - } |
|
166 | - } |
|
155 | + /** |
|
156 | + * Constructs a PatternLayout using the |
|
157 | + * {@link DEFAULT_LAYOUT_PATTERN}. |
|
158 | + * The default pattern just produces the application supplied message. |
|
159 | + */ |
|
160 | + public function __construct($pattern = null) { |
|
161 | + if ($pattern === null) { |
|
162 | + $this->pattern = self :: DEFAULT_CONVERSION_PATTERN; |
|
163 | + } else { |
|
164 | + $this->pattern = $pattern; |
|
165 | + } |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * Set the <b>ConversionPattern</b> option. This is the string which |
|
170 | - * controls formatting and consists of a mix of literal content and |
|
171 | - * conversion specifiers. |
|
172 | - */ |
|
173 | - public function setConversionPattern($conversionPattern) { |
|
174 | - $this->pattern = $conversionPattern; |
|
175 | - $patternParser = new LoggerPatternParser($this->pattern); |
|
176 | - $this->head = $patternParser->parse(); |
|
177 | - } |
|
168 | + /** |
|
169 | + * Set the <b>ConversionPattern</b> option. This is the string which |
|
170 | + * controls formatting and consists of a mix of literal content and |
|
171 | + * conversion specifiers. |
|
172 | + */ |
|
173 | + public function setConversionPattern($conversionPattern) { |
|
174 | + $this->pattern = $conversionPattern; |
|
175 | + $patternParser = new LoggerPatternParser($this->pattern); |
|
176 | + $this->head = $patternParser->parse(); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Produces a formatted string as specified by the conversion pattern. |
|
181 | - * |
|
182 | - * @param LoggerLoggingEvent $event |
|
183 | - * @return string |
|
184 | - */ |
|
185 | - public function format(LoggerLoggingEvent $event) { |
|
186 | - $sbuf = ''; |
|
187 | - $c = $this->head; |
|
188 | - while ($c !== null) { |
|
189 | - $c->format($sbuf, $event); |
|
190 | - $c = $c->next; |
|
191 | - } |
|
192 | - return $sbuf; |
|
193 | - } |
|
179 | + /** |
|
180 | + * Produces a formatted string as specified by the conversion pattern. |
|
181 | + * |
|
182 | + * @param LoggerLoggingEvent $event |
|
183 | + * @return string |
|
184 | + */ |
|
185 | + public function format(LoggerLoggingEvent $event) { |
|
186 | + $sbuf = ''; |
|
187 | + $c = $this->head; |
|
188 | + while ($c !== null) { |
|
189 | + $c->format($sbuf, $event); |
|
190 | + $c = $c->next; |
|
191 | + } |
|
192 | + return $sbuf; |
|
193 | + } |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Returns an array with the formatted elements. |
@@ -33,309 +33,309 @@ |
||
33 | 33 | */ |
34 | 34 | class LoggerPatternParser { |
35 | 35 | |
36 | - const ESCAPE_CHAR = '%'; |
|
36 | + const ESCAPE_CHAR = '%'; |
|
37 | 37 | |
38 | - const LITERAL_STATE = 0; |
|
39 | - const CONVERTER_STATE = 1; |
|
40 | - const MINUS_STATE = 2; |
|
41 | - const DOT_STATE = 3; |
|
42 | - const MIN_STATE = 4; |
|
43 | - const MAX_STATE = 5; |
|
38 | + const LITERAL_STATE = 0; |
|
39 | + const CONVERTER_STATE = 1; |
|
40 | + const MINUS_STATE = 2; |
|
41 | + const DOT_STATE = 3; |
|
42 | + const MIN_STATE = 4; |
|
43 | + const MAX_STATE = 5; |
|
44 | 44 | |
45 | - const FULL_LOCATION_CONVERTER = 1000; |
|
46 | - const METHOD_LOCATION_CONVERTER = 1001; |
|
47 | - const CLASS_LOCATION_CONVERTER = 1002; |
|
48 | - const FILE_LOCATION_CONVERTER = 1003; |
|
49 | - const LINE_LOCATION_CONVERTER = 1004; |
|
45 | + const FULL_LOCATION_CONVERTER = 1000; |
|
46 | + const METHOD_LOCATION_CONVERTER = 1001; |
|
47 | + const CLASS_LOCATION_CONVERTER = 1002; |
|
48 | + const FILE_LOCATION_CONVERTER = 1003; |
|
49 | + const LINE_LOCATION_CONVERTER = 1004; |
|
50 | 50 | |
51 | - const RELATIVE_TIME_CONVERTER = 2000; |
|
52 | - const THREAD_CONVERTER = 2001; |
|
53 | - const LEVEL_CONVERTER = 2002; |
|
54 | - const NDC_CONVERTER = 2003; |
|
55 | - const MESSAGE_CONVERTER = 2004; |
|
51 | + const RELATIVE_TIME_CONVERTER = 2000; |
|
52 | + const THREAD_CONVERTER = 2001; |
|
53 | + const LEVEL_CONVERTER = 2002; |
|
54 | + const NDC_CONVERTER = 2003; |
|
55 | + const MESSAGE_CONVERTER = 2004; |
|
56 | 56 | |
57 | - const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; |
|
58 | - const DATE_FORMAT_ABSOLUTE = 'H:i:s'; |
|
59 | - const DATE_FORMAT_DATE = 'd M Y H:i:s,u'; |
|
57 | + const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; |
|
58 | + const DATE_FORMAT_ABSOLUTE = 'H:i:s'; |
|
59 | + const DATE_FORMAT_DATE = 'd M Y H:i:s,u'; |
|
60 | 60 | |
61 | - private $state; |
|
62 | - private $currentLiteral; |
|
63 | - private $patternLength; |
|
64 | - private $i; |
|
61 | + private $state; |
|
62 | + private $currentLiteral; |
|
63 | + private $patternLength; |
|
64 | + private $i; |
|
65 | 65 | |
66 | - /** |
|
67 | - * @var LoggerPatternConverter |
|
68 | - */ |
|
69 | - private $head = null; |
|
66 | + /** |
|
67 | + * @var LoggerPatternConverter |
|
68 | + */ |
|
69 | + private $head = null; |
|
70 | 70 | |
71 | - /** |
|
72 | - * @var LoggerPatternConverter |
|
73 | - */ |
|
74 | - private $tail = null; |
|
71 | + /** |
|
72 | + * @var LoggerPatternConverter |
|
73 | + */ |
|
74 | + private $tail = null; |
|
75 | 75 | |
76 | - /** |
|
77 | - * @var LoggerFormattingInfo |
|
78 | - */ |
|
79 | - private $formattingInfo; |
|
76 | + /** |
|
77 | + * @var LoggerFormattingInfo |
|
78 | + */ |
|
79 | + private $formattingInfo; |
|
80 | 80 | |
81 | - /** |
|
82 | - * @var string pattern to parse |
|
83 | - */ |
|
84 | - private $pattern; |
|
81 | + /** |
|
82 | + * @var string pattern to parse |
|
83 | + */ |
|
84 | + private $pattern; |
|
85 | 85 | |
86 | - /** |
|
87 | - * Constructor |
|
88 | - * |
|
89 | - * @param string $pattern |
|
90 | - */ |
|
91 | - public function __construct($pattern) { |
|
92 | - $this->pattern = $pattern; |
|
93 | - $this->patternLength = strlen($pattern); |
|
94 | - $this->formattingInfo = new LoggerFormattingInfo(); |
|
95 | - $this->state = self::LITERAL_STATE; |
|
96 | - } |
|
86 | + /** |
|
87 | + * Constructor |
|
88 | + * |
|
89 | + * @param string $pattern |
|
90 | + */ |
|
91 | + public function __construct($pattern) { |
|
92 | + $this->pattern = $pattern; |
|
93 | + $this->patternLength = strlen($pattern); |
|
94 | + $this->formattingInfo = new LoggerFormattingInfo(); |
|
95 | + $this->state = self::LITERAL_STATE; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * @param LoggerPatternConverter $pc |
|
100 | - */ |
|
101 | - public function addToList($pc) { |
|
102 | - if($this->head == null) { |
|
103 | - $this->head = $pc; |
|
104 | - $this->tail = $this->head; |
|
105 | - } else { |
|
106 | - $this->tail->next = $pc; |
|
107 | - $this->tail = $this->tail->next; |
|
108 | - } |
|
109 | - } |
|
98 | + /** |
|
99 | + * @param LoggerPatternConverter $pc |
|
100 | + */ |
|
101 | + public function addToList($pc) { |
|
102 | + if($this->head == null) { |
|
103 | + $this->head = $pc; |
|
104 | + $this->tail = $this->head; |
|
105 | + } else { |
|
106 | + $this->tail->next = $pc; |
|
107 | + $this->tail = $this->tail->next; |
|
108 | + } |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function extractOption() { |
|
115 | - if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
116 | - $end = strpos($this->pattern, '}' , $this->i); |
|
117 | - if($end !== false) { |
|
118 | - $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
|
119 | - $this->i= $end + 1; |
|
120 | - return $r; |
|
121 | - } |
|
122 | - } |
|
123 | - return null; |
|
124 | - } |
|
111 | + /** |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function extractOption() { |
|
115 | + if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
116 | + $end = strpos($this->pattern, '}' , $this->i); |
|
117 | + if($end !== false) { |
|
118 | + $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
|
119 | + $this->i= $end + 1; |
|
120 | + return $r; |
|
121 | + } |
|
122 | + } |
|
123 | + return null; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * The option is expected to be in decimal and positive. In case of |
|
128 | - * error, zero is returned. |
|
129 | - */ |
|
130 | - public function extractPrecisionOption() { |
|
131 | - $opt = $this->extractOption(); |
|
132 | - $r = 0; |
|
133 | - if($opt !== null) { |
|
134 | - if(is_numeric($opt)) { |
|
135 | - $r = (int)$opt; |
|
136 | - if($r <= 0) { |
|
137 | - $r = 0; |
|
138 | - } |
|
139 | - } |
|
140 | - } |
|
141 | - return $r; |
|
142 | - } |
|
126 | + /** |
|
127 | + * The option is expected to be in decimal and positive. In case of |
|
128 | + * error, zero is returned. |
|
129 | + */ |
|
130 | + public function extractPrecisionOption() { |
|
131 | + $opt = $this->extractOption(); |
|
132 | + $r = 0; |
|
133 | + if($opt !== null) { |
|
134 | + if(is_numeric($opt)) { |
|
135 | + $r = (int)$opt; |
|
136 | + if($r <= 0) { |
|
137 | + $r = 0; |
|
138 | + } |
|
139 | + } |
|
140 | + } |
|
141 | + return $r; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | |
145 | - /** Parser. |
|
146 | - * |
|
147 | - * @return LoggerPatternConverter Returns $this->head. |
|
148 | - */ |
|
149 | - public function parse() { |
|
150 | - $c = ''; |
|
151 | - $this->i = 0; |
|
152 | - $this->currentLiteral = ''; |
|
153 | - while($this->i < $this->patternLength) { |
|
154 | - $c = $this->pattern{$this->i++}; |
|
145 | + /** Parser. |
|
146 | + * |
|
147 | + * @return LoggerPatternConverter Returns $this->head. |
|
148 | + */ |
|
149 | + public function parse() { |
|
150 | + $c = ''; |
|
151 | + $this->i = 0; |
|
152 | + $this->currentLiteral = ''; |
|
153 | + while($this->i < $this->patternLength) { |
|
154 | + $c = $this->pattern{$this->i++}; |
|
155 | 155 | |
156 | - switch($this->state) { |
|
157 | - case self::LITERAL_STATE: |
|
158 | - // In literal state, the last char is always a literal. |
|
159 | - if($this->i == $this->patternLength) { |
|
160 | - $this->currentLiteral .= $c; |
|
161 | - continue; |
|
162 | - } |
|
163 | - if($c == self::ESCAPE_CHAR) { |
|
164 | - // peek at the next char. |
|
165 | - switch($this->pattern{$this->i}) { |
|
166 | - case self::ESCAPE_CHAR: |
|
167 | - $this->currentLiteral .= $c; |
|
168 | - $this->i++; // move pointer |
|
169 | - break; |
|
170 | - case 'n': |
|
171 | - $this->currentLiteral .= PHP_EOL; |
|
172 | - $this->i++; // move pointer |
|
173 | - break; |
|
174 | - default: |
|
175 | - if(strlen($this->currentLiteral) != 0) { |
|
176 | - $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
177 | - } |
|
178 | - $this->currentLiteral = $c; |
|
179 | - $this->state = self::CONVERTER_STATE; |
|
180 | - $this->formattingInfo->reset(); |
|
181 | - } |
|
182 | - } else { |
|
183 | - $this->currentLiteral .= $c; |
|
184 | - } |
|
185 | - break; |
|
186 | - case self::CONVERTER_STATE: |
|
187 | - $this->currentLiteral .= $c; |
|
188 | - switch($c) { |
|
189 | - case '-': |
|
190 | - $this->formattingInfo->leftAlign = true; |
|
191 | - break; |
|
192 | - case '.': |
|
193 | - $this->state = self::DOT_STATE; |
|
194 | - break; |
|
195 | - default: |
|
196 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
197 | - $this->formattingInfo->min = ord($c) - ord('0'); |
|
198 | - $this->state = self::MIN_STATE; |
|
199 | - } else { |
|
200 | - $this->finalizeConverter($c); |
|
201 | - } |
|
202 | - } // switch |
|
203 | - break; |
|
204 | - case self::MIN_STATE: |
|
205 | - $this->currentLiteral .= $c; |
|
206 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
207 | - $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0')); |
|
208 | - } else if ($c == '.') { |
|
209 | - $this->state = self::DOT_STATE; |
|
210 | - } else { |
|
211 | - $this->finalizeConverter($c); |
|
212 | - } |
|
213 | - break; |
|
214 | - case self::DOT_STATE: |
|
215 | - $this->currentLiteral .= $c; |
|
216 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
217 | - $this->formattingInfo->max = ord($c) - ord('0'); |
|
218 | - $this->state = self::MAX_STATE; |
|
219 | - } else { |
|
220 | - $this->state = self::LITERAL_STATE; |
|
221 | - } |
|
222 | - break; |
|
223 | - case self::MAX_STATE: |
|
224 | - $this->currentLiteral .= $c; |
|
225 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
226 | - $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
|
227 | - } else { |
|
228 | - $this->finalizeConverter($c); |
|
229 | - $this->state = self::LITERAL_STATE; |
|
230 | - } |
|
231 | - break; |
|
232 | - } // switch |
|
233 | - } // while |
|
234 | - if(strlen($this->currentLiteral) != 0) { |
|
235 | - $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
236 | - } |
|
237 | - return $this->head; |
|
238 | - } |
|
156 | + switch($this->state) { |
|
157 | + case self::LITERAL_STATE: |
|
158 | + // In literal state, the last char is always a literal. |
|
159 | + if($this->i == $this->patternLength) { |
|
160 | + $this->currentLiteral .= $c; |
|
161 | + continue; |
|
162 | + } |
|
163 | + if($c == self::ESCAPE_CHAR) { |
|
164 | + // peek at the next char. |
|
165 | + switch($this->pattern{$this->i}) { |
|
166 | + case self::ESCAPE_CHAR: |
|
167 | + $this->currentLiteral .= $c; |
|
168 | + $this->i++; // move pointer |
|
169 | + break; |
|
170 | + case 'n': |
|
171 | + $this->currentLiteral .= PHP_EOL; |
|
172 | + $this->i++; // move pointer |
|
173 | + break; |
|
174 | + default: |
|
175 | + if(strlen($this->currentLiteral) != 0) { |
|
176 | + $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
177 | + } |
|
178 | + $this->currentLiteral = $c; |
|
179 | + $this->state = self::CONVERTER_STATE; |
|
180 | + $this->formattingInfo->reset(); |
|
181 | + } |
|
182 | + } else { |
|
183 | + $this->currentLiteral .= $c; |
|
184 | + } |
|
185 | + break; |
|
186 | + case self::CONVERTER_STATE: |
|
187 | + $this->currentLiteral .= $c; |
|
188 | + switch($c) { |
|
189 | + case '-': |
|
190 | + $this->formattingInfo->leftAlign = true; |
|
191 | + break; |
|
192 | + case '.': |
|
193 | + $this->state = self::DOT_STATE; |
|
194 | + break; |
|
195 | + default: |
|
196 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
197 | + $this->formattingInfo->min = ord($c) - ord('0'); |
|
198 | + $this->state = self::MIN_STATE; |
|
199 | + } else { |
|
200 | + $this->finalizeConverter($c); |
|
201 | + } |
|
202 | + } // switch |
|
203 | + break; |
|
204 | + case self::MIN_STATE: |
|
205 | + $this->currentLiteral .= $c; |
|
206 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
207 | + $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0')); |
|
208 | + } else if ($c == '.') { |
|
209 | + $this->state = self::DOT_STATE; |
|
210 | + } else { |
|
211 | + $this->finalizeConverter($c); |
|
212 | + } |
|
213 | + break; |
|
214 | + case self::DOT_STATE: |
|
215 | + $this->currentLiteral .= $c; |
|
216 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
217 | + $this->formattingInfo->max = ord($c) - ord('0'); |
|
218 | + $this->state = self::MAX_STATE; |
|
219 | + } else { |
|
220 | + $this->state = self::LITERAL_STATE; |
|
221 | + } |
|
222 | + break; |
|
223 | + case self::MAX_STATE: |
|
224 | + $this->currentLiteral .= $c; |
|
225 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
226 | + $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
|
227 | + } else { |
|
228 | + $this->finalizeConverter($c); |
|
229 | + $this->state = self::LITERAL_STATE; |
|
230 | + } |
|
231 | + break; |
|
232 | + } // switch |
|
233 | + } // while |
|
234 | + if(strlen($this->currentLiteral) != 0) { |
|
235 | + $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
|
236 | + } |
|
237 | + return $this->head; |
|
238 | + } |
|
239 | 239 | |
240 | - public function finalizeConverter($c) { |
|
241 | - $pc = null; |
|
242 | - switch($c) { |
|
243 | - case 'c': |
|
244 | - $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
245 | - $this->currentLiteral = ''; |
|
246 | - break; |
|
247 | - case 'C': |
|
248 | - $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
249 | - $this->currentLiteral = ''; |
|
250 | - break; |
|
251 | - case 'd': |
|
252 | - $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
|
253 | - $dOpt = $this->extractOption(); |
|
240 | + public function finalizeConverter($c) { |
|
241 | + $pc = null; |
|
242 | + switch($c) { |
|
243 | + case 'c': |
|
244 | + $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
245 | + $this->currentLiteral = ''; |
|
246 | + break; |
|
247 | + case 'C': |
|
248 | + $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
|
249 | + $this->currentLiteral = ''; |
|
250 | + break; |
|
251 | + case 'd': |
|
252 | + $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
|
253 | + $dOpt = $this->extractOption(); |
|
254 | 254 | |
255 | - if($dOpt !== null) |
|
256 | - $dateFormatStr = $dOpt; |
|
255 | + if($dOpt !== null) |
|
256 | + $dateFormatStr = $dOpt; |
|
257 | 257 | |
258 | - if($dateFormatStr == 'ISO8601') { |
|
259 | - $df = self::DATE_FORMAT_ISO8601; |
|
260 | - } else if($dateFormatStr == 'ABSOLUTE') { |
|
261 | - $df = self::DATE_FORMAT_ABSOLUTE; |
|
262 | - } else if($dateFormatStr == 'DATE') { |
|
263 | - $df = self::DATE_FORMAT_DATE; |
|
264 | - } else { |
|
265 | - $df = $dateFormatStr; |
|
266 | - if($df == null) { |
|
267 | - $df = self::DATE_FORMAT_ISO8601; |
|
268 | - } |
|
269 | - } |
|
270 | - $pc = new LoggerDatePatternConverter($this->formattingInfo, $df); |
|
271 | - $this->currentLiteral = ''; |
|
272 | - break; |
|
273 | - case 'F': |
|
274 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER); |
|
275 | - $this->currentLiteral = ''; |
|
276 | - break; |
|
277 | - case 'l': |
|
278 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER); |
|
279 | - $this->currentLiteral = ''; |
|
280 | - break; |
|
281 | - case 'L': |
|
282 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER); |
|
283 | - $this->currentLiteral = ''; |
|
284 | - break; |
|
285 | - case 'm': |
|
286 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER); |
|
287 | - $this->currentLiteral = ''; |
|
288 | - break; |
|
289 | - case 'M': |
|
290 | - $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER); |
|
291 | - $this->currentLiteral = ''; |
|
292 | - break; |
|
293 | - case 'p': |
|
294 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER); |
|
295 | - $this->currentLiteral = ''; |
|
296 | - break; |
|
297 | - case 'r': |
|
298 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER); |
|
299 | - $this->currentLiteral = ''; |
|
300 | - break; |
|
301 | - case 't': |
|
302 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER); |
|
303 | - $this->currentLiteral = ''; |
|
304 | - break; |
|
305 | - case 'u': |
|
306 | - if($this->i < $this->patternLength) { |
|
307 | - $cNext = $this->pattern{$this->i}; |
|
308 | - if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
309 | - $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
310 | - $this->currentLiteral = ''; |
|
311 | - $this->i++; |
|
312 | - } |
|
313 | - } |
|
314 | - break; |
|
315 | - case 'x': |
|
316 | - $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER); |
|
317 | - $this->currentLiteral = ''; |
|
318 | - break; |
|
319 | - case 'X': |
|
320 | - $xOpt = $this->extractOption(); |
|
321 | - $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt); |
|
322 | - $this->currentLiteral = ''; |
|
323 | - break; |
|
324 | - default: |
|
325 | - $pc = new LoggerLiteralPatternConverter($this->currentLiteral); |
|
326 | - $this->currentLiteral = ''; |
|
327 | - } |
|
328 | - $this->addConverter($pc); |
|
329 | - } |
|
258 | + if($dateFormatStr == 'ISO8601') { |
|
259 | + $df = self::DATE_FORMAT_ISO8601; |
|
260 | + } else if($dateFormatStr == 'ABSOLUTE') { |
|
261 | + $df = self::DATE_FORMAT_ABSOLUTE; |
|
262 | + } else if($dateFormatStr == 'DATE') { |
|
263 | + $df = self::DATE_FORMAT_DATE; |
|
264 | + } else { |
|
265 | + $df = $dateFormatStr; |
|
266 | + if($df == null) { |
|
267 | + $df = self::DATE_FORMAT_ISO8601; |
|
268 | + } |
|
269 | + } |
|
270 | + $pc = new LoggerDatePatternConverter($this->formattingInfo, $df); |
|
271 | + $this->currentLiteral = ''; |
|
272 | + break; |
|
273 | + case 'F': |
|
274 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER); |
|
275 | + $this->currentLiteral = ''; |
|
276 | + break; |
|
277 | + case 'l': |
|
278 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER); |
|
279 | + $this->currentLiteral = ''; |
|
280 | + break; |
|
281 | + case 'L': |
|
282 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER); |
|
283 | + $this->currentLiteral = ''; |
|
284 | + break; |
|
285 | + case 'm': |
|
286 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER); |
|
287 | + $this->currentLiteral = ''; |
|
288 | + break; |
|
289 | + case 'M': |
|
290 | + $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER); |
|
291 | + $this->currentLiteral = ''; |
|
292 | + break; |
|
293 | + case 'p': |
|
294 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER); |
|
295 | + $this->currentLiteral = ''; |
|
296 | + break; |
|
297 | + case 'r': |
|
298 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER); |
|
299 | + $this->currentLiteral = ''; |
|
300 | + break; |
|
301 | + case 't': |
|
302 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER); |
|
303 | + $this->currentLiteral = ''; |
|
304 | + break; |
|
305 | + case 'u': |
|
306 | + if($this->i < $this->patternLength) { |
|
307 | + $cNext = $this->pattern{$this->i}; |
|
308 | + if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
309 | + $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
310 | + $this->currentLiteral = ''; |
|
311 | + $this->i++; |
|
312 | + } |
|
313 | + } |
|
314 | + break; |
|
315 | + case 'x': |
|
316 | + $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER); |
|
317 | + $this->currentLiteral = ''; |
|
318 | + break; |
|
319 | + case 'X': |
|
320 | + $xOpt = $this->extractOption(); |
|
321 | + $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt); |
|
322 | + $this->currentLiteral = ''; |
|
323 | + break; |
|
324 | + default: |
|
325 | + $pc = new LoggerLiteralPatternConverter($this->currentLiteral); |
|
326 | + $this->currentLiteral = ''; |
|
327 | + } |
|
328 | + $this->addConverter($pc); |
|
329 | + } |
|
330 | 330 | |
331 | - public function addConverter($pc) { |
|
332 | - $this->currentLiteral = ''; |
|
333 | - // Add the pattern converter to the list. |
|
334 | - $this->addToList($pc); |
|
335 | - // Next pattern is assumed to be a literal. |
|
336 | - $this->state = self::LITERAL_STATE; |
|
337 | - // Reset formatting info |
|
338 | - $this->formattingInfo->reset(); |
|
339 | - } |
|
331 | + public function addConverter($pc) { |
|
332 | + $this->currentLiteral = ''; |
|
333 | + // Add the pattern converter to the list. |
|
334 | + $this->addToList($pc); |
|
335 | + // Next pattern is assumed to be a literal. |
|
336 | + $this->state = self::LITERAL_STATE; |
|
337 | + // Reset formatting info |
|
338 | + $this->formattingInfo->reset(); |
|
339 | + } |
|
340 | 340 | } |
341 | 341 |
@@ -24,27 +24,27 @@ |
||
24 | 24 | */ |
25 | 25 | class LoggerMDCPatternConverter extends LoggerPatternConverter { |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - private $key; |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + private $key; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor |
|
34 | - * |
|
35 | - * @param string $formattingInfo |
|
36 | - * @param string $key |
|
37 | - */ |
|
38 | - public function __construct($formattingInfo, $key) { |
|
39 | - parent::__construct($formattingInfo); |
|
40 | - $this->key = $key; |
|
41 | - } |
|
32 | + /** |
|
33 | + * Constructor |
|
34 | + * |
|
35 | + * @param string $formattingInfo |
|
36 | + * @param string $key |
|
37 | + */ |
|
38 | + public function __construct($formattingInfo, $key) { |
|
39 | + parent::__construct($formattingInfo); |
|
40 | + $this->key = $key; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param LoggerLoggingEvent $event |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function convert($event) { |
|
48 | - return $event->getMDC($this->key); |
|
49 | - } |
|
43 | + /** |
|
44 | + * @param LoggerLoggingEvent $event |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function convert($event) { |
|
48 | + return $event->getMDC($this->key); |
|
49 | + } |
|
50 | 50 | } |
@@ -28,23 +28,23 @@ |
||
28 | 28 | */ |
29 | 29 | class LoggerFormattingInfo { |
30 | 30 | |
31 | - public $min = -1; |
|
32 | - public $max = 0x7FFFFFFF; |
|
33 | - public $leftAlign = false; |
|
31 | + public $min = -1; |
|
32 | + public $max = 0x7FFFFFFF; |
|
33 | + public $leftAlign = false; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Constructor |
|
37 | - */ |
|
38 | - public function __construct() {} |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + */ |
|
38 | + public function __construct() {} |
|
39 | 39 | |
40 | - public function reset() { |
|
41 | - $this->min = -1; |
|
42 | - $this->max = 0x7FFFFFFF; |
|
43 | - $this->leftAlign = false; |
|
44 | - } |
|
40 | + public function reset() { |
|
41 | + $this->min = -1; |
|
42 | + $this->max = 0x7FFFFFFF; |
|
43 | + $this->leftAlign = false; |
|
44 | + } |
|
45 | 45 | |
46 | - public function dump() { |
|
47 | - // TODO: other option to dump? |
|
48 | - // LoggerLog::debug("LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}"); |
|
49 | - } |
|
46 | + public function dump() { |
|
47 | + // TODO: other option to dump? |
|
48 | + // LoggerLog::debug("LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}"); |
|
49 | + } |
|
50 | 50 | } |
@@ -26,85 +26,85 @@ |
||
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 | } |
@@ -26,334 +26,334 @@ |
||
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 |