@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | /** |
241 | 241 | * Log a message object with the ERROR level including the caller. |
242 | 242 | * |
243 | - * @param mixed $message message |
|
243 | + * @param string $message message |
|
244 | 244 | * @param mixed $caller caller object or caller string id |
245 | 245 | */ |
246 | 246 | public function error($message, $caller = null) { |
@@ -286,6 +286,7 @@ discard block |
||
286 | 286 | * Check whether this category is enabled for a given Level passed as parameter. |
287 | 287 | * |
288 | 288 | * @param LoggerLevel level |
289 | + * @param LoggerLevel $level |
|
289 | 290 | * @return boolean |
290 | 291 | */ |
291 | 292 | public function isEnabledFor($level) { |
@@ -326,6 +327,9 @@ discard block |
||
326 | 327 | } |
327 | 328 | } |
328 | 329 | |
330 | + /** |
|
331 | + * @param LoggerLevel $level |
|
332 | + */ |
|
329 | 333 | private function logLevel($message, $level, $caller = null) { |
330 | 334 | if($level->isGreaterOrEqual($this->getEffectiveLevel())) { |
331 | 335 | $this->forcedLog($this->fqcn, $caller, $level, $message); |
@@ -338,7 +342,6 @@ discard block |
||
338 | 342 | * Get a Logger by name (Delegate to {@link Logger}) |
339 | 343 | * |
340 | 344 | * @param string $name logger name |
341 | - * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
342 | 345 | * @return Logger |
343 | 346 | * @static |
344 | 347 | */ |
@@ -474,7 +477,7 @@ discard block |
||
474 | 477 | * Clears all logger definitions |
475 | 478 | * |
476 | 479 | * @static |
477 | - * @return boolean |
|
480 | + * @return boolean|null |
|
478 | 481 | */ |
479 | 482 | public static function clear() { |
480 | 483 | return self::getHierarchy()->clear(); |
@@ -484,7 +487,7 @@ discard block |
||
484 | 487 | * Destroy configurations for logger definitions |
485 | 488 | * |
486 | 489 | * @static |
487 | - * @return boolean |
|
490 | + * @return boolean|null |
|
488 | 491 | */ |
489 | 492 | public static function resetConfiguration() { |
490 | 493 | $result = self::getHierarchy()->resetConfiguration(); |
@@ -592,7 +595,7 @@ discard block |
||
592 | 595 | |
593 | 596 | /** |
594 | 597 | * Returns the current configurator |
595 | - * @return the configurator |
|
598 | + * @return string configurator |
|
596 | 599 | */ |
597 | 600 | public static function getConfigurationClass() { |
598 | 601 | return self::$configurationClass; |
@@ -600,7 +603,7 @@ discard block |
||
600 | 603 | |
601 | 604 | /** |
602 | 605 | * Returns the current configuration file |
603 | - * @return the configuration file |
|
606 | + * @return null|string configuration file |
|
604 | 607 | */ |
605 | 608 | public static function getConfigurationFile() { |
606 | 609 | return self::$configurationFile; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @version SVN: $Id: Logger.php 824193 2009-10-11 22:51:24Z chammers $ |
44 | 44 | * @link http://logging.apache.org/log4php |
45 | 45 | */ |
46 | - /* |
|
46 | + /* |
|
47 | 47 | * TODO: |
48 | 48 | * Localization: setResourceBundle($bundle) : not supported |
49 | 49 | * Localization: getResourceBundle: not supported |
@@ -51,576 +51,576 @@ discard block |
||
51 | 51 | * Localization: l7dlog($priority, $key, $params, $t) : not supported |
52 | 52 | */ |
53 | 53 | class Logger { |
54 | - private static $_classes = array( |
|
55 | - 'LoggerException' => '/LoggerException.php', |
|
56 | - 'LoggerHierarchy' => '/LoggerHierarchy.php', |
|
57 | - 'LoggerLayout' => '/LoggerLayout.php', |
|
58 | - 'LoggerLevel' => '/LoggerLevel.php', |
|
59 | - 'LoggerMDC' => '/LoggerMDC.php', |
|
60 | - 'LoggerNDC' => '/LoggerNDC.php', |
|
61 | - 'LoggerReflectionUtils' => '/LoggerReflectionUtils.php', |
|
62 | - 'LoggerConfigurator' => '/LoggerConfigurator.php', |
|
63 | - 'LoggerConfiguratorBasic' => '/configurators/LoggerConfiguratorBasic.php', |
|
64 | - 'LoggerConfiguratorIni' => '/configurators/LoggerConfiguratorIni.php', |
|
65 | - 'LoggerConfiguratorPhp' => '/configurators/LoggerConfiguratorPhp.php', |
|
66 | - 'LoggerConfiguratorXml' => '/configurators/LoggerConfiguratorXml.php', |
|
67 | - 'LoggerRoot' => '/LoggerRoot.php', |
|
68 | - 'LoggerAppender' => '/LoggerAppender.php', |
|
69 | - 'LoggerAppenderPool' => '/LoggerAppenderPool.php', |
|
70 | - 'LoggerAppenderAdodb' => '/appenders/LoggerAppenderAdodb.php', |
|
71 | - 'LoggerAppenderPDO' => '/appenders/LoggerAppenderPDO.php', |
|
72 | - 'LoggerAppenderConsole' => '/appenders/LoggerAppenderConsole.php', |
|
73 | - 'LoggerAppenderDailyFile' => '/appenders/LoggerAppenderDailyFile.php', |
|
74 | - 'LoggerAppenderEcho' => '/appenders/LoggerAppenderEcho.php', |
|
75 | - 'LoggerAppenderFile' => '/appenders/LoggerAppenderFile.php', |
|
76 | - 'LoggerAppenderMail' => '/appenders/LoggerAppenderMail.php', |
|
77 | - 'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php', |
|
78 | - 'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php', |
|
79 | - 'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php', |
|
80 | - 'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php', |
|
81 | - 'LoggerAppenderSocket' => '/appenders/LoggerAppenderSocket.php', |
|
82 | - 'LoggerAppenderSyslog' => '/appenders/LoggerAppenderSyslog.php', |
|
83 | - 'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php', |
|
84 | - 'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php', |
|
85 | - 'LoggerPatternConverter' => '/helpers/LoggerPatternConverter.php', |
|
86 | - 'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php', |
|
87 | - 'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php', |
|
88 | - 'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php', |
|
89 | - 'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php', |
|
90 | - 'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php', |
|
91 | - 'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php', |
|
92 | - 'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php', |
|
93 | - 'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php', |
|
94 | - 'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php', |
|
95 | - 'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php', |
|
96 | - 'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php', |
|
97 | - 'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php', |
|
98 | - 'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php', |
|
99 | - 'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php', |
|
100 | - 'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php', |
|
101 | - 'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php', |
|
102 | - 'LoggerPatternParser' => '/helpers/LoggerPatternParser.php', |
|
103 | - 'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php', |
|
104 | - 'LoggerLayoutSimple' => '/layouts/LoggerLayoutSimple.php', |
|
105 | - 'LoggerLayoutTTCC' => '/layouts/LoggerLayoutTTCC.php', |
|
106 | - 'LoggerLayoutPattern' => '/layouts/LoggerLayoutPattern.php', |
|
107 | - 'LoggerLayoutXml' => '/layouts/LoggerLayoutXml.php', |
|
108 | - 'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php', |
|
109 | - 'LoggerRendererObject' => '/renderers/LoggerRendererObject.php', |
|
110 | - 'LoggerRendererMap' => '/renderers/LoggerRendererMap.php', |
|
111 | - 'LoggerLocationInfo' => '/LoggerLocationInfo.php', |
|
112 | - 'LoggerLoggingEvent' => '/LoggerLoggingEvent.php', |
|
113 | - 'LoggerFilter' => '/LoggerFilter.php', |
|
114 | - 'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php', |
|
115 | - 'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php', |
|
116 | - 'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php', |
|
117 | - 'LoggerFilterStringMatch' => '/filters/LoggerFilterStringMatch.php', |
|
118 | - ); |
|
54 | + private static $_classes = array( |
|
55 | + 'LoggerException' => '/LoggerException.php', |
|
56 | + 'LoggerHierarchy' => '/LoggerHierarchy.php', |
|
57 | + 'LoggerLayout' => '/LoggerLayout.php', |
|
58 | + 'LoggerLevel' => '/LoggerLevel.php', |
|
59 | + 'LoggerMDC' => '/LoggerMDC.php', |
|
60 | + 'LoggerNDC' => '/LoggerNDC.php', |
|
61 | + 'LoggerReflectionUtils' => '/LoggerReflectionUtils.php', |
|
62 | + 'LoggerConfigurator' => '/LoggerConfigurator.php', |
|
63 | + 'LoggerConfiguratorBasic' => '/configurators/LoggerConfiguratorBasic.php', |
|
64 | + 'LoggerConfiguratorIni' => '/configurators/LoggerConfiguratorIni.php', |
|
65 | + 'LoggerConfiguratorPhp' => '/configurators/LoggerConfiguratorPhp.php', |
|
66 | + 'LoggerConfiguratorXml' => '/configurators/LoggerConfiguratorXml.php', |
|
67 | + 'LoggerRoot' => '/LoggerRoot.php', |
|
68 | + 'LoggerAppender' => '/LoggerAppender.php', |
|
69 | + 'LoggerAppenderPool' => '/LoggerAppenderPool.php', |
|
70 | + 'LoggerAppenderAdodb' => '/appenders/LoggerAppenderAdodb.php', |
|
71 | + 'LoggerAppenderPDO' => '/appenders/LoggerAppenderPDO.php', |
|
72 | + 'LoggerAppenderConsole' => '/appenders/LoggerAppenderConsole.php', |
|
73 | + 'LoggerAppenderDailyFile' => '/appenders/LoggerAppenderDailyFile.php', |
|
74 | + 'LoggerAppenderEcho' => '/appenders/LoggerAppenderEcho.php', |
|
75 | + 'LoggerAppenderFile' => '/appenders/LoggerAppenderFile.php', |
|
76 | + 'LoggerAppenderMail' => '/appenders/LoggerAppenderMail.php', |
|
77 | + 'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php', |
|
78 | + 'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php', |
|
79 | + 'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php', |
|
80 | + 'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php', |
|
81 | + 'LoggerAppenderSocket' => '/appenders/LoggerAppenderSocket.php', |
|
82 | + 'LoggerAppenderSyslog' => '/appenders/LoggerAppenderSyslog.php', |
|
83 | + 'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php', |
|
84 | + 'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php', |
|
85 | + 'LoggerPatternConverter' => '/helpers/LoggerPatternConverter.php', |
|
86 | + 'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php', |
|
87 | + 'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php', |
|
88 | + 'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php', |
|
89 | + 'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php', |
|
90 | + 'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php', |
|
91 | + 'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php', |
|
92 | + 'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php', |
|
93 | + 'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php', |
|
94 | + 'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php', |
|
95 | + 'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php', |
|
96 | + 'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php', |
|
97 | + 'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php', |
|
98 | + 'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php', |
|
99 | + 'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php', |
|
100 | + 'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php', |
|
101 | + 'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php', |
|
102 | + 'LoggerPatternParser' => '/helpers/LoggerPatternParser.php', |
|
103 | + 'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php', |
|
104 | + 'LoggerLayoutSimple' => '/layouts/LoggerLayoutSimple.php', |
|
105 | + 'LoggerLayoutTTCC' => '/layouts/LoggerLayoutTTCC.php', |
|
106 | + 'LoggerLayoutPattern' => '/layouts/LoggerLayoutPattern.php', |
|
107 | + 'LoggerLayoutXml' => '/layouts/LoggerLayoutXml.php', |
|
108 | + 'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php', |
|
109 | + 'LoggerRendererObject' => '/renderers/LoggerRendererObject.php', |
|
110 | + 'LoggerRendererMap' => '/renderers/LoggerRendererMap.php', |
|
111 | + 'LoggerLocationInfo' => '/LoggerLocationInfo.php', |
|
112 | + 'LoggerLoggingEvent' => '/LoggerLoggingEvent.php', |
|
113 | + 'LoggerFilter' => '/LoggerFilter.php', |
|
114 | + 'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php', |
|
115 | + 'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php', |
|
116 | + 'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php', |
|
117 | + 'LoggerFilterStringMatch' => '/filters/LoggerFilterStringMatch.php', |
|
118 | + ); |
|
119 | 119 | |
120 | - /** |
|
121 | - * Class autoloader |
|
122 | - * This method is provided to be invoked within an __autoload() magic method. |
|
123 | - * @param string class name |
|
124 | - */ |
|
125 | - public static function autoload($className) { |
|
126 | - if(isset(self::$_classes[$className])) { |
|
127 | - include LOG4PHP_DIR.self::$_classes[$className]; |
|
128 | - } |
|
129 | - } |
|
120 | + /** |
|
121 | + * Class autoloader |
|
122 | + * This method is provided to be invoked within an __autoload() magic method. |
|
123 | + * @param string class name |
|
124 | + */ |
|
125 | + public static function autoload($className) { |
|
126 | + if(isset(self::$_classes[$className])) { |
|
127 | + include LOG4PHP_DIR.self::$_classes[$className]; |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * Additivity is set to true by default, that is children inherit the |
|
133 | - * appenders of their ancestors by default. |
|
134 | - * @var boolean |
|
135 | - */ |
|
136 | - private $additive = true; |
|
137 | - |
|
138 | - /** @var string fully qualified class name */ |
|
139 | - private $fqcn = 'Logger'; |
|
131 | + /** |
|
132 | + * Additivity is set to true by default, that is children inherit the |
|
133 | + * appenders of their ancestors by default. |
|
134 | + * @var boolean |
|
135 | + */ |
|
136 | + private $additive = true; |
|
137 | + |
|
138 | + /** @var string fully qualified class name */ |
|
139 | + private $fqcn = 'Logger'; |
|
140 | 140 | |
141 | - /** @var LoggerLevel The assigned level of this category. */ |
|
142 | - private $level = null; |
|
141 | + /** @var LoggerLevel The assigned level of this category. */ |
|
142 | + private $level = null; |
|
143 | 143 | |
144 | - /** @var string name of this category. */ |
|
145 | - private $name = ''; |
|
144 | + /** @var string name of this category. */ |
|
145 | + private $name = ''; |
|
146 | 146 | |
147 | - /** @var Logger The parent of this category. Null if this is the root logger*/ |
|
148 | - private $parent = null; |
|
147 | + /** @var Logger The parent of this category. Null if this is the root logger*/ |
|
148 | + private $parent = null; |
|
149 | 149 | |
150 | - /** |
|
151 | - * @var array collection of appenders |
|
152 | - * @see LoggerAppender |
|
153 | - */ |
|
154 | - private $aai = array(); |
|
150 | + /** |
|
151 | + * @var array collection of appenders |
|
152 | + * @see LoggerAppender |
|
153 | + */ |
|
154 | + private $aai = array(); |
|
155 | 155 | |
156 | - /** the hierarchy used by log4php */ |
|
157 | - private static $hierarchy; |
|
158 | - |
|
159 | - /** the configurator class name */ |
|
160 | - private static $configurationClass = 'LoggerConfiguratorBasic'; |
|
161 | - |
|
162 | - /** the path to the configuration file */ |
|
163 | - private static $configurationFile = null; |
|
164 | - |
|
165 | - /** inidicates if log4php has already been initialized */ |
|
166 | - private static $initialized = false; |
|
167 | - |
|
168 | - /** |
|
169 | - * Constructor. |
|
170 | - * @param string $name Category name |
|
171 | - */ |
|
172 | - public function __construct($name) { |
|
173 | - $this->name = $name; |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Return the category name. |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function getName() { |
|
181 | - return $this->name; |
|
182 | - } |
|
156 | + /** the hierarchy used by log4php */ |
|
157 | + private static $hierarchy; |
|
158 | + |
|
159 | + /** the configurator class name */ |
|
160 | + private static $configurationClass = 'LoggerConfiguratorBasic'; |
|
161 | + |
|
162 | + /** the path to the configuration file */ |
|
163 | + private static $configurationFile = null; |
|
164 | + |
|
165 | + /** inidicates if log4php has already been initialized */ |
|
166 | + private static $initialized = false; |
|
167 | + |
|
168 | + /** |
|
169 | + * Constructor. |
|
170 | + * @param string $name Category name |
|
171 | + */ |
|
172 | + public function __construct($name) { |
|
173 | + $this->name = $name; |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Return the category name. |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function getName() { |
|
181 | + return $this->name; |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * Returns the parent of this category. |
|
186 | - * @return Logger |
|
187 | - */ |
|
188 | - public function getParent() { |
|
189 | - return $this->parent; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Returns the hierarchy used by this Logger. |
|
194 | - * Caution: do not use this hierarchy unless you have called initialize(). |
|
195 | - * To get Loggers, use the Logger::getLogger and Logger::getRootLogger methods |
|
196 | - * instead of operating on on the hierarchy directly. |
|
197 | - * |
|
198 | - * @deprecated - will be moved to private |
|
199 | - * @return LoggerHierarchy |
|
200 | - */ |
|
201 | - public static function getHierarchy() { |
|
202 | - if(!isset(self::$hierarchy)) { |
|
203 | - self::$hierarchy = new LoggerHierarchy(new LoggerRoot()); |
|
204 | - } |
|
205 | - return self::$hierarchy; |
|
206 | - } |
|
207 | - |
|
208 | - /* Logging methods */ |
|
209 | - /** |
|
210 | - * Log a message object with the DEBUG level including the caller. |
|
211 | - * |
|
212 | - * @param mixed $message message |
|
213 | - * @param mixed $caller caller object or caller string id |
|
214 | - */ |
|
215 | - public function debug($message, $caller = null) { |
|
216 | - $this->logLevel($message, LoggerLevel::getLevelDebug(), $caller); |
|
217 | - } |
|
184 | + /** |
|
185 | + * Returns the parent of this category. |
|
186 | + * @return Logger |
|
187 | + */ |
|
188 | + public function getParent() { |
|
189 | + return $this->parent; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Returns the hierarchy used by this Logger. |
|
194 | + * Caution: do not use this hierarchy unless you have called initialize(). |
|
195 | + * To get Loggers, use the Logger::getLogger and Logger::getRootLogger methods |
|
196 | + * instead of operating on on the hierarchy directly. |
|
197 | + * |
|
198 | + * @deprecated - will be moved to private |
|
199 | + * @return LoggerHierarchy |
|
200 | + */ |
|
201 | + public static function getHierarchy() { |
|
202 | + if(!isset(self::$hierarchy)) { |
|
203 | + self::$hierarchy = new LoggerHierarchy(new LoggerRoot()); |
|
204 | + } |
|
205 | + return self::$hierarchy; |
|
206 | + } |
|
207 | + |
|
208 | + /* Logging methods */ |
|
209 | + /** |
|
210 | + * Log a message object with the DEBUG level including the caller. |
|
211 | + * |
|
212 | + * @param mixed $message message |
|
213 | + * @param mixed $caller caller object or caller string id |
|
214 | + */ |
|
215 | + public function debug($message, $caller = null) { |
|
216 | + $this->logLevel($message, LoggerLevel::getLevelDebug(), $caller); |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | - /** |
|
221 | - * Log a message object with the INFO Level. |
|
222 | - * |
|
223 | - * @param mixed $message message |
|
224 | - * @param mixed $caller caller object or caller string id |
|
225 | - */ |
|
226 | - public function info($message, $caller = null) { |
|
227 | - $this->logLevel($message, LoggerLevel::getLevelInfo(), $caller); |
|
228 | - } |
|
220 | + /** |
|
221 | + * Log a message object with the INFO Level. |
|
222 | + * |
|
223 | + * @param mixed $message message |
|
224 | + * @param mixed $caller caller object or caller string id |
|
225 | + */ |
|
226 | + public function info($message, $caller = null) { |
|
227 | + $this->logLevel($message, LoggerLevel::getLevelInfo(), $caller); |
|
228 | + } |
|
229 | 229 | |
230 | - /** |
|
231 | - * Log a message with the WARN level. |
|
232 | - * |
|
233 | - * @param mixed $message message |
|
234 | - * @param mixed $caller caller object or caller string id |
|
235 | - */ |
|
236 | - public function warn($message, $caller = null) { |
|
237 | - $this->logLevel($message, LoggerLevel::getLevelWarn(), $caller); |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * Log a message object with the ERROR level including the caller. |
|
242 | - * |
|
243 | - * @param mixed $message message |
|
244 | - * @param mixed $caller caller object or caller string id |
|
245 | - */ |
|
246 | - public function error($message, $caller = null) { |
|
247 | - $this->logLevel($message, LoggerLevel::getLevelError(), $caller); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Log a message object with the FATAL level including the caller. |
|
252 | - * |
|
253 | - * @param mixed $message message |
|
254 | - * @param mixed $caller caller object or caller string id |
|
255 | - */ |
|
256 | - public function fatal($message, $caller = null) { |
|
257 | - $this->logLevel($message, LoggerLevel::getLevelFatal(), $caller); |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * This method creates a new logging event and logs the event without further checks. |
|
262 | - * |
|
263 | - * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()}, |
|
264 | - * {@link error()} and {@link fatal()} wrappers. |
|
265 | - * |
|
266 | - * @param string $fqcn Fully Qualified Class Name of the Logger |
|
267 | - * @param mixed $caller caller object or caller string id |
|
268 | - * @param LoggerLevel $level log level |
|
269 | - * @param mixed $message message |
|
270 | - * @see LoggerLoggingEvent |
|
271 | - */ |
|
272 | - public function forcedLog($fqcn, $caller, $level, $message) { |
|
273 | - $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message)); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * Check whether this category is enabled for the DEBUG Level. |
|
279 | - * @return boolean |
|
280 | - */ |
|
281 | - public function isDebugEnabled() { |
|
282 | - return $this->isEnabledFor(LoggerLevel::getLevelDebug()); |
|
283 | - } |
|
230 | + /** |
|
231 | + * Log a message with the WARN level. |
|
232 | + * |
|
233 | + * @param mixed $message message |
|
234 | + * @param mixed $caller caller object or caller string id |
|
235 | + */ |
|
236 | + public function warn($message, $caller = null) { |
|
237 | + $this->logLevel($message, LoggerLevel::getLevelWarn(), $caller); |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * Log a message object with the ERROR level including the caller. |
|
242 | + * |
|
243 | + * @param mixed $message message |
|
244 | + * @param mixed $caller caller object or caller string id |
|
245 | + */ |
|
246 | + public function error($message, $caller = null) { |
|
247 | + $this->logLevel($message, LoggerLevel::getLevelError(), $caller); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Log a message object with the FATAL level including the caller. |
|
252 | + * |
|
253 | + * @param mixed $message message |
|
254 | + * @param mixed $caller caller object or caller string id |
|
255 | + */ |
|
256 | + public function fatal($message, $caller = null) { |
|
257 | + $this->logLevel($message, LoggerLevel::getLevelFatal(), $caller); |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * This method creates a new logging event and logs the event without further checks. |
|
262 | + * |
|
263 | + * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()}, |
|
264 | + * {@link error()} and {@link fatal()} wrappers. |
|
265 | + * |
|
266 | + * @param string $fqcn Fully Qualified Class Name of the Logger |
|
267 | + * @param mixed $caller caller object or caller string id |
|
268 | + * @param LoggerLevel $level log level |
|
269 | + * @param mixed $message message |
|
270 | + * @see LoggerLoggingEvent |
|
271 | + */ |
|
272 | + public function forcedLog($fqcn, $caller, $level, $message) { |
|
273 | + $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message)); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * Check whether this category is enabled for the DEBUG Level. |
|
279 | + * @return boolean |
|
280 | + */ |
|
281 | + public function isDebugEnabled() { |
|
282 | + return $this->isEnabledFor(LoggerLevel::getLevelDebug()); |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * Check whether this category is enabled for a given Level passed as parameter. |
|
287 | - * |
|
288 | - * @param LoggerLevel level |
|
289 | - * @return boolean |
|
290 | - */ |
|
291 | - public function isEnabledFor($level) { |
|
292 | - return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
293 | - } |
|
285 | + /** |
|
286 | + * Check whether this category is enabled for a given Level passed as parameter. |
|
287 | + * |
|
288 | + * @param LoggerLevel level |
|
289 | + * @return boolean |
|
290 | + */ |
|
291 | + public function isEnabledFor($level) { |
|
292 | + return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
293 | + } |
|
294 | 294 | |
295 | - /** |
|
296 | - * Check whether this category is enabled for the info Level. |
|
297 | - * @return boolean |
|
298 | - * @see LoggerLevel |
|
299 | - */ |
|
300 | - public function isInfoEnabled() { |
|
301 | - return $this->isEnabledFor(LoggerLevel::getLevelInfo()); |
|
302 | - } |
|
295 | + /** |
|
296 | + * Check whether this category is enabled for the info Level. |
|
297 | + * @return boolean |
|
298 | + * @see LoggerLevel |
|
299 | + */ |
|
300 | + public function isInfoEnabled() { |
|
301 | + return $this->isEnabledFor(LoggerLevel::getLevelInfo()); |
|
302 | + } |
|
303 | 303 | |
304 | - /** |
|
305 | - * This generic form is intended to be used by wrappers. |
|
306 | - * |
|
307 | - * @param LoggerLevel $priority a valid level |
|
308 | - * @param mixed $message message |
|
309 | - * @param mixed $caller caller object or caller string id |
|
310 | - */ |
|
311 | - public function log($priority, $message, $caller = null) { |
|
312 | - if($this->isEnabledFor($priority)) { |
|
313 | - $this->forcedLog($this->fqcn, $caller, $priority, $message); |
|
314 | - } |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * If assertion parameter is false, then logs msg as an error statement. |
|
319 | - * |
|
320 | - * @param bool $assertion |
|
321 | - * @param string $msg message to log |
|
322 | - */ |
|
323 | - public function assertLog($assertion = true, $msg = '') { |
|
324 | - if($assertion == false) { |
|
325 | - $this->error($msg); |
|
326 | - } |
|
327 | - } |
|
304 | + /** |
|
305 | + * This generic form is intended to be used by wrappers. |
|
306 | + * |
|
307 | + * @param LoggerLevel $priority a valid level |
|
308 | + * @param mixed $message message |
|
309 | + * @param mixed $caller caller object or caller string id |
|
310 | + */ |
|
311 | + public function log($priority, $message, $caller = null) { |
|
312 | + if($this->isEnabledFor($priority)) { |
|
313 | + $this->forcedLog($this->fqcn, $caller, $priority, $message); |
|
314 | + } |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * If assertion parameter is false, then logs msg as an error statement. |
|
319 | + * |
|
320 | + * @param bool $assertion |
|
321 | + * @param string $msg message to log |
|
322 | + */ |
|
323 | + public function assertLog($assertion = true, $msg = '') { |
|
324 | + if($assertion == false) { |
|
325 | + $this->error($msg); |
|
326 | + } |
|
327 | + } |
|
328 | 328 | |
329 | - private function logLevel($message, $level, $caller = null) { |
|
330 | - if($level->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
331 | - $this->forcedLog($this->fqcn, $caller, $level, $message); |
|
332 | - } |
|
333 | - } |
|
334 | - |
|
335 | - /* Factory methods */ |
|
336 | - |
|
337 | - /** |
|
338 | - * Get a Logger by name (Delegate to {@link Logger}) |
|
339 | - * |
|
340 | - * @param string $name logger name |
|
341 | - * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
342 | - * @return Logger |
|
343 | - * @static |
|
344 | - */ |
|
345 | - public static function getLogger($name) { |
|
346 | - if(!self::isInitialized()) { |
|
347 | - self::initialize(); |
|
348 | - } |
|
349 | - return self::getHierarchy()->getLogger($name); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * get the Root Logger (Delegate to {@link Logger}) |
|
354 | - * @return LoggerRoot |
|
355 | - * @static |
|
356 | - */ |
|
357 | - public static function getRootLogger() { |
|
358 | - if(!self::isInitialized()) { |
|
359 | - self::initialize(); |
|
360 | - } |
|
361 | - return self::getHierarchy()->getRootLogger(); |
|
362 | - } |
|
363 | - |
|
364 | - /* Configuration methods */ |
|
365 | - |
|
366 | - /** |
|
367 | - * Add a new Appender to the list of appenders of this Category instance. |
|
368 | - * |
|
369 | - * @param LoggerAppender $newAppender |
|
370 | - */ |
|
371 | - public function addAppender($newAppender) { |
|
372 | - $appenderName = $newAppender->getName(); |
|
373 | - $this->aai[$appenderName] = $newAppender; |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * Remove all previously added appenders from this Category instance. |
|
378 | - */ |
|
379 | - public function removeAllAppenders() { |
|
380 | - $appenderNames = array_keys($this->aai); |
|
381 | - $enumAppenders = count($appenderNames); |
|
382 | - for($i = 0; $i < $enumAppenders; $i++) { |
|
383 | - $this->removeAppender($appenderNames[$i]); |
|
384 | - } |
|
385 | - } |
|
329 | + private function logLevel($message, $level, $caller = null) { |
|
330 | + if($level->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
331 | + $this->forcedLog($this->fqcn, $caller, $level, $message); |
|
332 | + } |
|
333 | + } |
|
334 | + |
|
335 | + /* Factory methods */ |
|
336 | + |
|
337 | + /** |
|
338 | + * Get a Logger by name (Delegate to {@link Logger}) |
|
339 | + * |
|
340 | + * @param string $name logger name |
|
341 | + * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
342 | + * @return Logger |
|
343 | + * @static |
|
344 | + */ |
|
345 | + public static function getLogger($name) { |
|
346 | + if(!self::isInitialized()) { |
|
347 | + self::initialize(); |
|
348 | + } |
|
349 | + return self::getHierarchy()->getLogger($name); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * get the Root Logger (Delegate to {@link Logger}) |
|
354 | + * @return LoggerRoot |
|
355 | + * @static |
|
356 | + */ |
|
357 | + public static function getRootLogger() { |
|
358 | + if(!self::isInitialized()) { |
|
359 | + self::initialize(); |
|
360 | + } |
|
361 | + return self::getHierarchy()->getRootLogger(); |
|
362 | + } |
|
363 | + |
|
364 | + /* Configuration methods */ |
|
365 | + |
|
366 | + /** |
|
367 | + * Add a new Appender to the list of appenders of this Category instance. |
|
368 | + * |
|
369 | + * @param LoggerAppender $newAppender |
|
370 | + */ |
|
371 | + public function addAppender($newAppender) { |
|
372 | + $appenderName = $newAppender->getName(); |
|
373 | + $this->aai[$appenderName] = $newAppender; |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * Remove all previously added appenders from this Category instance. |
|
378 | + */ |
|
379 | + public function removeAllAppenders() { |
|
380 | + $appenderNames = array_keys($this->aai); |
|
381 | + $enumAppenders = count($appenderNames); |
|
382 | + for($i = 0; $i < $enumAppenders; $i++) { |
|
383 | + $this->removeAppender($appenderNames[$i]); |
|
384 | + } |
|
385 | + } |
|
386 | 386 | |
387 | - /** |
|
388 | - * Remove the appender passed as parameter form the list of appenders. |
|
389 | - * |
|
390 | - * @param mixed $appender can be an appender name or a {@link LoggerAppender} object |
|
391 | - */ |
|
392 | - public function removeAppender($appender) { |
|
393 | - if($appender instanceof LoggerAppender) { |
|
394 | - $appender->close(); |
|
395 | - unset($this->aai[$appender->getName()]); |
|
396 | - } else if (is_string($appender) and isset($this->aai[$appender])) { |
|
397 | - $this->aai[$appender]->close(); |
|
398 | - unset($this->aai[$appender]); |
|
399 | - } |
|
400 | - } |
|
387 | + /** |
|
388 | + * Remove the appender passed as parameter form the list of appenders. |
|
389 | + * |
|
390 | + * @param mixed $appender can be an appender name or a {@link LoggerAppender} object |
|
391 | + */ |
|
392 | + public function removeAppender($appender) { |
|
393 | + if($appender instanceof LoggerAppender) { |
|
394 | + $appender->close(); |
|
395 | + unset($this->aai[$appender->getName()]); |
|
396 | + } else if (is_string($appender) and isset($this->aai[$appender])) { |
|
397 | + $this->aai[$appender]->close(); |
|
398 | + unset($this->aai[$appender]); |
|
399 | + } |
|
400 | + } |
|
401 | 401 | |
402 | - /** |
|
403 | - * Call the appenders in the hierarchy starting at this. |
|
404 | - * |
|
405 | - * @param LoggerLoggingEvent $event |
|
406 | - */ |
|
407 | - public function callAppenders($event) { |
|
408 | - if(count($this->aai) > 0) { |
|
409 | - foreach(array_keys($this->aai) as $appenderName) { |
|
410 | - $this->aai[$appenderName]->doAppend($event); |
|
411 | - } |
|
412 | - } |
|
413 | - if($this->parent != null and $this->getAdditivity()) { |
|
414 | - $this->parent->callAppenders($event); |
|
415 | - } |
|
416 | - } |
|
417 | - |
|
418 | - /** |
|
419 | - * Get the appenders contained in this category as an array. |
|
420 | - * @return array collection of appenders |
|
421 | - */ |
|
422 | - public function getAllAppenders() { |
|
423 | - return array_values($this->aai); |
|
424 | - } |
|
425 | - |
|
426 | - /** |
|
427 | - * Look for the appender named as name. |
|
428 | - * @return LoggerAppender |
|
429 | - */ |
|
430 | - public function getAppender($name) { |
|
431 | - return $this->aai[$name]; |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Get the additivity flag for this Category instance. |
|
436 | - * @return boolean |
|
437 | - */ |
|
438 | - public function getAdditivity() { |
|
439 | - return $this->additive; |
|
440 | - } |
|
402 | + /** |
|
403 | + * Call the appenders in the hierarchy starting at this. |
|
404 | + * |
|
405 | + * @param LoggerLoggingEvent $event |
|
406 | + */ |
|
407 | + public function callAppenders($event) { |
|
408 | + if(count($this->aai) > 0) { |
|
409 | + foreach(array_keys($this->aai) as $appenderName) { |
|
410 | + $this->aai[$appenderName]->doAppend($event); |
|
411 | + } |
|
412 | + } |
|
413 | + if($this->parent != null and $this->getAdditivity()) { |
|
414 | + $this->parent->callAppenders($event); |
|
415 | + } |
|
416 | + } |
|
417 | + |
|
418 | + /** |
|
419 | + * Get the appenders contained in this category as an array. |
|
420 | + * @return array collection of appenders |
|
421 | + */ |
|
422 | + public function getAllAppenders() { |
|
423 | + return array_values($this->aai); |
|
424 | + } |
|
425 | + |
|
426 | + /** |
|
427 | + * Look for the appender named as name. |
|
428 | + * @return LoggerAppender |
|
429 | + */ |
|
430 | + public function getAppender($name) { |
|
431 | + return $this->aai[$name]; |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Get the additivity flag for this Category instance. |
|
436 | + * @return boolean |
|
437 | + */ |
|
438 | + public function getAdditivity() { |
|
439 | + return $this->additive; |
|
440 | + } |
|
441 | 441 | |
442 | - /** |
|
443 | - * Starting from this category, search the category hierarchy for a non-null level and return it. |
|
444 | - * @see LoggerLevel |
|
445 | - * @return LoggerLevel or null |
|
446 | - */ |
|
447 | - public function getEffectiveLevel() { |
|
448 | - for($c = $this; $c != null; $c = $c->parent) { |
|
449 | - if($c->getLevel() !== null) { |
|
450 | - return $c->getLevel(); |
|
451 | - } |
|
452 | - } |
|
453 | - return null; |
|
454 | - } |
|
442 | + /** |
|
443 | + * Starting from this category, search the category hierarchy for a non-null level and return it. |
|
444 | + * @see LoggerLevel |
|
445 | + * @return LoggerLevel or null |
|
446 | + */ |
|
447 | + public function getEffectiveLevel() { |
|
448 | + for($c = $this; $c != null; $c = $c->parent) { |
|
449 | + if($c->getLevel() !== null) { |
|
450 | + return $c->getLevel(); |
|
451 | + } |
|
452 | + } |
|
453 | + return null; |
|
454 | + } |
|
455 | 455 | |
456 | - /** |
|
457 | - * Returns the assigned Level, if any, for this Category. |
|
458 | - * @return LoggerLevel or null |
|
459 | - */ |
|
460 | - public function getLevel() { |
|
461 | - return $this->level; |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * Set the level of this Category. |
|
466 | - * |
|
467 | - * @param LoggerLevel $level a level string or a level constant |
|
468 | - */ |
|
469 | - public function setLevel($level) { |
|
470 | - $this->level = $level; |
|
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * Clears all logger definitions |
|
475 | - * |
|
476 | - * @static |
|
477 | - * @return boolean |
|
478 | - */ |
|
479 | - public static function clear() { |
|
480 | - return self::getHierarchy()->clear(); |
|
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Destroy configurations for logger definitions |
|
485 | - * |
|
486 | - * @static |
|
487 | - * @return boolean |
|
488 | - */ |
|
489 | - public static function resetConfiguration() { |
|
490 | - $result = self::getHierarchy()->resetConfiguration(); |
|
491 | - self::$initialized = false; |
|
492 | - self::$configurationClass = 'LoggerConfiguratorBasic'; |
|
493 | - self::$configurationFile = null; |
|
494 | - return $result; |
|
495 | - } |
|
456 | + /** |
|
457 | + * Returns the assigned Level, if any, for this Category. |
|
458 | + * @return LoggerLevel or null |
|
459 | + */ |
|
460 | + public function getLevel() { |
|
461 | + return $this->level; |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * Set the level of this Category. |
|
466 | + * |
|
467 | + * @param LoggerLevel $level a level string or a level constant |
|
468 | + */ |
|
469 | + public function setLevel($level) { |
|
470 | + $this->level = $level; |
|
471 | + } |
|
472 | + |
|
473 | + /** |
|
474 | + * Clears all logger definitions |
|
475 | + * |
|
476 | + * @static |
|
477 | + * @return boolean |
|
478 | + */ |
|
479 | + public static function clear() { |
|
480 | + return self::getHierarchy()->clear(); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Destroy configurations for logger definitions |
|
485 | + * |
|
486 | + * @static |
|
487 | + * @return boolean |
|
488 | + */ |
|
489 | + public static function resetConfiguration() { |
|
490 | + $result = self::getHierarchy()->resetConfiguration(); |
|
491 | + self::$initialized = false; |
|
492 | + self::$configurationClass = 'LoggerConfiguratorBasic'; |
|
493 | + self::$configurationFile = null; |
|
494 | + return $result; |
|
495 | + } |
|
496 | 496 | |
497 | - /** |
|
498 | - * Safely close all appenders. |
|
499 | - * This is not longer necessary due the appenders shutdown via |
|
500 | - * destructors. |
|
501 | - * @deprecated |
|
502 | - * @static |
|
503 | - */ |
|
504 | - public static function shutdown() { |
|
505 | - return self::getHierarchy()->shutdown(); |
|
506 | - } |
|
507 | - |
|
508 | - /** |
|
509 | - * check if a given logger exists. |
|
510 | - * |
|
511 | - * @param string $name logger name |
|
512 | - * @static |
|
513 | - * @return boolean |
|
514 | - */ |
|
515 | - public static function exists($name) { |
|
516 | - return self::getHierarchy()->exists($name); |
|
517 | - } |
|
518 | - |
|
519 | - /** |
|
520 | - * Returns an array this whole Logger instances. |
|
521 | - * |
|
522 | - * @static |
|
523 | - * @see Logger |
|
524 | - * @return array |
|
525 | - */ |
|
526 | - public static function getCurrentLoggers() { |
|
527 | - return self::getHierarchy()->getCurrentLoggers(); |
|
528 | - } |
|
529 | - |
|
530 | - /** |
|
531 | - * Is the appender passed as parameter attached to this category? |
|
532 | - * |
|
533 | - * @param LoggerAppender $appender |
|
534 | - */ |
|
535 | - public function isAttached($appender) { |
|
536 | - return isset($this->aai[$appender->getName()]); |
|
537 | - } |
|
497 | + /** |
|
498 | + * Safely close all appenders. |
|
499 | + * This is not longer necessary due the appenders shutdown via |
|
500 | + * destructors. |
|
501 | + * @deprecated |
|
502 | + * @static |
|
503 | + */ |
|
504 | + public static function shutdown() { |
|
505 | + return self::getHierarchy()->shutdown(); |
|
506 | + } |
|
507 | + |
|
508 | + /** |
|
509 | + * check if a given logger exists. |
|
510 | + * |
|
511 | + * @param string $name logger name |
|
512 | + * @static |
|
513 | + * @return boolean |
|
514 | + */ |
|
515 | + public static function exists($name) { |
|
516 | + return self::getHierarchy()->exists($name); |
|
517 | + } |
|
518 | + |
|
519 | + /** |
|
520 | + * Returns an array this whole Logger instances. |
|
521 | + * |
|
522 | + * @static |
|
523 | + * @see Logger |
|
524 | + * @return array |
|
525 | + */ |
|
526 | + public static function getCurrentLoggers() { |
|
527 | + return self::getHierarchy()->getCurrentLoggers(); |
|
528 | + } |
|
529 | + |
|
530 | + /** |
|
531 | + * Is the appender passed as parameter attached to this category? |
|
532 | + * |
|
533 | + * @param LoggerAppender $appender |
|
534 | + */ |
|
535 | + public function isAttached($appender) { |
|
536 | + return isset($this->aai[$appender->getName()]); |
|
537 | + } |
|
538 | 538 | |
539 | - /** |
|
540 | - * Set the additivity flag for this Category instance. |
|
541 | - * |
|
542 | - * @param boolean $additive |
|
543 | - */ |
|
544 | - public function setAdditivity($additive) { |
|
545 | - $this->additive = (bool)$additive; |
|
546 | - } |
|
539 | + /** |
|
540 | + * Set the additivity flag for this Category instance. |
|
541 | + * |
|
542 | + * @param boolean $additive |
|
543 | + */ |
|
544 | + public function setAdditivity($additive) { |
|
545 | + $this->additive = (bool)$additive; |
|
546 | + } |
|
547 | 547 | |
548 | - /** |
|
549 | - * Sets the parent logger of this logger |
|
550 | - */ |
|
551 | - public function setParent(Logger $logger) { |
|
552 | - $this->parent = $logger; |
|
553 | - } |
|
554 | - |
|
555 | - /** |
|
556 | - * Configures Log4PHP. |
|
557 | - * This method needs to be called before the first logging event |
|
558 | - * has occured. If this methode is never called, the standard configuration |
|
559 | - * takes place (@see LoggerConfiguratorBasic). |
|
560 | - * If only the configuration file is given, the configurator class will |
|
561 | - * be the XML Configurator or the INI Configurator, if no .xml ending |
|
562 | - * could be determined. |
|
563 | - * |
|
564 | - * If a custom configurator should be used, the configuration file |
|
565 | - * is either null or the path to file the custom configurator uses. |
|
566 | - * Make sure the configurator is already or can be loaded by PHP when necessary. |
|
567 | - * |
|
568 | - * @param String $configurationFile the configuration file |
|
569 | - * @param String $configurationClass the configurator class |
|
570 | - */ |
|
571 | - public static function configure($configurationFile = null, |
|
572 | - $configurationClass = null ) { |
|
573 | - if($configurationClass === null && $configurationFile === null) { |
|
574 | - self::$configurationClass = 'LoggerConfiguratorBasic'; |
|
575 | - return; |
|
576 | - } |
|
548 | + /** |
|
549 | + * Sets the parent logger of this logger |
|
550 | + */ |
|
551 | + public function setParent(Logger $logger) { |
|
552 | + $this->parent = $logger; |
|
553 | + } |
|
554 | + |
|
555 | + /** |
|
556 | + * Configures Log4PHP. |
|
557 | + * This method needs to be called before the first logging event |
|
558 | + * has occured. If this methode is never called, the standard configuration |
|
559 | + * takes place (@see LoggerConfiguratorBasic). |
|
560 | + * If only the configuration file is given, the configurator class will |
|
561 | + * be the XML Configurator or the INI Configurator, if no .xml ending |
|
562 | + * could be determined. |
|
563 | + * |
|
564 | + * If a custom configurator should be used, the configuration file |
|
565 | + * is either null or the path to file the custom configurator uses. |
|
566 | + * Make sure the configurator is already or can be loaded by PHP when necessary. |
|
567 | + * |
|
568 | + * @param String $configurationFile the configuration file |
|
569 | + * @param String $configurationClass the configurator class |
|
570 | + */ |
|
571 | + public static function configure($configurationFile = null, |
|
572 | + $configurationClass = null ) { |
|
573 | + if($configurationClass === null && $configurationFile === null) { |
|
574 | + self::$configurationClass = 'LoggerConfiguratorBasic'; |
|
575 | + return; |
|
576 | + } |
|
577 | 577 | |
578 | - if($configurationClass !== null) { |
|
579 | - self::$configurationFile = $configurationFile; |
|
580 | - self::$configurationClass = $configurationClass; |
|
581 | - return; |
|
582 | - } |
|
578 | + if($configurationClass !== null) { |
|
579 | + self::$configurationFile = $configurationFile; |
|
580 | + self::$configurationClass = $configurationClass; |
|
581 | + return; |
|
582 | + } |
|
583 | 583 | |
584 | - if (strtolower(substr( $configurationFile, -4 )) == '.xml') { |
|
585 | - self::$configurationFile = $configurationFile; |
|
586 | - self::$configurationClass = 'LoggerConfiguratorXml'; |
|
587 | - } else { |
|
588 | - self::$configurationFile = $configurationFile; |
|
589 | - self::$configurationClass = 'LoggerConfiguratorIni'; |
|
590 | - } |
|
591 | - } |
|
592 | - |
|
593 | - /** |
|
594 | - * Returns the current configurator |
|
595 | - * @return the configurator |
|
596 | - */ |
|
597 | - public static function getConfigurationClass() { |
|
598 | - return self::$configurationClass; |
|
599 | - } |
|
600 | - |
|
601 | - /** |
|
602 | - * Returns the current configuration file |
|
603 | - * @return the configuration file |
|
604 | - */ |
|
605 | - public static function getConfigurationFile() { |
|
606 | - return self::$configurationFile; |
|
607 | - } |
|
608 | - |
|
609 | - /** |
|
610 | - * Returns, true, if the log4php framework is already initialized |
|
611 | - */ |
|
612 | - private static function isInitialized() { |
|
613 | - return self::$initialized; |
|
614 | - } |
|
615 | - |
|
616 | - /** |
|
617 | - * Initializes the log4php framework. |
|
618 | - * @return boolean |
|
619 | - */ |
|
620 | - public static function initialize() { |
|
621 | - self::$initialized = true; |
|
622 | - $instance = LoggerReflectionUtils::createObject(self::$configurationClass); |
|
623 | - $result = $instance->configure(self::getHierarchy(), self::$configurationFile); |
|
624 | - return $result; |
|
625 | - } |
|
584 | + if (strtolower(substr( $configurationFile, -4 )) == '.xml') { |
|
585 | + self::$configurationFile = $configurationFile; |
|
586 | + self::$configurationClass = 'LoggerConfiguratorXml'; |
|
587 | + } else { |
|
588 | + self::$configurationFile = $configurationFile; |
|
589 | + self::$configurationClass = 'LoggerConfiguratorIni'; |
|
590 | + } |
|
591 | + } |
|
592 | + |
|
593 | + /** |
|
594 | + * Returns the current configurator |
|
595 | + * @return the configurator |
|
596 | + */ |
|
597 | + public static function getConfigurationClass() { |
|
598 | + return self::$configurationClass; |
|
599 | + } |
|
600 | + |
|
601 | + /** |
|
602 | + * Returns the current configuration file |
|
603 | + * @return the configuration file |
|
604 | + */ |
|
605 | + public static function getConfigurationFile() { |
|
606 | + return self::$configurationFile; |
|
607 | + } |
|
608 | + |
|
609 | + /** |
|
610 | + * Returns, true, if the log4php framework is already initialized |
|
611 | + */ |
|
612 | + private static function isInitialized() { |
|
613 | + return self::$initialized; |
|
614 | + } |
|
615 | + |
|
616 | + /** |
|
617 | + * Initializes the log4php framework. |
|
618 | + * @return boolean |
|
619 | + */ |
|
620 | + public static function initialize() { |
|
621 | + self::$initialized = true; |
|
622 | + $instance = LoggerReflectionUtils::createObject(self::$configurationClass); |
|
623 | + $result = $instance->configure(self::getHierarchy(), self::$configurationFile); |
|
624 | + return $result; |
|
625 | + } |
|
626 | 626 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string class name |
124 | 124 | */ |
125 | 125 | public static function autoload($className) { |
126 | - if(isset(self::$_classes[$className])) { |
|
126 | + if (isset(self::$_classes[$className])) { |
|
127 | 127 | include LOG4PHP_DIR.self::$_classes[$className]; |
128 | 128 | } |
129 | 129 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return LoggerHierarchy |
200 | 200 | */ |
201 | 201 | public static function getHierarchy() { |
202 | - if(!isset(self::$hierarchy)) { |
|
202 | + if (!isset(self::$hierarchy)) { |
|
203 | 203 | self::$hierarchy = new LoggerHierarchy(new LoggerRoot()); |
204 | 204 | } |
205 | 205 | return self::$hierarchy; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | 291 | public function isEnabledFor($level) { |
292 | - return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
292 | + return (bool) ($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param mixed $caller caller object or caller string id |
310 | 310 | */ |
311 | 311 | public function log($priority, $message, $caller = null) { |
312 | - if($this->isEnabledFor($priority)) { |
|
312 | + if ($this->isEnabledFor($priority)) { |
|
313 | 313 | $this->forcedLog($this->fqcn, $caller, $priority, $message); |
314 | 314 | } |
315 | 315 | } |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | * @param string $msg message to log |
322 | 322 | */ |
323 | 323 | public function assertLog($assertion = true, $msg = '') { |
324 | - if($assertion == false) { |
|
324 | + if ($assertion == false) { |
|
325 | 325 | $this->error($msg); |
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | 329 | private function logLevel($message, $level, $caller = null) { |
330 | - if($level->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
330 | + if ($level->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
331 | 331 | $this->forcedLog($this->fqcn, $caller, $level, $message); |
332 | 332 | } |
333 | 333 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @static |
344 | 344 | */ |
345 | 345 | public static function getLogger($name) { |
346 | - if(!self::isInitialized()) { |
|
346 | + if (!self::isInitialized()) { |
|
347 | 347 | self::initialize(); |
348 | 348 | } |
349 | 349 | return self::getHierarchy()->getLogger($name); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @static |
356 | 356 | */ |
357 | 357 | public static function getRootLogger() { |
358 | - if(!self::isInitialized()) { |
|
358 | + if (!self::isInitialized()) { |
|
359 | 359 | self::initialize(); |
360 | 360 | } |
361 | 361 | return self::getHierarchy()->getRootLogger(); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | public function removeAllAppenders() { |
380 | 380 | $appenderNames = array_keys($this->aai); |
381 | 381 | $enumAppenders = count($appenderNames); |
382 | - for($i = 0; $i < $enumAppenders; $i++) { |
|
382 | + for ($i = 0; $i < $enumAppenders; $i++) { |
|
383 | 383 | $this->removeAppender($appenderNames[$i]); |
384 | 384 | } |
385 | 385 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * @param mixed $appender can be an appender name or a {@link LoggerAppender} object |
391 | 391 | */ |
392 | 392 | public function removeAppender($appender) { |
393 | - if($appender instanceof LoggerAppender) { |
|
393 | + if ($appender instanceof LoggerAppender) { |
|
394 | 394 | $appender->close(); |
395 | 395 | unset($this->aai[$appender->getName()]); |
396 | 396 | } else if (is_string($appender) and isset($this->aai[$appender])) { |
@@ -405,12 +405,12 @@ discard block |
||
405 | 405 | * @param LoggerLoggingEvent $event |
406 | 406 | */ |
407 | 407 | public function callAppenders($event) { |
408 | - if(count($this->aai) > 0) { |
|
409 | - foreach(array_keys($this->aai) as $appenderName) { |
|
408 | + if (count($this->aai) > 0) { |
|
409 | + foreach (array_keys($this->aai) as $appenderName) { |
|
410 | 410 | $this->aai[$appenderName]->doAppend($event); |
411 | 411 | } |
412 | 412 | } |
413 | - if($this->parent != null and $this->getAdditivity()) { |
|
413 | + if ($this->parent != null and $this->getAdditivity()) { |
|
414 | 414 | $this->parent->callAppenders($event); |
415 | 415 | } |
416 | 416 | } |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * @return LoggerLevel or null |
446 | 446 | */ |
447 | 447 | public function getEffectiveLevel() { |
448 | - for($c = $this; $c != null; $c = $c->parent) { |
|
449 | - if($c->getLevel() !== null) { |
|
448 | + for ($c = $this; $c != null; $c = $c->parent) { |
|
449 | + if ($c->getLevel() !== null) { |
|
450 | 450 | return $c->getLevel(); |
451 | 451 | } |
452 | 452 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @param boolean $additive |
543 | 543 | */ |
544 | 544 | public function setAdditivity($additive) { |
545 | - $this->additive = (bool)$additive; |
|
545 | + $this->additive = (bool) $additive; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -569,19 +569,19 @@ discard block |
||
569 | 569 | * @param String $configurationClass the configurator class |
570 | 570 | */ |
571 | 571 | public static function configure($configurationFile = null, |
572 | - $configurationClass = null ) { |
|
573 | - if($configurationClass === null && $configurationFile === null) { |
|
572 | + $configurationClass = null) { |
|
573 | + if ($configurationClass === null && $configurationFile === null) { |
|
574 | 574 | self::$configurationClass = 'LoggerConfiguratorBasic'; |
575 | 575 | return; |
576 | 576 | } |
577 | 577 | |
578 | - if($configurationClass !== null) { |
|
578 | + if ($configurationClass !== null) { |
|
579 | 579 | self::$configurationFile = $configurationFile; |
580 | 580 | self::$configurationClass = $configurationClass; |
581 | 581 | return; |
582 | 582 | } |
583 | 583 | |
584 | - if (strtolower(substr( $configurationFile, -4 )) == '.xml') { |
|
584 | + if (strtolower(substr($configurationFile, -4)) == '.xml') { |
|
585 | 585 | self::$configurationFile = $configurationFile; |
586 | 586 | self::$configurationClass = 'LoggerConfiguratorXml'; |
587 | 587 | } else { |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * |
27 | 27 | * @var string |
28 | 28 | */ |
29 | -if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); |
|
29 | +if (!defined('LOG4PHP_DIR')) { |
|
30 | + define('LOG4PHP_DIR', dirname(__FILE__)); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | spl_autoload_register(array('Logger', 'autoload')); |
32 | 34 |
@@ -209,7 +209,7 @@ |
||
209 | 209 | /** |
210 | 210 | * Set the threshold level of this appender. |
211 | 211 | * |
212 | - * @param mixed $threshold can be a {@link LoggerLevel} object or a string. |
|
212 | + * @param LoggerLevel $threshold can be a {@link LoggerLevel} object or a string. |
|
213 | 213 | * @see LoggerOptionConverter::toLevel() |
214 | 214 | */ |
215 | 215 | public function setThreshold($threshold) { |
@@ -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 | * Abstract class that defines output logs strategies. |
@@ -26,236 +26,236 @@ discard block |
||
26 | 26 | */ |
27 | 27 | abstract class LoggerAppender { |
28 | 28 | |
29 | - /** |
|
30 | - * @var boolean closed appender flag |
|
31 | - */ |
|
32 | - protected $closed = false; |
|
29 | + /** |
|
30 | + * @var boolean closed appender flag |
|
31 | + */ |
|
32 | + protected $closed = false; |
|
33 | 33 | |
34 | - /** |
|
35 | - * The first filter in the filter chain |
|
36 | - * @var LoggerFilter |
|
37 | - */ |
|
38 | - protected $filter = null; |
|
34 | + /** |
|
35 | + * The first filter in the filter chain |
|
36 | + * @var LoggerFilter |
|
37 | + */ |
|
38 | + protected $filter = null; |
|
39 | 39 | |
40 | - /** |
|
41 | - * LoggerLayout for this appender. It can be null if appender has its own layout |
|
42 | - * @var LoggerLayout |
|
43 | - */ |
|
44 | - protected $layout = null; |
|
40 | + /** |
|
41 | + * LoggerLayout for this appender. It can be null if appender has its own layout |
|
42 | + * @var LoggerLayout |
|
43 | + */ |
|
44 | + protected $layout = null; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var string Appender name |
|
48 | - */ |
|
49 | - protected $name; |
|
46 | + /** |
|
47 | + * @var string Appender name |
|
48 | + */ |
|
49 | + protected $name; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var LoggerLevel There is no level threshold filtering by default. |
|
53 | - */ |
|
54 | - protected $threshold = null; |
|
51 | + /** |
|
52 | + * @var LoggerLevel There is no level threshold filtering by default. |
|
53 | + */ |
|
54 | + protected $threshold = null; |
|
55 | 55 | |
56 | - /** |
|
57 | - * @var boolean needs a layout formatting ? |
|
58 | - */ |
|
59 | - protected $requiresLayout = false; |
|
56 | + /** |
|
57 | + * @var boolean needs a layout formatting ? |
|
58 | + */ |
|
59 | + protected $requiresLayout = false; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Constructor |
|
63 | - * |
|
64 | - * @param string $name appender name |
|
65 | - */ |
|
66 | - public function __construct($name = '') { |
|
67 | - $this->name = $name; |
|
68 | - } |
|
61 | + /** |
|
62 | + * Constructor |
|
63 | + * |
|
64 | + * @param string $name appender name |
|
65 | + */ |
|
66 | + public function __construct($name = '') { |
|
67 | + $this->name = $name; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Add a filter to the end of the filter list. |
|
72 | - * |
|
73 | - * @param LoggerFilter $newFilter add a new LoggerFilter |
|
74 | - */ |
|
75 | - public function addFilter($newFilter) { |
|
76 | - if($this->filter === null) { |
|
77 | - $this->filter = $newFilter; |
|
78 | - } else { |
|
79 | - $this->filter->addNext($newFilter); |
|
80 | - } |
|
81 | - } |
|
70 | + /** |
|
71 | + * Add a filter to the end of the filter list. |
|
72 | + * |
|
73 | + * @param LoggerFilter $newFilter add a new LoggerFilter |
|
74 | + */ |
|
75 | + public function addFilter($newFilter) { |
|
76 | + if($this->filter === null) { |
|
77 | + $this->filter = $newFilter; |
|
78 | + } else { |
|
79 | + $this->filter->addNext($newFilter); |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Clear the list of filters by removing all the filters in it. |
|
85 | - * @abstract |
|
86 | - */ |
|
87 | - public function clearFilters() { |
|
88 | - unset($this->filter); |
|
89 | - $this->filter = null; |
|
90 | - } |
|
83 | + /** |
|
84 | + * Clear the list of filters by removing all the filters in it. |
|
85 | + * @abstract |
|
86 | + */ |
|
87 | + public function clearFilters() { |
|
88 | + unset($this->filter); |
|
89 | + $this->filter = null; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Return the first filter in the filter chain for this Appender. |
|
94 | - * The return value may be <i>null</i> if no is filter is set. |
|
95 | - * @return LoggerFilter |
|
96 | - */ |
|
97 | - public function getFilter() { |
|
98 | - return $this->filter; |
|
99 | - } |
|
92 | + /** |
|
93 | + * Return the first filter in the filter chain for this Appender. |
|
94 | + * The return value may be <i>null</i> if no is filter is set. |
|
95 | + * @return LoggerFilter |
|
96 | + */ |
|
97 | + public function getFilter() { |
|
98 | + return $this->filter; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Return the first filter in the filter chain for this Appender. |
|
103 | - * The return value may be <i>null</i> if no is filter is set. |
|
104 | - * @return LoggerFilter |
|
105 | - */ |
|
106 | - public function getFirstFilter() { |
|
107 | - return $this->filter; |
|
108 | - } |
|
101 | + /** |
|
102 | + * Return the first filter in the filter chain for this Appender. |
|
103 | + * The return value may be <i>null</i> if no is filter is set. |
|
104 | + * @return LoggerFilter |
|
105 | + */ |
|
106 | + public function getFirstFilter() { |
|
107 | + return $this->filter; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * This method performs threshold checks and invokes filters before |
|
113 | - * delegating actual logging to the subclasses specific <i>append()</i> method. |
|
114 | - * @see LoggerAppender::doAppend() |
|
115 | - * @param LoggerLoggingEvent $event |
|
116 | - */ |
|
117 | - public function doAppend(LoggerLoggingEvent $event) { |
|
118 | - if($this->closed) { |
|
119 | - return; |
|
120 | - } |
|
111 | + /** |
|
112 | + * This method performs threshold checks and invokes filters before |
|
113 | + * delegating actual logging to the subclasses specific <i>append()</i> method. |
|
114 | + * @see LoggerAppender::doAppend() |
|
115 | + * @param LoggerLoggingEvent $event |
|
116 | + */ |
|
117 | + public function doAppend(LoggerLoggingEvent $event) { |
|
118 | + if($this->closed) { |
|
119 | + return; |
|
120 | + } |
|
121 | 121 | |
122 | - if(!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
123 | - return; |
|
124 | - } |
|
122 | + if(!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
123 | + return; |
|
124 | + } |
|
125 | 125 | |
126 | - $f = $this->getFirstFilter(); |
|
127 | - while($f !== null) { |
|
128 | - switch ($f->decide($event)) { |
|
129 | - case LoggerFilter::DENY: return; |
|
130 | - case LoggerFilter::ACCEPT: return $this->append($event); |
|
131 | - case LoggerFilter::NEUTRAL: $f = $f->getNext(); |
|
132 | - } |
|
133 | - } |
|
134 | - $this->append($event); |
|
135 | - } |
|
126 | + $f = $this->getFirstFilter(); |
|
127 | + while($f !== null) { |
|
128 | + switch ($f->decide($event)) { |
|
129 | + case LoggerFilter::DENY: return; |
|
130 | + case LoggerFilter::ACCEPT: return $this->append($event); |
|
131 | + case LoggerFilter::NEUTRAL: $f = $f->getNext(); |
|
132 | + } |
|
133 | + } |
|
134 | + $this->append($event); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Set the Layout for this appender. |
|
139 | - * @see LoggerAppender::setLayout() |
|
140 | - * @param LoggerLayout $layout |
|
141 | - */ |
|
142 | - public function setLayout($layout) { |
|
143 | - if($this->requiresLayout()) { |
|
144 | - $this->layout = $layout; |
|
145 | - } |
|
146 | - } |
|
137 | + /** |
|
138 | + * Set the Layout for this appender. |
|
139 | + * @see LoggerAppender::setLayout() |
|
140 | + * @param LoggerLayout $layout |
|
141 | + */ |
|
142 | + public function setLayout($layout) { |
|
143 | + if($this->requiresLayout()) { |
|
144 | + $this->layout = $layout; |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Returns this appender layout. |
|
150 | - * @see LoggerAppender::getLayout() |
|
151 | - * @return LoggerLayout |
|
152 | - */ |
|
153 | - public function getLayout() { |
|
154 | - return $this->layout; |
|
155 | - } |
|
148 | + /** |
|
149 | + * Returns this appender layout. |
|
150 | + * @see LoggerAppender::getLayout() |
|
151 | + * @return LoggerLayout |
|
152 | + */ |
|
153 | + public function getLayout() { |
|
154 | + return $this->layout; |
|
155 | + } |
|
156 | 156 | |
157 | - /** |
|
158 | - * Configurators call this method to determine if the appender |
|
159 | - * requires a layout. |
|
160 | - * |
|
161 | - * <p>If this method returns <i>true</i>, meaning that layout is required, |
|
162 | - * then the configurator will configure a layout using the configuration |
|
163 | - * information at its disposal. If this method returns <i>false</i>, |
|
164 | - * meaning that a layout is not required, then layout configuration will be |
|
165 | - * skipped even if there is available layout configuration |
|
166 | - * information at the disposal of the configurator.</p> |
|
167 | - * |
|
168 | - * <p>In the rather exceptional case, where the appender |
|
169 | - * implementation admits a layout but can also work without it, then |
|
170 | - * the appender should return <i>true</i>.</p> |
|
171 | - * |
|
172 | - * @see LoggerAppender::requiresLayout() |
|
173 | - * @return boolean |
|
174 | - */ |
|
175 | - public function requiresLayout() { |
|
176 | - return $this->requiresLayout; |
|
177 | - } |
|
157 | + /** |
|
158 | + * Configurators call this method to determine if the appender |
|
159 | + * requires a layout. |
|
160 | + * |
|
161 | + * <p>If this method returns <i>true</i>, meaning that layout is required, |
|
162 | + * then the configurator will configure a layout using the configuration |
|
163 | + * information at its disposal. If this method returns <i>false</i>, |
|
164 | + * meaning that a layout is not required, then layout configuration will be |
|
165 | + * skipped even if there is available layout configuration |
|
166 | + * information at the disposal of the configurator.</p> |
|
167 | + * |
|
168 | + * <p>In the rather exceptional case, where the appender |
|
169 | + * implementation admits a layout but can also work without it, then |
|
170 | + * the appender should return <i>true</i>.</p> |
|
171 | + * |
|
172 | + * @see LoggerAppender::requiresLayout() |
|
173 | + * @return boolean |
|
174 | + */ |
|
175 | + public function requiresLayout() { |
|
176 | + return $this->requiresLayout; |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Get the name of this appender. |
|
181 | - * @see LoggerAppender::getName() |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - public function getName() { |
|
185 | - return $this->name; |
|
186 | - } |
|
179 | + /** |
|
180 | + * Get the name of this appender. |
|
181 | + * @see LoggerAppender::getName() |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + public function getName() { |
|
185 | + return $this->name; |
|
186 | + } |
|
187 | 187 | |
188 | 188 | /** |
189 | - * Set the name of this appender. |
|
190 | - * |
|
191 | - * The name is used by other components to identify this appender. |
|
192 | - * |
|
193 | - * |
|
194 | - * @param string $name |
|
195 | - */ |
|
196 | - public function setName($name) { |
|
197 | - $this->name = $name; |
|
198 | - } |
|
189 | + * Set the name of this appender. |
|
190 | + * |
|
191 | + * The name is used by other components to identify this appender. |
|
192 | + * |
|
193 | + * |
|
194 | + * @param string $name |
|
195 | + */ |
|
196 | + public function setName($name) { |
|
197 | + $this->name = $name; |
|
198 | + } |
|
199 | 199 | |
200 | - /** |
|
201 | - * Returns this appenders threshold level. |
|
202 | - * See the {@link setThreshold()} method for the meaning of this option. |
|
203 | - * @return LoggerLevel |
|
204 | - */ |
|
205 | - public function getThreshold() { |
|
206 | - return $this->threshold; |
|
207 | - } |
|
200 | + /** |
|
201 | + * Returns this appenders threshold level. |
|
202 | + * See the {@link setThreshold()} method for the meaning of this option. |
|
203 | + * @return LoggerLevel |
|
204 | + */ |
|
205 | + public function getThreshold() { |
|
206 | + return $this->threshold; |
|
207 | + } |
|
208 | 208 | |
209 | - /** |
|
210 | - * Set the threshold level of this appender. |
|
211 | - * |
|
212 | - * @param mixed $threshold can be a {@link LoggerLevel} object or a string. |
|
213 | - * @see LoggerOptionConverter::toLevel() |
|
214 | - */ |
|
215 | - public function setThreshold($threshold) { |
|
216 | - if(is_string($threshold)) { |
|
217 | - $this->threshold = LoggerOptionConverter::toLevel($threshold, null); |
|
218 | - } else if($threshold instanceof LoggerLevel) { |
|
219 | - $this->threshold = $threshold; |
|
220 | - } |
|
221 | - } |
|
209 | + /** |
|
210 | + * Set the threshold level of this appender. |
|
211 | + * |
|
212 | + * @param mixed $threshold can be a {@link LoggerLevel} object or a string. |
|
213 | + * @see LoggerOptionConverter::toLevel() |
|
214 | + */ |
|
215 | + public function setThreshold($threshold) { |
|
216 | + if(is_string($threshold)) { |
|
217 | + $this->threshold = LoggerOptionConverter::toLevel($threshold, null); |
|
218 | + } else if($threshold instanceof LoggerLevel) { |
|
219 | + $this->threshold = $threshold; |
|
220 | + } |
|
221 | + } |
|
222 | 222 | |
223 | - /** |
|
224 | - * Check whether the message level is below the appender's threshold. |
|
225 | - * |
|
226 | - * |
|
227 | - * If there is no threshold set, then the return value is always <i>true</i>. |
|
228 | - * @param LoggerLevel $level |
|
229 | - * @return boolean true if priority is greater or equal than threshold |
|
230 | - */ |
|
231 | - public function isAsSevereAsThreshold($level) { |
|
232 | - if($this->threshold === null) { |
|
233 | - return true; |
|
234 | - } |
|
235 | - return $level->isGreaterOrEqual($this->getThreshold()); |
|
236 | - } |
|
223 | + /** |
|
224 | + * Check whether the message level is below the appender's threshold. |
|
225 | + * |
|
226 | + * |
|
227 | + * If there is no threshold set, then the return value is always <i>true</i>. |
|
228 | + * @param LoggerLevel $level |
|
229 | + * @return boolean true if priority is greater or equal than threshold |
|
230 | + */ |
|
231 | + public function isAsSevereAsThreshold($level) { |
|
232 | + if($this->threshold === null) { |
|
233 | + return true; |
|
234 | + } |
|
235 | + return $level->isGreaterOrEqual($this->getThreshold()); |
|
236 | + } |
|
237 | 237 | |
238 | - /** |
|
239 | - * Derived appenders should override this method if option structure |
|
240 | - * requires it. |
|
241 | - */ |
|
242 | - abstract public function activateOptions(); |
|
238 | + /** |
|
239 | + * Derived appenders should override this method if option structure |
|
240 | + * requires it. |
|
241 | + */ |
|
242 | + abstract public function activateOptions(); |
|
243 | 243 | |
244 | - /** |
|
245 | - * Subclasses of {@link LoggerAppender} should implement |
|
246 | - * this method to perform actual logging. |
|
247 | - * |
|
248 | - * @param LoggerLoggingEvent $event |
|
249 | - * @see doAppend() |
|
250 | - * @abstract |
|
251 | - */ |
|
252 | - abstract protected function append(LoggerLoggingEvent $event); |
|
244 | + /** |
|
245 | + * Subclasses of {@link LoggerAppender} should implement |
|
246 | + * this method to perform actual logging. |
|
247 | + * |
|
248 | + * @param LoggerLoggingEvent $event |
|
249 | + * @see doAppend() |
|
250 | + * @abstract |
|
251 | + */ |
|
252 | + abstract protected function append(LoggerLoggingEvent $event); |
|
253 | 253 | |
254 | - /** |
|
255 | - * Release any resources allocated. |
|
256 | - * Subclasses of {@link LoggerAppender} should implement |
|
257 | - * this method to perform proper closing procedures. |
|
258 | - * @abstract |
|
259 | - */ |
|
260 | - abstract public function close(); |
|
254 | + /** |
|
255 | + * Release any resources allocated. |
|
256 | + * Subclasses of {@link LoggerAppender} should implement |
|
257 | + * this method to perform proper closing procedures. |
|
258 | + * @abstract |
|
259 | + */ |
|
260 | + abstract public function close(); |
|
261 | 261 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param LoggerFilter $newFilter add a new LoggerFilter |
74 | 74 | */ |
75 | 75 | public function addFilter($newFilter) { |
76 | - if($this->filter === null) { |
|
76 | + if ($this->filter === null) { |
|
77 | 77 | $this->filter = $newFilter; |
78 | 78 | } else { |
79 | 79 | $this->filter->addNext($newFilter); |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | * @param LoggerLoggingEvent $event |
116 | 116 | */ |
117 | 117 | public function doAppend(LoggerLoggingEvent $event) { |
118 | - if($this->closed) { |
|
118 | + if ($this->closed) { |
|
119 | 119 | return; |
120 | 120 | } |
121 | 121 | |
122 | - if(!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
122 | + if (!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | $f = $this->getFirstFilter(); |
127 | - while($f !== null) { |
|
127 | + while ($f !== null) { |
|
128 | 128 | switch ($f->decide($event)) { |
129 | 129 | case LoggerFilter::DENY: return; |
130 | 130 | case LoggerFilter::ACCEPT: return $this->append($event); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param LoggerLayout $layout |
141 | 141 | */ |
142 | 142 | public function setLayout($layout) { |
143 | - if($this->requiresLayout()) { |
|
143 | + if ($this->requiresLayout()) { |
|
144 | 144 | $this->layout = $layout; |
145 | 145 | } |
146 | 146 | } |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | * @see LoggerOptionConverter::toLevel() |
214 | 214 | */ |
215 | 215 | public function setThreshold($threshold) { |
216 | - if(is_string($threshold)) { |
|
216 | + if (is_string($threshold)) { |
|
217 | 217 | $this->threshold = LoggerOptionConverter::toLevel($threshold, null); |
218 | - } else if($threshold instanceof LoggerLevel) { |
|
218 | + } else if ($threshold instanceof LoggerLevel) { |
|
219 | 219 | $this->threshold = $threshold; |
220 | 220 | } |
221 | 221 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return boolean true if priority is greater or equal than threshold |
230 | 230 | */ |
231 | 231 | public function isAsSevereAsThreshold($level) { |
232 | - if($this->threshold === null) { |
|
232 | + if ($this->threshold === null) { |
|
233 | 233 | return true; |
234 | 234 | } |
235 | 235 | return $level->isGreaterOrEqual($this->getThreshold()); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Create a new logger hierarchy. |
74 | - * @param object $root the root logger |
|
74 | + * @param LoggerRoot $root the root logger |
|
75 | 75 | */ |
76 | 76 | public function __construct(LoggerRoot $root) { |
77 | 77 | $this->root = $root; |
@@ -107,7 +107,6 @@ discard block |
||
107 | 107 | * Return a new logger instance named as the first parameter using the default factory. |
108 | 108 | * |
109 | 109 | * @param string $name logger name |
110 | - * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
111 | 110 | * @return Logger |
112 | 111 | */ |
113 | 112 | public function getLogger($name) { |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | - * contributor license agreements. See the NOTICE file distributed with |
|
5 | - * this work for additional information regarding copyright ownership. |
|
6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | - * (the "License"); you may not use this file except in compliance with |
|
8 | - * the License. You may obtain a copy of the License at |
|
9 | - * |
|
10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | - * |
|
12 | - * Unless required by applicable law or agreed to in writing, software |
|
13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | - * See the License for the specific language governing permissions and |
|
16 | - * limitations under the License. |
|
17 | - * |
|
18 | - * @package log4php |
|
19 | - */ |
|
3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
4 | + * contributor license agreements. See the NOTICE file distributed with |
|
5 | + * this work for additional information regarding copyright ownership. |
|
6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7 | + * (the "License"); you may not use this file except in compliance with |
|
8 | + * the License. You may obtain a copy of the License at |
|
9 | + * |
|
10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + * |
|
12 | + * Unless required by applicable law or agreed to in writing, software |
|
13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + * See the License for the specific language governing permissions and |
|
16 | + * limitations under the License. |
|
17 | + * |
|
18 | + * @package log4php |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * This class is specialized in retrieving loggers by name and also maintaining |
@@ -47,199 +47,199 @@ discard block |
||
47 | 47 | * @version $Revision: 822448 $ |
48 | 48 | * @package log4php |
49 | 49 | */ |
50 | - /* |
|
50 | + /* |
|
51 | 51 | * TODO: |
52 | 52 | * - addHierarchyEventListener($listener) not supported |
53 | 53 | * - emitNoAppenderWarning($cat) not supported |
54 | 54 | * - fireAddAppenderEvent not supported |
55 | 55 | */ |
56 | 56 | class LoggerHierarchy { |
57 | - /** Default Factory */ |
|
58 | - protected $defaultFactory; |
|
57 | + /** Default Factory */ |
|
58 | + protected $defaultFactory; |
|
59 | 59 | |
60 | - /** array hierarchy tree. saves here all loggers */ |
|
61 | - protected $ht = array(); |
|
60 | + /** array hierarchy tree. saves here all loggers */ |
|
61 | + protected $ht = array(); |
|
62 | 62 | |
63 | - /** The root Logger */ |
|
64 | - protected $root = null; |
|
63 | + /** The root Logger */ |
|
64 | + protected $root = null; |
|
65 | 65 | |
66 | - /** LoggerRendererMap */ |
|
67 | - protected $rendererMap; |
|
66 | + /** LoggerRendererMap */ |
|
67 | + protected $rendererMap; |
|
68 | 68 | |
69 | - /** LoggerLevel main level threshold */ |
|
70 | - protected $threshold; |
|
69 | + /** LoggerLevel main level threshold */ |
|
70 | + protected $threshold; |
|
71 | 71 | |
72 | - /** |
|
73 | - * Create a new logger hierarchy. |
|
74 | - * @param object $root the root logger |
|
75 | - */ |
|
76 | - public function __construct(LoggerRoot $root) { |
|
77 | - $this->root = $root; |
|
78 | - $this->setThreshold(LoggerLevel::getLevelAll()); |
|
79 | - $this->rendererMap = new LoggerRendererMap(); |
|
80 | - } |
|
72 | + /** |
|
73 | + * Create a new logger hierarchy. |
|
74 | + * @param object $root the root logger |
|
75 | + */ |
|
76 | + public function __construct(LoggerRoot $root) { |
|
77 | + $this->root = $root; |
|
78 | + $this->setThreshold(LoggerLevel::getLevelAll()); |
|
79 | + $this->rendererMap = new LoggerRendererMap(); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * This call will clear all logger definitions from the internal hashtable. |
|
84 | - */ |
|
85 | - public function clear() { |
|
86 | - $this->ht = array(); |
|
87 | - } |
|
82 | + /** |
|
83 | + * This call will clear all logger definitions from the internal hashtable. |
|
84 | + */ |
|
85 | + public function clear() { |
|
86 | + $this->ht = array(); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Check if the named logger exists in the hierarchy. |
|
91 | - * @param string $name |
|
92 | - * @return boolean |
|
93 | - */ |
|
94 | - public function exists($name) { |
|
95 | - return isset($this->ht[$name]); |
|
96 | - } |
|
89 | + /** |
|
90 | + * Check if the named logger exists in the hierarchy. |
|
91 | + * @param string $name |
|
92 | + * @return boolean |
|
93 | + */ |
|
94 | + public function exists($name) { |
|
95 | + return isset($this->ht[$name]); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Returns all the currently defined categories in this hierarchy as an array. |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function getCurrentLoggers() { |
|
103 | - return array_values($this->ht); |
|
104 | - } |
|
98 | + /** |
|
99 | + * Returns all the currently defined categories in this hierarchy as an array. |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function getCurrentLoggers() { |
|
103 | + return array_values($this->ht); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Return a new logger instance named as the first parameter using the default factory. |
|
108 | - * |
|
109 | - * @param string $name logger name |
|
110 | - * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
111 | - * @return Logger |
|
112 | - */ |
|
113 | - public function getLogger($name) { |
|
114 | - if(!isset($this->ht[$name])) { |
|
115 | - $this->ht[$name] = new Logger($name);; |
|
116 | - // TODO: isn't necessary, access via singleton? |
|
117 | - // $this->ht[$name]->setHierarchy($this); |
|
118 | - $nodes = explode('.', $name); |
|
119 | - $firstNode = array_shift($nodes); |
|
106 | + /** |
|
107 | + * Return a new logger instance named as the first parameter using the default factory. |
|
108 | + * |
|
109 | + * @param string $name logger name |
|
110 | + * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
111 | + * @return Logger |
|
112 | + */ |
|
113 | + public function getLogger($name) { |
|
114 | + if(!isset($this->ht[$name])) { |
|
115 | + $this->ht[$name] = new Logger($name);; |
|
116 | + // TODO: isn't necessary, access via singleton? |
|
117 | + // $this->ht[$name]->setHierarchy($this); |
|
118 | + $nodes = explode('.', $name); |
|
119 | + $firstNode = array_shift($nodes); |
|
120 | 120 | |
121 | - // if name is not a first node but another first node is their |
|
122 | - if($firstNode != $name and isset($this->ht[$firstNode])) { |
|
123 | - $this->ht[$name]->setParent($this->ht[$firstNode]); |
|
124 | - } else { |
|
125 | - // if there is no father, set root logger as father |
|
126 | - $this->ht[$name]->setParent($this->root); |
|
127 | - } |
|
121 | + // if name is not a first node but another first node is their |
|
122 | + if($firstNode != $name and isset($this->ht[$firstNode])) { |
|
123 | + $this->ht[$name]->setParent($this->ht[$firstNode]); |
|
124 | + } else { |
|
125 | + // if there is no father, set root logger as father |
|
126 | + $this->ht[$name]->setParent($this->root); |
|
127 | + } |
|
128 | 128 | |
129 | - // if there are more nodes than one |
|
130 | - if(count($nodes) > 0) { |
|
131 | - // find parent node |
|
132 | - foreach($nodes as $node) { |
|
133 | - $parentNode = "$firstNode.$node"; |
|
134 | - if(isset($this->ht[$parentNode]) and $parentNode != $name) { |
|
129 | + // if there are more nodes than one |
|
130 | + if(count($nodes) > 0) { |
|
131 | + // find parent node |
|
132 | + foreach($nodes as $node) { |
|
133 | + $parentNode = "$firstNode.$node"; |
|
134 | + if(isset($this->ht[$parentNode]) and $parentNode != $name) { |
|
135 | 135 | |
136 | - $this->ht[$name]->setParent($this->ht[$parentNode]); |
|
137 | - } |
|
138 | - $firstNode .= ".$node"; |
|
139 | - } |
|
140 | - } |
|
141 | - } |
|
136 | + $this->ht[$name]->setParent($this->ht[$parentNode]); |
|
137 | + } |
|
138 | + $firstNode .= ".$node"; |
|
139 | + } |
|
140 | + } |
|
141 | + } |
|
142 | 142 | |
143 | - return $this->ht[$name]; |
|
144 | - } |
|
143 | + return $this->ht[$name]; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @return LoggerRendererMap Get the renderer map for this hierarchy. |
|
148 | - */ |
|
149 | - public function getRendererMap() { |
|
150 | - return $this->rendererMap; |
|
151 | - } |
|
146 | + /** |
|
147 | + * @return LoggerRendererMap Get the renderer map for this hierarchy. |
|
148 | + */ |
|
149 | + public function getRendererMap() { |
|
150 | + return $this->rendererMap; |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * @return LoggerRoot Get the root of this hierarchy. |
|
155 | - */ |
|
156 | - public function getRootLogger() { |
|
157 | - if(!isset($this->root) or $this->root == null) { |
|
158 | - $this->root = new LoggerRoot(); |
|
159 | - } |
|
160 | - return $this->root; |
|
161 | - } |
|
153 | + /** |
|
154 | + * @return LoggerRoot Get the root of this hierarchy. |
|
155 | + */ |
|
156 | + public function getRootLogger() { |
|
157 | + if(!isset($this->root) or $this->root == null) { |
|
158 | + $this->root = new LoggerRoot(); |
|
159 | + } |
|
160 | + return $this->root; |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * @return LoggerLevel Returns the threshold Level. |
|
165 | - */ |
|
166 | - public function getThreshold() { |
|
167 | - return $this->threshold; |
|
168 | - } |
|
163 | + /** |
|
164 | + * @return LoggerLevel Returns the threshold Level. |
|
165 | + */ |
|
166 | + public function getThreshold() { |
|
167 | + return $this->threshold; |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * This method will return true if this repository is disabled |
|
172 | - * for level object passed as parameter and false otherwise. |
|
173 | - * @return boolean |
|
174 | - */ |
|
175 | - public function isDisabled(LoggerLevel $level) { |
|
176 | - return ($this->threshold->toInt() > $level->toInt()); |
|
177 | - } |
|
170 | + /** |
|
171 | + * This method will return true if this repository is disabled |
|
172 | + * for level object passed as parameter and false otherwise. |
|
173 | + * @return boolean |
|
174 | + */ |
|
175 | + public function isDisabled(LoggerLevel $level) { |
|
176 | + return ($this->threshold->toInt() > $level->toInt()); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Reset all values contained in this hierarchy instance to their |
|
181 | - * default. |
|
182 | - * |
|
183 | - * This removes all appenders from all categories, sets |
|
184 | - * the level of all non-root categories to <i>null</i>, |
|
185 | - * sets their additivity flag to <i>true</i> and sets the level |
|
186 | - * of the root logger to {@link LOGGER_LEVEL_DEBUG}. Moreover, |
|
187 | - * message disabling is set its default "off" value. |
|
188 | - * |
|
189 | - * <p>Existing categories are not removed. They are just reset. |
|
190 | - * |
|
191 | - * <p>This method should be used sparingly and with care as it will |
|
192 | - * block all logging until it is completed.</p> |
|
193 | - */ |
|
194 | - public function resetConfiguration() { |
|
195 | - $root = $this->getRootLogger(); |
|
179 | + /** |
|
180 | + * Reset all values contained in this hierarchy instance to their |
|
181 | + * default. |
|
182 | + * |
|
183 | + * This removes all appenders from all categories, sets |
|
184 | + * the level of all non-root categories to <i>null</i>, |
|
185 | + * sets their additivity flag to <i>true</i> and sets the level |
|
186 | + * of the root logger to {@link LOGGER_LEVEL_DEBUG}. Moreover, |
|
187 | + * message disabling is set its default "off" value. |
|
188 | + * |
|
189 | + * <p>Existing categories are not removed. They are just reset. |
|
190 | + * |
|
191 | + * <p>This method should be used sparingly and with care as it will |
|
192 | + * block all logging until it is completed.</p> |
|
193 | + */ |
|
194 | + public function resetConfiguration() { |
|
195 | + $root = $this->getRootLogger(); |
|
196 | 196 | |
197 | - $root->setLevel(LoggerLevel::getLevelDebug()); |
|
198 | - $this->setThreshold(LoggerLevel::getLevelAll()); |
|
199 | - $this->shutDown(); |
|
200 | - $loggers = $this->getCurrentLoggers(); |
|
201 | - $enumLoggers = count($loggers); |
|
202 | - for($i = 0; $i < $enumLoggers; $i++) { |
|
203 | - $loggers[$i]->setLevel(null); |
|
204 | - $loggers[$i]->setAdditivity(true); |
|
205 | - $loggers[$i]->removeAllAppenders(); |
|
206 | - } |
|
207 | - $this->rendererMap->clear(); |
|
208 | - } |
|
197 | + $root->setLevel(LoggerLevel::getLevelDebug()); |
|
198 | + $this->setThreshold(LoggerLevel::getLevelAll()); |
|
199 | + $this->shutDown(); |
|
200 | + $loggers = $this->getCurrentLoggers(); |
|
201 | + $enumLoggers = count($loggers); |
|
202 | + for($i = 0; $i < $enumLoggers; $i++) { |
|
203 | + $loggers[$i]->setLevel(null); |
|
204 | + $loggers[$i]->setAdditivity(true); |
|
205 | + $loggers[$i]->removeAllAppenders(); |
|
206 | + } |
|
207 | + $this->rendererMap->clear(); |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * set a new threshold level |
|
212 | - * |
|
213 | - * @param LoggerLevel $l |
|
214 | - */ |
|
215 | - public function setThreshold(LoggerLevel $l) { |
|
216 | - if($l !== null) { |
|
217 | - $this->threshold = $l; |
|
218 | - } |
|
219 | - } |
|
210 | + /** |
|
211 | + * set a new threshold level |
|
212 | + * |
|
213 | + * @param LoggerLevel $l |
|
214 | + */ |
|
215 | + public function setThreshold(LoggerLevel $l) { |
|
216 | + if($l !== null) { |
|
217 | + $this->threshold = $l; |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Shutting down a hierarchy will <i>safely</i> close and remove |
|
223 | - * all appenders in all categories including the root logger. |
|
224 | - * |
|
225 | - * <p>Some appenders such as {@link LoggerSocketAppender} |
|
226 | - * need to be closed before the |
|
227 | - * application exists. Otherwise, pending logging events might be |
|
228 | - * lost. |
|
229 | - * |
|
230 | - * <p>The shutdown method is careful to close nested |
|
231 | - * appenders before closing regular appenders. This is allows |
|
232 | - * configurations where a regular appender is attached to a logger |
|
233 | - * and again to a nested appender. |
|
234 | - */ |
|
235 | - public function shutdown() { |
|
236 | - $this->root->removeAllAppenders(); |
|
237 | - $cats = $this->getCurrentLoggers(); |
|
238 | - $enumCats = count($cats); |
|
239 | - if($enumCats > 0) { |
|
240 | - for($i = 0; $i < $enumCats; $i++) { |
|
241 | - $cats[$i]->removeAllAppenders(); |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
221 | + /** |
|
222 | + * Shutting down a hierarchy will <i>safely</i> close and remove |
|
223 | + * all appenders in all categories including the root logger. |
|
224 | + * |
|
225 | + * <p>Some appenders such as {@link LoggerSocketAppender} |
|
226 | + * need to be closed before the |
|
227 | + * application exists. Otherwise, pending logging events might be |
|
228 | + * lost. |
|
229 | + * |
|
230 | + * <p>The shutdown method is careful to close nested |
|
231 | + * appenders before closing regular appenders. This is allows |
|
232 | + * configurations where a regular appender is attached to a logger |
|
233 | + * and again to a nested appender. |
|
234 | + */ |
|
235 | + public function shutdown() { |
|
236 | + $this->root->removeAllAppenders(); |
|
237 | + $cats = $this->getCurrentLoggers(); |
|
238 | + $enumCats = count($cats); |
|
239 | + if($enumCats > 0) { |
|
240 | + for($i = 0; $i < $enumCats; $i++) { |
|
241 | + $cats[$i]->removeAllAppenders(); |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | 245 | } |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @return Logger |
112 | 112 | */ |
113 | 113 | public function getLogger($name) { |
114 | - if(!isset($this->ht[$name])) { |
|
115 | - $this->ht[$name] = new Logger($name);; |
|
114 | + if (!isset($this->ht[$name])) { |
|
115 | + $this->ht[$name] = new Logger($name); ; |
|
116 | 116 | // TODO: isn't necessary, access via singleton? |
117 | 117 | // $this->ht[$name]->setHierarchy($this); |
118 | 118 | $nodes = explode('.', $name); |
119 | 119 | $firstNode = array_shift($nodes); |
120 | 120 | |
121 | 121 | // if name is not a first node but another first node is their |
122 | - if($firstNode != $name and isset($this->ht[$firstNode])) { |
|
122 | + if ($firstNode != $name and isset($this->ht[$firstNode])) { |
|
123 | 123 | $this->ht[$name]->setParent($this->ht[$firstNode]); |
124 | 124 | } else { |
125 | 125 | // if there is no father, set root logger as father |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | // if there are more nodes than one |
130 | - if(count($nodes) > 0) { |
|
130 | + if (count($nodes) > 0) { |
|
131 | 131 | // find parent node |
132 | - foreach($nodes as $node) { |
|
132 | + foreach ($nodes as $node) { |
|
133 | 133 | $parentNode = "$firstNode.$node"; |
134 | - if(isset($this->ht[$parentNode]) and $parentNode != $name) { |
|
134 | + if (isset($this->ht[$parentNode]) and $parentNode != $name) { |
|
135 | 135 | |
136 | 136 | $this->ht[$name]->setParent($this->ht[$parentNode]); |
137 | 137 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return LoggerRoot Get the root of this hierarchy. |
155 | 155 | */ |
156 | 156 | public function getRootLogger() { |
157 | - if(!isset($this->root) or $this->root == null) { |
|
157 | + if (!isset($this->root) or $this->root == null) { |
|
158 | 158 | $this->root = new LoggerRoot(); |
159 | 159 | } |
160 | 160 | return $this->root; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $this->shutDown(); |
200 | 200 | $loggers = $this->getCurrentLoggers(); |
201 | 201 | $enumLoggers = count($loggers); |
202 | - for($i = 0; $i < $enumLoggers; $i++) { |
|
202 | + for ($i = 0; $i < $enumLoggers; $i++) { |
|
203 | 203 | $loggers[$i]->setLevel(null); |
204 | 204 | $loggers[$i]->setAdditivity(true); |
205 | 205 | $loggers[$i]->removeAllAppenders(); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param LoggerLevel $l |
214 | 214 | */ |
215 | 215 | public function setThreshold(LoggerLevel $l) { |
216 | - if($l !== null) { |
|
216 | + if ($l !== null) { |
|
217 | 217 | $this->threshold = $l; |
218 | 218 | } |
219 | 219 | } |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | $this->root->removeAllAppenders(); |
237 | 237 | $cats = $this->getCurrentLoggers(); |
238 | 238 | $enumCats = count($cats); |
239 | - if($enumCats > 0) { |
|
240 | - for($i = 0; $i < $enumCats; $i++) { |
|
239 | + if ($enumCats > 0) { |
|
240 | + for ($i = 0; $i < $enumCats; $i++) { |
|
241 | 241 | $cats[$i]->removeAllAppenders(); |
242 | 242 | } |
243 | 243 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Two priorities are equal if their level fields are equal. |
80 | 80 | * |
81 | - * @param object $o |
|
82 | - * @return boolean |
|
81 | + * @param LoggerLevel $o |
|
82 | + * @return boolean|null |
|
83 | 83 | */ |
84 | 84 | public function equals($o) { |
85 | 85 | if($o instanceof LoggerLevel) { |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * Convert the string passed as argument to a level. If the |
221 | 221 | * conversion fails, then this method returns a DEBUG Level. |
222 | 222 | * |
223 | - * @param mixed $arg |
|
224 | - * @param LoggerLevel $default |
|
223 | + * @param string $arg |
|
224 | + * @param LoggerLevel $defaultLevel |
|
225 | 225 | * @static |
226 | 226 | */ |
227 | 227 | public static function toLevel($arg, $defaultLevel = null) { |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return boolean |
83 | 83 | */ |
84 | 84 | public function equals($o) { |
85 | - if($o instanceof LoggerLevel) { |
|
86 | - if($this->level == $o->level) { |
|
85 | + if ($o instanceof LoggerLevel) { |
|
86 | + if ($this->level == $o->level) { |
|
87 | 87 | return true; |
88 | 88 | } |
89 | 89 | } else { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @return LoggerLevel |
98 | 98 | */ |
99 | 99 | public static function getLevelOff() { |
100 | - if(!isset(self::$levelMap[LoggerLevel::OFF])) { |
|
100 | + if (!isset(self::$levelMap[LoggerLevel::OFF])) { |
|
101 | 101 | self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0); |
102 | 102 | } |
103 | 103 | return self::$levelMap[LoggerLevel::OFF]; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return LoggerLevel |
110 | 110 | */ |
111 | 111 | public static function getLevelFatal() { |
112 | - if(!isset(self::$levelMap[LoggerLevel::FATAL])) { |
|
112 | + if (!isset(self::$levelMap[LoggerLevel::FATAL])) { |
|
113 | 113 | self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0); |
114 | 114 | } |
115 | 115 | return self::$levelMap[LoggerLevel::FATAL]; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return LoggerLevel |
122 | 122 | */ |
123 | 123 | public static function getLevelError() { |
124 | - if(!isset(self::$levelMap[LoggerLevel::ERROR])) { |
|
124 | + if (!isset(self::$levelMap[LoggerLevel::ERROR])) { |
|
125 | 125 | self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3); |
126 | 126 | } |
127 | 127 | return self::$levelMap[LoggerLevel::ERROR]; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return LoggerLevel |
134 | 134 | */ |
135 | 135 | public static function getLevelWarn() { |
136 | - if(!isset(self::$levelMap[LoggerLevel::WARN])) { |
|
136 | + if (!isset(self::$levelMap[LoggerLevel::WARN])) { |
|
137 | 137 | self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4); |
138 | 138 | } |
139 | 139 | return self::$levelMap[LoggerLevel::WARN]; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return LoggerLevel |
146 | 146 | */ |
147 | 147 | public static function getLevelInfo() { |
148 | - if(!isset(self::$levelMap[LoggerLevel::INFO])) { |
|
148 | + if (!isset(self::$levelMap[LoggerLevel::INFO])) { |
|
149 | 149 | self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6); |
150 | 150 | } |
151 | 151 | return self::$levelMap[LoggerLevel::INFO]; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return LoggerLevel |
158 | 158 | */ |
159 | 159 | public static function getLevelDebug() { |
160 | - if(!isset(self::$levelMap[LoggerLevel::DEBUG])) { |
|
160 | + if (!isset(self::$levelMap[LoggerLevel::DEBUG])) { |
|
161 | 161 | self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7); |
162 | 162 | } |
163 | 163 | return self::$levelMap[LoggerLevel::DEBUG]; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @return LoggerLevel |
170 | 170 | */ |
171 | 171 | public static function getLevelAll() { |
172 | - if(!isset(self::$levelMap[LoggerLevel::ALL])) { |
|
172 | + if (!isset(self::$levelMap[LoggerLevel::ALL])) { |
|
173 | 173 | self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7); |
174 | 174 | } |
175 | 175 | return self::$levelMap[LoggerLevel::ALL]; |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @static |
226 | 226 | */ |
227 | 227 | public static function toLevel($arg, $defaultLevel = null) { |
228 | - if($defaultLevel === null) { |
|
228 | + if ($defaultLevel === null) { |
|
229 | 229 | return self::toLevel($arg, self::getLevelDebug()); |
230 | 230 | } else { |
231 | - if(is_int($arg)) { |
|
232 | - switch($arg) { |
|
231 | + if (is_int($arg)) { |
|
232 | + switch ($arg) { |
|
233 | 233 | case self::ALL: return self::getLevelAll(); |
234 | 234 | case self::DEBUG: return self::getLevelDebug(); |
235 | 235 | case self::INFO: return self::getLevelInfo(); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | default: return $defaultLevel; |
241 | 241 | } |
242 | 242 | } else { |
243 | - switch(strtoupper($arg)) { |
|
243 | + switch (strtoupper($arg)) { |
|
244 | 244 | case 'ALL': return self::getLevelAll(); |
245 | 245 | case 'DEBUG': return self::getLevelDebug(); |
246 | 246 | case 'INFO': return self::getLevelInfo(); |
@@ -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 | * Defines the minimum set of levels recognized by the system, that is |
@@ -33,224 +33,224 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class LoggerLevel { |
35 | 35 | |
36 | - const OFF = 2147483647; |
|
37 | - const FATAL = 50000; |
|
38 | - const ERROR = 40000; |
|
39 | - const WARN = 30000; |
|
40 | - const INFO = 20000; |
|
41 | - const DEBUG = 10000; |
|
42 | - const ALL = -2147483647; |
|
36 | + const OFF = 2147483647; |
|
37 | + const FATAL = 50000; |
|
38 | + const ERROR = 40000; |
|
39 | + const WARN = 30000; |
|
40 | + const INFO = 20000; |
|
41 | + const DEBUG = 10000; |
|
42 | + const ALL = -2147483647; |
|
43 | 43 | |
44 | - /** |
|
45 | - * TODO: check if still necessary or to be refactored |
|
46 | - * @var integer |
|
47 | - */ |
|
48 | - private $level; |
|
44 | + /** |
|
45 | + * TODO: check if still necessary or to be refactored |
|
46 | + * @var integer |
|
47 | + */ |
|
48 | + private $level; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Contains a list of instantiated levels |
|
52 | - */ |
|
53 | - private static $levelMap; |
|
50 | + /** |
|
51 | + * Contains a list of instantiated levels |
|
52 | + */ |
|
53 | + private static $levelMap; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - private $levelStr; |
|
55 | + /** |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + private $levelStr; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var integer |
|
62 | - */ |
|
63 | - private $syslogEquivalent; |
|
60 | + /** |
|
61 | + * @var integer |
|
62 | + */ |
|
63 | + private $syslogEquivalent; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Constructor |
|
67 | - * |
|
68 | - * @param integer $level |
|
69 | - * @param string $levelStr |
|
70 | - * @param integer $syslogEquivalent |
|
71 | - */ |
|
72 | - private function __construct($level, $levelStr, $syslogEquivalent) { |
|
73 | - $this->level = $level; |
|
74 | - $this->levelStr = $levelStr; |
|
75 | - $this->syslogEquivalent = $syslogEquivalent; |
|
76 | - } |
|
65 | + /** |
|
66 | + * Constructor |
|
67 | + * |
|
68 | + * @param integer $level |
|
69 | + * @param string $levelStr |
|
70 | + * @param integer $syslogEquivalent |
|
71 | + */ |
|
72 | + private function __construct($level, $levelStr, $syslogEquivalent) { |
|
73 | + $this->level = $level; |
|
74 | + $this->levelStr = $levelStr; |
|
75 | + $this->syslogEquivalent = $syslogEquivalent; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Two priorities are equal if their level fields are equal. |
|
80 | - * |
|
81 | - * @param object $o |
|
82 | - * @return boolean |
|
83 | - */ |
|
84 | - public function equals($o) { |
|
85 | - if($o instanceof LoggerLevel) { |
|
86 | - if($this->level == $o->level) { |
|
87 | - return true; |
|
88 | - } |
|
89 | - } else { |
|
90 | - return false; |
|
91 | - } |
|
92 | - } |
|
78 | + /** |
|
79 | + * Two priorities are equal if their level fields are equal. |
|
80 | + * |
|
81 | + * @param object $o |
|
82 | + * @return boolean |
|
83 | + */ |
|
84 | + public function equals($o) { |
|
85 | + if($o instanceof LoggerLevel) { |
|
86 | + if($this->level == $o->level) { |
|
87 | + return true; |
|
88 | + } |
|
89 | + } else { |
|
90 | + return false; |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Returns an Off Level |
|
96 | - * @static |
|
97 | - * @return LoggerLevel |
|
98 | - */ |
|
99 | - public static function getLevelOff() { |
|
100 | - if(!isset(self::$levelMap[LoggerLevel::OFF])) { |
|
101 | - self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0); |
|
102 | - } |
|
103 | - return self::$levelMap[LoggerLevel::OFF]; |
|
104 | - } |
|
94 | + /** |
|
95 | + * Returns an Off Level |
|
96 | + * @static |
|
97 | + * @return LoggerLevel |
|
98 | + */ |
|
99 | + public static function getLevelOff() { |
|
100 | + if(!isset(self::$levelMap[LoggerLevel::OFF])) { |
|
101 | + self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0); |
|
102 | + } |
|
103 | + return self::$levelMap[LoggerLevel::OFF]; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Returns a Fatal Level |
|
108 | - * @static |
|
109 | - * @return LoggerLevel |
|
110 | - */ |
|
111 | - public static function getLevelFatal() { |
|
112 | - if(!isset(self::$levelMap[LoggerLevel::FATAL])) { |
|
113 | - self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0); |
|
114 | - } |
|
115 | - return self::$levelMap[LoggerLevel::FATAL]; |
|
116 | - } |
|
106 | + /** |
|
107 | + * Returns a Fatal Level |
|
108 | + * @static |
|
109 | + * @return LoggerLevel |
|
110 | + */ |
|
111 | + public static function getLevelFatal() { |
|
112 | + if(!isset(self::$levelMap[LoggerLevel::FATAL])) { |
|
113 | + self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0); |
|
114 | + } |
|
115 | + return self::$levelMap[LoggerLevel::FATAL]; |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Returns an Error Level |
|
120 | - * @static |
|
121 | - * @return LoggerLevel |
|
122 | - */ |
|
123 | - public static function getLevelError() { |
|
124 | - if(!isset(self::$levelMap[LoggerLevel::ERROR])) { |
|
125 | - self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3); |
|
126 | - } |
|
127 | - return self::$levelMap[LoggerLevel::ERROR]; |
|
128 | - } |
|
118 | + /** |
|
119 | + * Returns an Error Level |
|
120 | + * @static |
|
121 | + * @return LoggerLevel |
|
122 | + */ |
|
123 | + public static function getLevelError() { |
|
124 | + if(!isset(self::$levelMap[LoggerLevel::ERROR])) { |
|
125 | + self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3); |
|
126 | + } |
|
127 | + return self::$levelMap[LoggerLevel::ERROR]; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Returns a Warn Level |
|
132 | - * @static |
|
133 | - * @return LoggerLevel |
|
134 | - */ |
|
135 | - public static function getLevelWarn() { |
|
136 | - if(!isset(self::$levelMap[LoggerLevel::WARN])) { |
|
137 | - self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4); |
|
138 | - } |
|
139 | - return self::$levelMap[LoggerLevel::WARN]; |
|
140 | - } |
|
130 | + /** |
|
131 | + * Returns a Warn Level |
|
132 | + * @static |
|
133 | + * @return LoggerLevel |
|
134 | + */ |
|
135 | + public static function getLevelWarn() { |
|
136 | + if(!isset(self::$levelMap[LoggerLevel::WARN])) { |
|
137 | + self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4); |
|
138 | + } |
|
139 | + return self::$levelMap[LoggerLevel::WARN]; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * Returns an Info Level |
|
144 | - * @static |
|
145 | - * @return LoggerLevel |
|
146 | - */ |
|
147 | - public static function getLevelInfo() { |
|
148 | - if(!isset(self::$levelMap[LoggerLevel::INFO])) { |
|
149 | - self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6); |
|
150 | - } |
|
151 | - return self::$levelMap[LoggerLevel::INFO]; |
|
152 | - } |
|
142 | + /** |
|
143 | + * Returns an Info Level |
|
144 | + * @static |
|
145 | + * @return LoggerLevel |
|
146 | + */ |
|
147 | + public static function getLevelInfo() { |
|
148 | + if(!isset(self::$levelMap[LoggerLevel::INFO])) { |
|
149 | + self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6); |
|
150 | + } |
|
151 | + return self::$levelMap[LoggerLevel::INFO]; |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Returns a Debug Level |
|
156 | - * @static |
|
157 | - * @return LoggerLevel |
|
158 | - */ |
|
159 | - public static function getLevelDebug() { |
|
160 | - if(!isset(self::$levelMap[LoggerLevel::DEBUG])) { |
|
161 | - self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7); |
|
162 | - } |
|
163 | - return self::$levelMap[LoggerLevel::DEBUG]; |
|
164 | - } |
|
154 | + /** |
|
155 | + * Returns a Debug Level |
|
156 | + * @static |
|
157 | + * @return LoggerLevel |
|
158 | + */ |
|
159 | + public static function getLevelDebug() { |
|
160 | + if(!isset(self::$levelMap[LoggerLevel::DEBUG])) { |
|
161 | + self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7); |
|
162 | + } |
|
163 | + return self::$levelMap[LoggerLevel::DEBUG]; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * Returns an All Level |
|
168 | - * @static |
|
169 | - * @return LoggerLevel |
|
170 | - */ |
|
171 | - public static function getLevelAll() { |
|
172 | - if(!isset(self::$levelMap[LoggerLevel::ALL])) { |
|
173 | - self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7); |
|
174 | - } |
|
175 | - return self::$levelMap[LoggerLevel::ALL]; |
|
176 | - } |
|
166 | + /** |
|
167 | + * Returns an All Level |
|
168 | + * @static |
|
169 | + * @return LoggerLevel |
|
170 | + */ |
|
171 | + public static function getLevelAll() { |
|
172 | + if(!isset(self::$levelMap[LoggerLevel::ALL])) { |
|
173 | + self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7); |
|
174 | + } |
|
175 | + return self::$levelMap[LoggerLevel::ALL]; |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Return the syslog equivalent of this priority as an integer. |
|
180 | - * @final |
|
181 | - * @return integer |
|
182 | - */ |
|
183 | - public function getSyslogEquivalent() { |
|
184 | - return $this->syslogEquivalent; |
|
185 | - } |
|
178 | + /** |
|
179 | + * Return the syslog equivalent of this priority as an integer. |
|
180 | + * @final |
|
181 | + * @return integer |
|
182 | + */ |
|
183 | + public function getSyslogEquivalent() { |
|
184 | + return $this->syslogEquivalent; |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * Returns <i>true</i> if this level has a higher or equal |
|
189 | - * level than the level passed as argument, <i>false</i> |
|
190 | - * otherwise. |
|
191 | - * |
|
192 | - * <p>You should think twice before overriding the default |
|
193 | - * implementation of <i>isGreaterOrEqual</i> method. |
|
194 | - * |
|
195 | - * @param LoggerLevel $r |
|
196 | - * @return boolean |
|
197 | - */ |
|
198 | - public function isGreaterOrEqual($r) { |
|
199 | - return $this->level >= $r->level; |
|
200 | - } |
|
187 | + /** |
|
188 | + * Returns <i>true</i> if this level has a higher or equal |
|
189 | + * level than the level passed as argument, <i>false</i> |
|
190 | + * otherwise. |
|
191 | + * |
|
192 | + * <p>You should think twice before overriding the default |
|
193 | + * implementation of <i>isGreaterOrEqual</i> method. |
|
194 | + * |
|
195 | + * @param LoggerLevel $r |
|
196 | + * @return boolean |
|
197 | + */ |
|
198 | + public function isGreaterOrEqual($r) { |
|
199 | + return $this->level >= $r->level; |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * Returns the string representation of this priority. |
|
204 | - * @return string |
|
205 | - * @final |
|
206 | - */ |
|
207 | - public function toString() { |
|
208 | - return $this->levelStr; |
|
209 | - } |
|
202 | + /** |
|
203 | + * Returns the string representation of this priority. |
|
204 | + * @return string |
|
205 | + * @final |
|
206 | + */ |
|
207 | + public function toString() { |
|
208 | + return $this->levelStr; |
|
209 | + } |
|
210 | 210 | |
211 | - /** |
|
212 | - * Returns the integer representation of this level. |
|
213 | - * @return integer |
|
214 | - */ |
|
215 | - public function toInt() { |
|
216 | - return $this->level; |
|
217 | - } |
|
211 | + /** |
|
212 | + * Returns the integer representation of this level. |
|
213 | + * @return integer |
|
214 | + */ |
|
215 | + public function toInt() { |
|
216 | + return $this->level; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * Convert the string passed as argument to a level. If the |
|
221 | - * conversion fails, then this method returns a DEBUG Level. |
|
222 | - * |
|
223 | - * @param mixed $arg |
|
224 | - * @param LoggerLevel $default |
|
225 | - * @static |
|
226 | - */ |
|
227 | - public static function toLevel($arg, $defaultLevel = null) { |
|
228 | - if($defaultLevel === null) { |
|
229 | - return self::toLevel($arg, self::getLevelDebug()); |
|
230 | - } else { |
|
231 | - if(is_int($arg)) { |
|
232 | - switch($arg) { |
|
233 | - case self::ALL: return self::getLevelAll(); |
|
234 | - case self::DEBUG: return self::getLevelDebug(); |
|
235 | - case self::INFO: return self::getLevelInfo(); |
|
236 | - case self::WARN: return self::getLevelWarn(); |
|
237 | - case self::ERROR: return self::getLevelError(); |
|
238 | - case self::FATAL: return self::getLevelFatal(); |
|
239 | - case self::OFF: return self::getLevelOff(); |
|
240 | - default: return $defaultLevel; |
|
241 | - } |
|
242 | - } else { |
|
243 | - switch(strtoupper($arg)) { |
|
244 | - case 'ALL': return self::getLevelAll(); |
|
245 | - case 'DEBUG': return self::getLevelDebug(); |
|
246 | - case 'INFO': return self::getLevelInfo(); |
|
247 | - case 'WARN': return self::getLevelWarn(); |
|
248 | - case 'ERROR': return self::getLevelError(); |
|
249 | - case 'FATAL': return self::getLevelFatal(); |
|
250 | - case 'OFF': return self::getLevelOff(); |
|
251 | - default: return $defaultLevel; |
|
252 | - } |
|
253 | - } |
|
254 | - } |
|
255 | - } |
|
219 | + /** |
|
220 | + * Convert the string passed as argument to a level. If the |
|
221 | + * conversion fails, then this method returns a DEBUG Level. |
|
222 | + * |
|
223 | + * @param mixed $arg |
|
224 | + * @param LoggerLevel $default |
|
225 | + * @static |
|
226 | + */ |
|
227 | + public static function toLevel($arg, $defaultLevel = null) { |
|
228 | + if($defaultLevel === null) { |
|
229 | + return self::toLevel($arg, self::getLevelDebug()); |
|
230 | + } else { |
|
231 | + if(is_int($arg)) { |
|
232 | + switch($arg) { |
|
233 | + case self::ALL: return self::getLevelAll(); |
|
234 | + case self::DEBUG: return self::getLevelDebug(); |
|
235 | + case self::INFO: return self::getLevelInfo(); |
|
236 | + case self::WARN: return self::getLevelWarn(); |
|
237 | + case self::ERROR: return self::getLevelError(); |
|
238 | + case self::FATAL: return self::getLevelFatal(); |
|
239 | + case self::OFF: return self::getLevelOff(); |
|
240 | + default: return $defaultLevel; |
|
241 | + } |
|
242 | + } else { |
|
243 | + switch(strtoupper($arg)) { |
|
244 | + case 'ALL': return self::getLevelAll(); |
|
245 | + case 'DEBUG': return self::getLevelDebug(); |
|
246 | + case 'INFO': return self::getLevelInfo(); |
|
247 | + case 'WARN': return self::getLevelWarn(); |
|
248 | + case 'ERROR': return self::getLevelError(); |
|
249 | + case 'FATAL': return self::getLevelFatal(); |
|
250 | + case 'OFF': return self::getLevelOff(); |
|
251 | + default: return $defaultLevel; |
|
252 | + } |
|
253 | + } |
|
254 | + } |
|
255 | + } |
|
256 | 256 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}. |
63 | 63 | * |
64 | 64 | * @param array $trace |
65 | - * @param mixed $caller |
|
65 | + * @param string $fqcn |
|
66 | 66 | */ |
67 | 67 | public function __construct($trace, $fqcn = null) { |
68 | 68 | $this->lineNumber = isset($trace['line']) ? $trace['line'] : null; |
@@ -69,8 +69,8 @@ |
||
69 | 69 | $this->fileName = isset($trace['file']) ? $trace['file'] : null; |
70 | 70 | $this->className = isset($trace['class']) ? $trace['class'] : null; |
71 | 71 | $this->methodName = isset($trace['function']) ? $trace['function'] : null; |
72 | - $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . |
|
73 | - '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')'; |
|
72 | + $this->fullInfo = $this->getClassName().'.'.$this->getMethodName(). |
|
73 | + '('.$this->getFileName().':'.$this->getLineNumber().')'; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public function getClassName() { |
@@ -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 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * LoggerLoggingEvent are filled when actually needed. |
118 | 118 | * |
119 | 119 | * @param string $fqcn name of the caller class. |
120 | - * @param mixed $logger The {@link Logger} category of this event or the logger name. |
|
120 | + * @param Logger $logger The {@link Logger} category of this event or the logger name. |
|
121 | 121 | * @param LoggerLevel $priority The level of this event. |
122 | 122 | * @param mixed $message The message of this event. |
123 | 123 | * @param integer $timeStamp the timestamp of this logging event. |
@@ -249,6 +249,7 @@ discard block |
||
249 | 249 | /** |
250 | 250 | * Returns the the context corresponding to the <code>key</code> |
251 | 251 | * parameter. |
252 | + * @param string $key |
|
252 | 253 | * @return string |
253 | 254 | */ |
254 | 255 | public function getMDC($key) { |
@@ -304,7 +305,7 @@ discard block |
||
304 | 305 | |
305 | 306 | /** |
306 | 307 | * Calculates the time of this event. |
307 | - * @return the time after event starttime when this event has occured |
|
308 | + * @return string time after event starttime when this event has occured |
|
308 | 309 | */ |
309 | 310 | public function getTime() { |
310 | 311 | $eventTime = (float)$this->getTimeStamp(); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) { |
126 | 126 | $this->fqcn = $fqcn; |
127 | - if($logger instanceof Logger) { |
|
127 | + if ($logger instanceof Logger) { |
|
128 | 128 | $this->logger = $logger; |
129 | 129 | $this->categoryName = $logger->getName(); |
130 | 130 | } else { |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | } |
133 | 133 | $this->level = $priority; |
134 | 134 | $this->message = $message; |
135 | - if($timeStamp !== null && is_float($timeStamp)) { |
|
135 | + if ($timeStamp !== null && is_float($timeStamp)) { |
|
136 | 136 | $this->timeStamp = $timeStamp; |
137 | 137 | } else { |
138 | - if(function_exists('microtime')) { |
|
138 | + if (function_exists('microtime')) { |
|
139 | 139 | // get microtime as float |
140 | 140 | $this->timeStamp = microtime(true); |
141 | 141 | } else { |
@@ -154,20 +154,20 @@ discard block |
||
154 | 154 | * @return LoggerLocationInfo |
155 | 155 | */ |
156 | 156 | public function getLocationInformation() { |
157 | - if($this->locationInfo === null) { |
|
157 | + if ($this->locationInfo === null) { |
|
158 | 158 | |
159 | 159 | $locationInfo = array(); |
160 | 160 | |
161 | - if(function_exists('debug_backtrace')) { |
|
161 | + if (function_exists('debug_backtrace')) { |
|
162 | 162 | $trace = debug_backtrace(); |
163 | 163 | $prevHop = null; |
164 | 164 | // make a downsearch to identify the caller |
165 | 165 | $hop = array_pop($trace); |
166 | - while($hop !== null) { |
|
167 | - if(isset($hop['class'])) { |
|
166 | + while ($hop !== null) { |
|
167 | + if (isset($hop['class'])) { |
|
168 | 168 | // we are sometimes in functions = no class available: avoid php warning here |
169 | 169 | $className = strtolower($hop['class']); |
170 | - if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or |
|
170 | + if (!empty($className) and ($className == 'logger' or $className == 'loggercategory' or |
|
171 | 171 | strtolower(get_parent_class($className)) == 'logger' or |
172 | 172 | strtolower(get_parent_class($className)) == 'loggercategory')) { |
173 | 173 | $locationInfo['line'] = $hop['line']; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $hop = array_pop($trace); |
180 | 180 | } |
181 | 181 | $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; |
182 | - if(isset($prevHop['function']) and |
|
182 | + if (isset($prevHop['function']) and |
|
183 | 183 | $prevHop['function'] !== 'include' and |
184 | 184 | $prevHop['function'] !== 'include_once' and |
185 | 185 | $prevHop['function'] !== 'require' and |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return mixed |
225 | 225 | */ |
226 | 226 | public function getMessage() { |
227 | - if($this->message !== null) { |
|
227 | + if ($this->message !== null) { |
|
228 | 228 | return $this->message; |
229 | 229 | } else { |
230 | 230 | return $this->getRenderedMessage(); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @return string |
240 | 240 | */ |
241 | 241 | public function getNDC() { |
242 | - if($this->ndcLookupRequired) { |
|
242 | + if ($this->ndcLookupRequired) { |
|
243 | 243 | $this->ndcLookupRequired = false; |
244 | 244 | $this->ndc = implode(' ', LoggerNDC::get()); |
245 | 245 | } |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | * @return string |
261 | 261 | */ |
262 | 262 | public function getRenderedMessage() { |
263 | - if($this->renderedMessage === null and $this->message !== null) { |
|
264 | - if(is_string($this->message)) { |
|
263 | + if ($this->renderedMessage === null and $this->message !== null) { |
|
264 | + if (is_string($this->message)) { |
|
265 | 265 | $this->renderedMessage = $this->message; |
266 | 266 | } else { |
267 | 267 | // $this->logger might be null or an instance of Logger or RootLogger |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | // TODO: Logger::getHierarchy() is marked @deprecated! |
271 | 271 | $repository = Logger::getHierarchy(); |
272 | 272 | $rendererMap = $repository->getRendererMap(); |
273 | - $this->renderedMessage= $rendererMap->findAndRender($this->message); |
|
273 | + $this->renderedMessage = $rendererMap->findAndRender($this->message); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | return $this->renderedMessage; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @static |
285 | 285 | */ |
286 | 286 | public static function getStartTime() { |
287 | - if(!isset(self::$startTime)) { |
|
287 | + if (!isset(self::$startTime)) { |
|
288 | 288 | if (function_exists('microtime')) { |
289 | 289 | // microtime as float |
290 | 290 | self::$startTime = microtime(true); |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | * @return the time after event starttime when this event has occured |
308 | 308 | */ |
309 | 309 | public function getTime() { |
310 | - $eventTime = (float)$this->getTimeStamp(); |
|
311 | - $eventStartTime = (float)LoggerLoggingEvent::getStartTime(); |
|
310 | + $eventTime = (float) $this->getTimeStamp(); |
|
311 | + $eventStartTime = (float) LoggerLoggingEvent::getStartTime(); |
|
312 | 312 | return number_format(($eventTime - $eventStartTime) * 1000, 0, '', ''); |
313 | 313 | } |
314 | 314 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function getThreadName() { |
319 | 319 | if ($this->threadName === null) { |
320 | - $this->threadName = (string)getmypid(); |
|
320 | + $this->threadName = (string) getmypid(); |
|
321 | 321 | } |
322 | 322 | return $this->threadName; |
323 | 323 | } |
@@ -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 |
@@ -47,6 +47,10 @@ discard block |
||
47 | 47 | * @static |
48 | 48 | */ |
49 | 49 | // TODO: check, if this is really useful |
50 | + |
|
51 | + /** |
|
52 | + * @param string $prefix |
|
53 | + */ |
|
50 | 54 | public static function setPropertiesByObject($obj, $properties, $prefix) { |
51 | 55 | $pSetter = new LoggerReflectionUtils($obj); |
52 | 56 | return $pSetter->setProperties($properties, $prefix); |
@@ -123,7 +127,7 @@ discard block |
||
123 | 127 | /** |
124 | 128 | * Creates an instances from the given class name. |
125 | 129 | * |
126 | - * @param string $classname |
|
130 | + * @param string $class |
|
127 | 131 | * @return an object from the class with the given classname |
128 | 132 | */ |
129 | 133 | public static function createObject($class) { |
@@ -18,123 +18,123 @@ |
||
18 | 18 | * @package log4php |
19 | 19 | */ |
20 | 20 | |
21 | - /** |
|
22 | - * Provides methods for reflective use on php objects |
|
23 | - * @package log4php |
|
24 | - */ |
|
21 | + /** |
|
22 | + * Provides methods for reflective use on php objects |
|
23 | + * @package log4php |
|
24 | + */ |
|
25 | 25 | class LoggerReflectionUtils { |
26 | - /** the target object */ |
|
27 | - private $obj; |
|
26 | + /** the target object */ |
|
27 | + private $obj; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Create a new LoggerReflectionUtils for the specified Object. |
|
31 | - * This is done in prepartion for invoking {@link setProperty()} |
|
32 | - * one or more times. |
|
33 | - * @param object &$obj the object for which to set properties |
|
34 | - */ |
|
35 | - public function __construct($obj) { |
|
36 | - $this->obj = $obj; |
|
37 | - } |
|
29 | + /** |
|
30 | + * Create a new LoggerReflectionUtils for the specified Object. |
|
31 | + * This is done in prepartion for invoking {@link setProperty()} |
|
32 | + * one or more times. |
|
33 | + * @param object &$obj the object for which to set properties |
|
34 | + */ |
|
35 | + public function __construct($obj) { |
|
36 | + $this->obj = $obj; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Set the properties of an object passed as a parameter in one |
|
41 | - * go. The <code>properties</code> are parsed relative to a |
|
42 | - * <code>prefix</code>. |
|
43 | - * |
|
44 | - * @param object $obj The object to configure. |
|
45 | - * @param array $properties An array containing keys and values. |
|
46 | - * @param string $prefix Only keys having the specified prefix will be set. |
|
47 | - * @static |
|
48 | - */ |
|
49 | - // TODO: check, if this is really useful |
|
50 | - public static function setPropertiesByObject($obj, $properties, $prefix) { |
|
51 | - $pSetter = new LoggerReflectionUtils($obj); |
|
52 | - return $pSetter->setProperties($properties, $prefix); |
|
53 | - } |
|
39 | + /** |
|
40 | + * Set the properties of an object passed as a parameter in one |
|
41 | + * go. The <code>properties</code> are parsed relative to a |
|
42 | + * <code>prefix</code>. |
|
43 | + * |
|
44 | + * @param object $obj The object to configure. |
|
45 | + * @param array $properties An array containing keys and values. |
|
46 | + * @param string $prefix Only keys having the specified prefix will be set. |
|
47 | + * @static |
|
48 | + */ |
|
49 | + // TODO: check, if this is really useful |
|
50 | + public static function setPropertiesByObject($obj, $properties, $prefix) { |
|
51 | + $pSetter = new LoggerReflectionUtils($obj); |
|
52 | + return $pSetter->setProperties($properties, $prefix); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Set the properites for the object that match the |
|
58 | - * <code>prefix</code> passed as parameter. |
|
59 | - * |
|
60 | - * Example: |
|
61 | - * |
|
62 | - * $arr['xxxname'] = 'Joe'; |
|
63 | - * $arr['xxxmale'] = true; |
|
64 | - * and prefix xxx causes setName and setMale. |
|
65 | - * |
|
66 | - * @param array $properties An array containing keys and values. |
|
67 | - * @param string $prefix Only keys having the specified prefix will be set. |
|
68 | - */ |
|
69 | - // TODO: check, if this is really useful |
|
70 | - public function setProperties($properties, $prefix) { |
|
71 | - $len = strlen($prefix); |
|
72 | - while(list($key,) = each($properties)) { |
|
73 | - if(strpos($key, $prefix) === 0) { |
|
74 | - if(strpos($key, '.', ($len + 1)) > 0) { |
|
75 | - continue; |
|
76 | - } |
|
77 | - $value = LoggerOptionConverter::findAndSubst($key, $properties); |
|
78 | - $key = substr($key, $len); |
|
79 | - if($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
80 | - continue; |
|
81 | - } |
|
82 | - $this->setProperty($key, $value); |
|
83 | - } |
|
84 | - } |
|
85 | - $this->activate(); |
|
86 | - } |
|
56 | + /** |
|
57 | + * Set the properites for the object that match the |
|
58 | + * <code>prefix</code> passed as parameter. |
|
59 | + * |
|
60 | + * Example: |
|
61 | + * |
|
62 | + * $arr['xxxname'] = 'Joe'; |
|
63 | + * $arr['xxxmale'] = true; |
|
64 | + * and prefix xxx causes setName and setMale. |
|
65 | + * |
|
66 | + * @param array $properties An array containing keys and values. |
|
67 | + * @param string $prefix Only keys having the specified prefix will be set. |
|
68 | + */ |
|
69 | + // TODO: check, if this is really useful |
|
70 | + public function setProperties($properties, $prefix) { |
|
71 | + $len = strlen($prefix); |
|
72 | + while(list($key,) = each($properties)) { |
|
73 | + if(strpos($key, $prefix) === 0) { |
|
74 | + if(strpos($key, '.', ($len + 1)) > 0) { |
|
75 | + continue; |
|
76 | + } |
|
77 | + $value = LoggerOptionConverter::findAndSubst($key, $properties); |
|
78 | + $key = substr($key, $len); |
|
79 | + if($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
80 | + continue; |
|
81 | + } |
|
82 | + $this->setProperty($key, $value); |
|
83 | + } |
|
84 | + } |
|
85 | + $this->activate(); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Set a property on this PropertySetter's Object. If successful, this |
|
90 | - * method will invoke a setter method on the underlying Object. The |
|
91 | - * setter is the one for the specified property name and the value is |
|
92 | - * determined partly from the setter argument type and partly from the |
|
93 | - * value specified in the call to this method. |
|
94 | - * |
|
95 | - * <p>If the setter expects a String no conversion is necessary. |
|
96 | - * If it expects an int, then an attempt is made to convert 'value' |
|
97 | - * to an int using new Integer(value). If the setter expects a boolean, |
|
98 | - * the conversion is by new Boolean(value). |
|
99 | - * |
|
100 | - * @param string $name name of the property |
|
101 | - * @param string $value String value of the property |
|
102 | - */ |
|
103 | - public function setProperty($name, $value) { |
|
104 | - if($value === null) { |
|
105 | - return; |
|
106 | - } |
|
88 | + /** |
|
89 | + * Set a property on this PropertySetter's Object. If successful, this |
|
90 | + * method will invoke a setter method on the underlying Object. The |
|
91 | + * setter is the one for the specified property name and the value is |
|
92 | + * determined partly from the setter argument type and partly from the |
|
93 | + * value specified in the call to this method. |
|
94 | + * |
|
95 | + * <p>If the setter expects a String no conversion is necessary. |
|
96 | + * If it expects an int, then an attempt is made to convert 'value' |
|
97 | + * to an int using new Integer(value). If the setter expects a boolean, |
|
98 | + * the conversion is by new Boolean(value). |
|
99 | + * |
|
100 | + * @param string $name name of the property |
|
101 | + * @param string $value String value of the property |
|
102 | + */ |
|
103 | + public function setProperty($name, $value) { |
|
104 | + if($value === null) { |
|
105 | + return; |
|
106 | + } |
|
107 | 107 | |
108 | - $method = "set" . ucfirst($name); |
|
108 | + $method = "set" . ucfirst($name); |
|
109 | 109 | |
110 | - if(!method_exists($this->obj, $method)) { |
|
111 | - throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!"); |
|
112 | - } else { |
|
113 | - return call_user_func(array($this->obj, $method), $value); |
|
114 | - } |
|
115 | - } |
|
110 | + if(!method_exists($this->obj, $method)) { |
|
111 | + throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!"); |
|
112 | + } else { |
|
113 | + return call_user_func(array($this->obj, $method), $value); |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | - public function activate() { |
|
118 | - if(method_exists($this->obj, 'activateoptions')) { |
|
119 | - return call_user_func(array($this->obj, 'activateoptions')); |
|
120 | - } |
|
121 | - } |
|
117 | + public function activate() { |
|
118 | + if(method_exists($this->obj, 'activateoptions')) { |
|
119 | + return call_user_func(array($this->obj, 'activateoptions')); |
|
120 | + } |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Creates an instances from the given class name. |
|
125 | - * |
|
126 | - * @param string $classname |
|
127 | - * @return an object from the class with the given classname |
|
128 | - */ |
|
129 | - public static function createObject($class) { |
|
130 | - if(!empty($class)) { |
|
131 | - $class = basename($class); |
|
132 | - return new $class(); |
|
133 | - } |
|
134 | - return null; |
|
135 | - } |
|
123 | + /** |
|
124 | + * Creates an instances from the given class name. |
|
125 | + * |
|
126 | + * @param string $classname |
|
127 | + * @return an object from the class with the given classname |
|
128 | + */ |
|
129 | + public static function createObject($class) { |
|
130 | + if(!empty($class)) { |
|
131 | + $class = basename($class); |
|
132 | + return new $class(); |
|
133 | + } |
|
134 | + return null; |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
137 | + /** |
|
138 | 138 | * @param object $object |
139 | 139 | * @param string $name |
140 | 140 | * @param mixed $value |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | // TODO: check, if this is really useful |
70 | 70 | public function setProperties($properties, $prefix) { |
71 | 71 | $len = strlen($prefix); |
72 | - while(list($key,) = each($properties)) { |
|
73 | - if(strpos($key, $prefix) === 0) { |
|
74 | - if(strpos($key, '.', ($len + 1)) > 0) { |
|
72 | + while (list($key,) = each($properties)) { |
|
73 | + if (strpos($key, $prefix) === 0) { |
|
74 | + if (strpos($key, '.', ($len + 1)) > 0) { |
|
75 | 75 | continue; |
76 | 76 | } |
77 | 77 | $value = LoggerOptionConverter::findAndSubst($key, $properties); |
78 | 78 | $key = substr($key, $len); |
79 | - if($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
79 | + if ($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
80 | 80 | continue; |
81 | 81 | } |
82 | 82 | $this->setProperty($key, $value); |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | * @param string $value String value of the property |
102 | 102 | */ |
103 | 103 | public function setProperty($name, $value) { |
104 | - if($value === null) { |
|
104 | + if ($value === null) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - $method = "set" . ucfirst($name); |
|
108 | + $method = "set".ucfirst($name); |
|
109 | 109 | |
110 | - if(!method_exists($this->obj, $method)) { |
|
110 | + if (!method_exists($this->obj, $method)) { |
|
111 | 111 | throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!"); |
112 | 112 | } else { |
113 | 113 | return call_user_func(array($this->obj, $method), $value); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | public function activate() { |
118 | - if(method_exists($this->obj, 'activateoptions')) { |
|
118 | + if (method_exists($this->obj, 'activateoptions')) { |
|
119 | 119 | return call_user_func(array($this->obj, 'activateoptions')); |
120 | 120 | } |
121 | 121 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return an object from the class with the given classname |
128 | 128 | */ |
129 | 129 | public static function createObject($class) { |
130 | - if(!empty($class)) { |
|
130 | + if (!empty($class)) { |
|
131 | 131 | $class = basename($class); |
132 | 132 | return new $class(); |
133 | 133 | } |
@@ -58,7 +58,6 @@ discard block |
||
58 | 58 | * Add a renderer to a hierarchy passed as parameter. |
59 | 59 | * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
60 | 60 | * |
61 | - * @param LoggerHierarchy $repository a logger repository. |
|
62 | 61 | * @param string $renderedClassName |
63 | 62 | * @param string $renderingClassName |
64 | 63 | * @static |
@@ -108,7 +107,7 @@ discard block |
||
108 | 107 | * class of the object parameter. |
109 | 108 | * |
110 | 109 | * @param mixed $o |
111 | - * @return string |
|
110 | + * @return LoggerRendererObject |
|
112 | 111 | */ |
113 | 112 | public function getByObject($o) { |
114 | 113 | return ($o == null) ? null : $this->getByClassName(get_class($o)); |
@@ -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 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function addRenderer($renderedClassName, $renderingClassName) { |
67 | 67 | $renderer = LoggerReflectionUtils::createObject($renderingClassName); |
68 | - if($renderer == null) { |
|
68 | + if ($renderer == null) { |
|
69 | 69 | return; |
70 | 70 | } else { |
71 | 71 | $this->put($renderedClassName, $renderer); |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | * @return string |
87 | 87 | */ |
88 | 88 | public function findAndRender($o) { |
89 | - if($o == null) { |
|
89 | + if ($o == null) { |
|
90 | 90 | return null; |
91 | 91 | } else { |
92 | - if(is_object($o)) { |
|
92 | + if (is_object($o)) { |
|
93 | 93 | $renderer = $this->getByObject($o); |
94 | - if($renderer !== null) { |
|
94 | + if ($renderer !== null) { |
|
95 | 95 | return $renderer->render($o); |
96 | 96 | } else { |
97 | 97 | return null; |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getByClassName($class) { |
128 | 128 | $r = null; |
129 | - for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
130 | - if(isset($this->map[$c])) { |
|
129 | + for ($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
130 | + if (isset($this->map[$c])) { |
|
131 | 131 | return $this->map[$c]; |
132 | 132 | } |
133 | 133 | } |
@@ -98,7 +98,6 @@ |
||
98 | 98 | /** |
99 | 99 | * Render a background image over a rectangular area |
100 | 100 | * |
101 | - * @param string $img The background image to load |
|
102 | 101 | * @param float $x The left edge of the rectangular area |
103 | 102 | * @param float $y The top edge of the rectangular area |
104 | 103 | * @param float $width The width of the rectangular area |
@@ -299,21 +299,21 @@ discard block |
||
299 | 299 | |
300 | 300 | switch (strtolower($ext)) { |
301 | 301 | |
302 | - case "png": |
|
303 | - $src = imagecreatefrompng($img); |
|
304 | - break; |
|
302 | + case "png": |
|
303 | + $src = imagecreatefrompng($img); |
|
304 | + break; |
|
305 | 305 | |
306 | - case "jpg": |
|
307 | - case "jpeg": |
|
308 | - $src = imagecreatefromjpeg($img); |
|
309 | - break; |
|
306 | + case "jpg": |
|
307 | + case "jpeg": |
|
308 | + $src = imagecreatefromjpeg($img); |
|
309 | + break; |
|
310 | 310 | |
311 | - case "gif": |
|
312 | - $src = imagecreatefromgif($img); |
|
313 | - break; |
|
311 | + case "gif": |
|
312 | + $src = imagecreatefromgif($img); |
|
313 | + break; |
|
314 | 314 | |
315 | - default: |
|
316 | - return; // Unsupported image type |
|
315 | + default: |
|
316 | + return; // Unsupported image type |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | if ($src == null) { |
@@ -475,22 +475,22 @@ discard block |
||
475 | 475 | |
476 | 476 | switch ($side) { |
477 | 477 | |
478 | - case "top": |
|
479 | - $delta = $top / 2; |
|
480 | - case "bottom": |
|
481 | - $delta = isset($delta) ? $delta : -$bottom / 2; |
|
482 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
483 | - break; |
|
484 | - |
|
485 | - case "left": |
|
486 | - $delta = $left / 2; |
|
487 | - case "right": |
|
488 | - $delta = isset($delta) ? $delta : - $right / 2; |
|
489 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
490 | - break; |
|
491 | - |
|
492 | - default: |
|
493 | - return; |
|
478 | + case "top": |
|
479 | + $delta = $top / 2; |
|
480 | + case "bottom": |
|
481 | + $delta = isset($delta) ? $delta : -$bottom / 2; |
|
482 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
483 | + break; |
|
484 | + |
|
485 | + case "left": |
|
486 | + $delta = $left / 2; |
|
487 | + case "right": |
|
488 | + $delta = isset($delta) ? $delta : - $right / 2; |
|
489 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
490 | + break; |
|
491 | + |
|
492 | + default: |
|
493 | + return; |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | } |
@@ -501,22 +501,22 @@ discard block |
||
501 | 501 | |
502 | 502 | switch ($side) { |
503 | 503 | |
504 | - case "top": |
|
505 | - $delta = $top / 2; |
|
506 | - case "bottom": |
|
507 | - $delta = isset($delta) ? $delta : -$bottom / 2; |
|
508 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
509 | - break; |
|
510 | - |
|
511 | - case "left": |
|
512 | - $delta = $left / 2; |
|
513 | - case "right": |
|
514 | - $delta = isset($delta) ? $delta : - $right / 2; |
|
515 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
516 | - break; |
|
517 | - |
|
518 | - default: |
|
519 | - return; |
|
504 | + case "top": |
|
505 | + $delta = $top / 2; |
|
506 | + case "bottom": |
|
507 | + $delta = isset($delta) ? $delta : -$bottom / 2; |
|
508 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
509 | + break; |
|
510 | + |
|
511 | + case "left": |
|
512 | + $delta = $left / 2; |
|
513 | + case "right": |
|
514 | + $delta = isset($delta) ? $delta : - $right / 2; |
|
515 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
516 | + break; |
|
517 | + |
|
518 | + default: |
|
519 | + return; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | } |
@@ -528,57 +528,57 @@ discard block |
||
528 | 528 | // All this polygon business is for beveled corners... |
529 | 529 | switch ($side) { |
530 | 530 | |
531 | - case "top": |
|
532 | - if ( $corner_style === "bevel" ) { |
|
531 | + case "top": |
|
532 | + if ( $corner_style === "bevel" ) { |
|
533 | 533 | |
534 | - $points = array($x, $y, |
|
535 | - $x + $length, $y, |
|
536 | - $x + $length - $right, $y + $top, |
|
537 | - $x + $left, $y + $top); |
|
538 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
539 | - } else |
|
540 | - $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
534 | + $points = array($x, $y, |
|
535 | + $x + $length, $y, |
|
536 | + $x + $length - $right, $y + $top, |
|
537 | + $x + $left, $y + $top); |
|
538 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
539 | + } else |
|
540 | + $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
541 | 541 | |
542 | - break; |
|
542 | + break; |
|
543 | 543 | |
544 | - case "bottom": |
|
545 | - if ( $corner_style === "bevel" ) { |
|
546 | - $points = array($x, $y, |
|
547 | - $x + $length, $y, |
|
548 | - $x + $length - $right, $y - $bottom, |
|
549 | - $x + $left, $y - $bottom); |
|
550 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
551 | - } else |
|
552 | - $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
544 | + case "bottom": |
|
545 | + if ( $corner_style === "bevel" ) { |
|
546 | + $points = array($x, $y, |
|
547 | + $x + $length, $y, |
|
548 | + $x + $length - $right, $y - $bottom, |
|
549 | + $x + $left, $y - $bottom); |
|
550 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
551 | + } else |
|
552 | + $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
553 | 553 | |
554 | - break; |
|
554 | + break; |
|
555 | 555 | |
556 | - case "left": |
|
557 | - if ( $corner_style === "bevel" ) { |
|
558 | - $points = array($x, $y, |
|
559 | - $x, $y + $length, |
|
560 | - $x + $left, $y + $length - $bottom, |
|
561 | - $x + $left, $y + $top); |
|
562 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
563 | - } else |
|
564 | - $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
556 | + case "left": |
|
557 | + if ( $corner_style === "bevel" ) { |
|
558 | + $points = array($x, $y, |
|
559 | + $x, $y + $length, |
|
560 | + $x + $left, $y + $length - $bottom, |
|
561 | + $x + $left, $y + $top); |
|
562 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
563 | + } else |
|
564 | + $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
565 | 565 | |
566 | - break; |
|
566 | + break; |
|
567 | 567 | |
568 | - case "right": |
|
569 | - if ( $corner_style === "bevel" ) { |
|
570 | - $points = array($x, $y, |
|
571 | - $x, $y + $length, |
|
572 | - $x - $right, $y + $length - $bottom, |
|
573 | - $x - $right, $y + $top); |
|
574 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
575 | - } else |
|
576 | - $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
577 | - |
|
578 | - break; |
|
579 | - |
|
580 | - default: |
|
581 | - return; |
|
568 | + case "right": |
|
569 | + if ( $corner_style === "bevel" ) { |
|
570 | + $points = array($x, $y, |
|
571 | + $x, $y + $length, |
|
572 | + $x - $right, $y + $length - $bottom, |
|
573 | + $x - $right, $y + $top); |
|
574 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
575 | + } else |
|
576 | + $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
577 | + |
|
578 | + break; |
|
579 | + |
|
580 | + default: |
|
581 | + return; |
|
582 | 582 | |
583 | 583 | } |
584 | 584 | |
@@ -595,105 +595,105 @@ discard block |
||
595 | 595 | // inner bottom, inner top. |
596 | 596 | switch ($side) { |
597 | 597 | |
598 | - case "top": |
|
599 | - if ( $corner_style === "bevel" ) { |
|
600 | - $left_line_width = $left / 4; |
|
601 | - $right_line_width = $right / 4; |
|
598 | + case "top": |
|
599 | + if ( $corner_style === "bevel" ) { |
|
600 | + $left_line_width = $left / 4; |
|
601 | + $right_line_width = $right / 4; |
|
602 | 602 | |
603 | - $points = array($x, $y, |
|
604 | - $x + $length, $y, |
|
605 | - $x + $length - $right_line_width, $y + $line_width, |
|
606 | - $x + $left_line_width, $y + $line_width,); |
|
607 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
603 | + $points = array($x, $y, |
|
604 | + $x + $length, $y, |
|
605 | + $x + $length - $right_line_width, $y + $line_width, |
|
606 | + $x + $left_line_width, $y + $line_width,); |
|
607 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
608 | 608 | |
609 | - $points = array($x + $left - $left_line_width, $y + $top - $line_width, |
|
610 | - $x + $length - $right + $right_line_width, $y + $top - $line_width, |
|
611 | - $x + $length - $right, $y + $top, |
|
612 | - $x + $left, $y + $top); |
|
613 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
609 | + $points = array($x + $left - $left_line_width, $y + $top - $line_width, |
|
610 | + $x + $length - $right + $right_line_width, $y + $top - $line_width, |
|
611 | + $x + $length - $right, $y + $top, |
|
612 | + $x + $left, $y + $top); |
|
613 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
614 | 614 | |
615 | - } else { |
|
616 | - $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color); |
|
617 | - $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color); |
|
615 | + } else { |
|
616 | + $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color); |
|
617 | + $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color); |
|
618 | 618 | |
619 | - } |
|
620 | - break; |
|
619 | + } |
|
620 | + break; |
|
621 | 621 | |
622 | - case "bottom": |
|
623 | - if ( $corner_style === "bevel" ) { |
|
624 | - $left_line_width = $left / 4; |
|
625 | - $right_line_width = $right / 4; |
|
622 | + case "bottom": |
|
623 | + if ( $corner_style === "bevel" ) { |
|
624 | + $left_line_width = $left / 4; |
|
625 | + $right_line_width = $right / 4; |
|
626 | 626 | |
627 | - $points = array($x, $y, |
|
628 | - $x + $length, $y, |
|
629 | - $x + $length - $right_line_width, $y - $line_width, |
|
630 | - $x + $left_line_width, $y - $line_width); |
|
631 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
627 | + $points = array($x, $y, |
|
628 | + $x + $length, $y, |
|
629 | + $x + $length - $right_line_width, $y - $line_width, |
|
630 | + $x + $left_line_width, $y - $line_width); |
|
631 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
632 | 632 | |
633 | - $points = array($x + $left - $left_line_width, $y - $bottom + $line_width, |
|
634 | - $x + $length - $right + $right_line_width, $y - $bottom + $line_width, |
|
635 | - $x + $length - $right, $y - $bottom, |
|
636 | - $x + $left, $y - $bottom); |
|
637 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
633 | + $points = array($x + $left - $left_line_width, $y - $bottom + $line_width, |
|
634 | + $x + $length - $right + $right_line_width, $y - $bottom + $line_width, |
|
635 | + $x + $length - $right, $y - $bottom, |
|
636 | + $x + $left, $y - $bottom); |
|
637 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
638 | 638 | |
639 | - } else { |
|
640 | - $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color); |
|
641 | - $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color); |
|
642 | - } |
|
639 | + } else { |
|
640 | + $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color); |
|
641 | + $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color); |
|
642 | + } |
|
643 | 643 | |
644 | - break; |
|
644 | + break; |
|
645 | 645 | |
646 | - case "left": |
|
647 | - if ( $corner_style === "bevel" ) { |
|
648 | - $top_line_width = $top / 4; |
|
649 | - $bottom_line_width = $bottom / 4; |
|
646 | + case "left": |
|
647 | + if ( $corner_style === "bevel" ) { |
|
648 | + $top_line_width = $top / 4; |
|
649 | + $bottom_line_width = $bottom / 4; |
|
650 | 650 | |
651 | - $points = array($x, $y, |
|
652 | - $x, $y + $length, |
|
653 | - $x + $line_width, $y + $length - $bottom_line_width, |
|
654 | - $x + $line_width, $y + $top_line_width); |
|
655 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
656 | - |
|
657 | - $points = array($x + $left - $line_width, $y + $top - $top_line_width, |
|
658 | - $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width, |
|
659 | - $x + $left, $y + $length - $bottom, |
|
660 | - $x + $left, $y + $top); |
|
661 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
651 | + $points = array($x, $y, |
|
652 | + $x, $y + $length, |
|
653 | + $x + $line_width, $y + $length - $bottom_line_width, |
|
654 | + $x + $line_width, $y + $top_line_width); |
|
655 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
656 | + |
|
657 | + $points = array($x + $left - $line_width, $y + $top - $top_line_width, |
|
658 | + $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width, |
|
659 | + $x + $left, $y + $length - $bottom, |
|
660 | + $x + $left, $y + $top); |
|
661 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
662 | 662 | |
663 | - } else { |
|
664 | - $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color); |
|
665 | - $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color); |
|
666 | - } |
|
663 | + } else { |
|
664 | + $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color); |
|
665 | + $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color); |
|
666 | + } |
|
667 | 667 | |
668 | - break; |
|
668 | + break; |
|
669 | 669 | |
670 | - case "right": |
|
671 | - if ( $corner_style === "bevel" ) { |
|
672 | - $top_line_width = $top / 4; |
|
673 | - $bottom_line_width = $bottom / 4; |
|
670 | + case "right": |
|
671 | + if ( $corner_style === "bevel" ) { |
|
672 | + $top_line_width = $top / 4; |
|
673 | + $bottom_line_width = $bottom / 4; |
|
674 | 674 | |
675 | 675 | |
676 | - $points = array($x, $y, |
|
677 | - $x, $y + $length, |
|
678 | - $x - $line_width, $y + $length - $bottom_line_width, |
|
679 | - $x - $line_width, $y + $top_line_width); |
|
680 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
676 | + $points = array($x, $y, |
|
677 | + $x, $y + $length, |
|
678 | + $x - $line_width, $y + $length - $bottom_line_width, |
|
679 | + $x - $line_width, $y + $top_line_width); |
|
680 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
681 | 681 | |
682 | - $points = array($x - $right + $line_width, $y + $top - $top_line_width, |
|
683 | - $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width, |
|
684 | - $x - $right, $y + $length - $bottom, |
|
685 | - $x - $right, $y + $top); |
|
686 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
682 | + $points = array($x - $right + $line_width, $y + $top - $top_line_width, |
|
683 | + $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width, |
|
684 | + $x - $right, $y + $length - $bottom, |
|
685 | + $x - $right, $y + $top); |
|
686 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
687 | 687 | |
688 | - } else { |
|
689 | - $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color); |
|
690 | - $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color); |
|
691 | - } |
|
688 | + } else { |
|
689 | + $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color); |
|
690 | + $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color); |
|
691 | + } |
|
692 | 692 | |
693 | - break; |
|
693 | + break; |
|
694 | 694 | |
695 | - default: |
|
696 | - return; |
|
695 | + default: |
|
696 | + return; |
|
697 | 697 | |
698 | 698 | } |
699 | 699 | |
@@ -708,32 +708,32 @@ discard block |
||
708 | 708 | |
709 | 709 | switch ($side) { |
710 | 710 | |
711 | - case "top": |
|
712 | - $x += $left / 2; |
|
713 | - $y += $top / 2; |
|
714 | - $length -= $left / 2 + $right / 2; |
|
715 | - break; |
|
716 | - |
|
717 | - case "bottom": |
|
718 | - $x += $left / 2; |
|
719 | - $y -= $bottom / 2; |
|
720 | - $length -= $left / 2 + $right / 2; |
|
721 | - break; |
|
722 | - |
|
723 | - case "left": |
|
724 | - $x += $left / 2; |
|
725 | - $y += $top / 2; |
|
726 | - $length -= $top / 2 + $bottom / 2; |
|
727 | - break; |
|
728 | - |
|
729 | - case "right": |
|
730 | - $x -= $right / 2; |
|
731 | - $y += $top / 2; |
|
732 | - $length -= $top / 2 + $bottom / 2; |
|
733 | - break; |
|
734 | - |
|
735 | - default: |
|
736 | - return; |
|
711 | + case "top": |
|
712 | + $x += $left / 2; |
|
713 | + $y += $top / 2; |
|
714 | + $length -= $left / 2 + $right / 2; |
|
715 | + break; |
|
716 | + |
|
717 | + case "bottom": |
|
718 | + $x += $left / 2; |
|
719 | + $y -= $bottom / 2; |
|
720 | + $length -= $left / 2 + $right / 2; |
|
721 | + break; |
|
722 | + |
|
723 | + case "left": |
|
724 | + $x += $left / 2; |
|
725 | + $y += $top / 2; |
|
726 | + $length -= $top / 2 + $bottom / 2; |
|
727 | + break; |
|
728 | + |
|
729 | + case "right": |
|
730 | + $x -= $right / 2; |
|
731 | + $y += $top / 2; |
|
732 | + $length -= $top / 2 + $bottom / 2; |
|
733 | + break; |
|
734 | + |
|
735 | + default: |
|
736 | + return; |
|
737 | 737 | |
738 | 738 | } |
739 | 739 | |
@@ -750,32 +750,32 @@ discard block |
||
750 | 750 | |
751 | 751 | switch ($side) { |
752 | 752 | |
753 | - case "top": |
|
754 | - $x += $left / 2; |
|
755 | - $y += $top / 2; |
|
756 | - $length -= $left / 2 + $right / 2; |
|
757 | - break; |
|
758 | - |
|
759 | - case "bottom": |
|
760 | - $x += $left / 2; |
|
761 | - $y -= $bottom / 2; |
|
762 | - $length -= $left / 2 + $right / 2; |
|
763 | - break; |
|
764 | - |
|
765 | - case "left": |
|
766 | - $x += $left / 2; |
|
767 | - $y += $top / 2; |
|
768 | - $length -= $top / 2 + $bottom / 2; |
|
769 | - break; |
|
770 | - |
|
771 | - case "right": |
|
772 | - $x -= $right / 2; |
|
773 | - $y += $top / 2; |
|
774 | - $length -= $top / 2 + $bottom / 2; |
|
775 | - break; |
|
776 | - |
|
777 | - default: |
|
778 | - return; |
|
753 | + case "top": |
|
754 | + $x += $left / 2; |
|
755 | + $y += $top / 2; |
|
756 | + $length -= $left / 2 + $right / 2; |
|
757 | + break; |
|
758 | + |
|
759 | + case "bottom": |
|
760 | + $x += $left / 2; |
|
761 | + $y -= $bottom / 2; |
|
762 | + $length -= $left / 2 + $right / 2; |
|
763 | + break; |
|
764 | + |
|
765 | + case "left": |
|
766 | + $x += $left / 2; |
|
767 | + $y += $top / 2; |
|
768 | + $length -= $top / 2 + $bottom / 2; |
|
769 | + break; |
|
770 | + |
|
771 | + case "right": |
|
772 | + $x -= $right / 2; |
|
773 | + $y += $top / 2; |
|
774 | + $length -= $top / 2 + $bottom / 2; |
|
775 | + break; |
|
776 | + |
|
777 | + default: |
|
778 | + return; |
|
779 | 779 | |
780 | 780 | } |
781 | 781 | |
@@ -802,20 +802,20 @@ discard block |
||
802 | 802 | |
803 | 803 | switch ($side) { |
804 | 804 | |
805 | - case "top": |
|
806 | - case "left": |
|
807 | - $shade = array_map(array($this, "_shade"), $color); |
|
808 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
809 | - break; |
|
805 | + case "top": |
|
806 | + case "left": |
|
807 | + $shade = array_map(array($this, "_shade"), $color); |
|
808 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
809 | + break; |
|
810 | 810 | |
811 | - case "bottom": |
|
812 | - case "right": |
|
813 | - $tint = array_map(array($this, "_tint"), $color); |
|
814 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
815 | - break; |
|
811 | + case "bottom": |
|
812 | + case "right": |
|
813 | + $tint = array_map(array($this, "_tint"), $color); |
|
814 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
815 | + break; |
|
816 | 816 | |
817 | - default: |
|
818 | - return; |
|
817 | + default: |
|
818 | + return; |
|
819 | 819 | } |
820 | 820 | } |
821 | 821 | |
@@ -823,20 +823,20 @@ discard block |
||
823 | 823 | list($top, $right, $bottom, $left) = $widths; |
824 | 824 | |
825 | 825 | switch ($side) { |
826 | - case "top": |
|
827 | - case "left": |
|
828 | - $tint = array_map(array($this, "_tint"), $color); |
|
829 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
830 | - break; |
|
831 | - |
|
832 | - case "bottom": |
|
833 | - case "right": |
|
834 | - $shade = array_map(array($this, "_shade"), $color); |
|
835 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
836 | - break; |
|
837 | - |
|
838 | - default: |
|
839 | - return; |
|
826 | + case "top": |
|
827 | + case "left": |
|
828 | + $tint = array_map(array($this, "_tint"), $color); |
|
829 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
830 | + break; |
|
831 | + |
|
832 | + case "bottom": |
|
833 | + case "right": |
|
834 | + $shade = array_map(array($this, "_shade"), $color); |
|
835 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
836 | + break; |
|
837 | + |
|
838 | + default: |
|
839 | + return; |
|
840 | 840 | |
841 | 841 | } |
842 | 842 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $sheet = $style->get_stylesheet(); |
110 | 110 | |
111 | 111 | // Skip degenerate cases |
112 | - if ( $width == 0 || $height == 0 ) |
|
112 | + if ($width == 0 || $height == 0) |
|
113 | 113 | return; |
114 | 114 | |
115 | 115 | //debugpng |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $sheet->get_base_path()); |
122 | 122 | |
123 | 123 | // Bail if the image is no good |
124 | - if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) |
|
124 | + if ($img === DOMPDF_LIB_DIR."/res/broken_image.png") |
|
125 | 125 | return; |
126 | 126 | |
127 | 127 | //Try to optimize away reading and composing of same background multiple times |
@@ -140,35 +140,35 @@ discard block |
||
140 | 140 | |
141 | 141 | //Increase background resolution and dependent box size according to image resolution to be placed in |
142 | 142 | //Then image can be copied in without resize |
143 | - $bg_width = round((float)($width * DOMPDF_DPI) / 72); |
|
144 | - $bg_height = round((float)($height * DOMPDF_DPI) / 72); |
|
143 | + $bg_width = round((float) ($width * DOMPDF_DPI) / 72); |
|
144 | + $bg_height = round((float) ($height * DOMPDF_DPI) / 72); |
|
145 | 145 | |
146 | 146 | //Need %bg_x, $bg_y as background pos, where img starts, converted to pixel |
147 | 147 | |
148 | 148 | list($bg_x, $bg_y) = $style->background_position; |
149 | 149 | |
150 | - if ( is_percent($bg_x) ) { |
|
150 | + if (is_percent($bg_x)) { |
|
151 | 151 | // The point $bg_x % from the left edge of the image is placed |
152 | 152 | // $bg_x % from the left edge of the background rectangle |
153 | - $p = ((float)$bg_x)/100.0; |
|
153 | + $p = ((float) $bg_x) / 100.0; |
|
154 | 154 | $x1 = $p * $img_w; |
155 | 155 | $x2 = $p * $bg_width; |
156 | 156 | |
157 | 157 | $bg_x = round($x2 - $x1); |
158 | 158 | } else { |
159 | - $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72); |
|
159 | + $bg_x = round((float) ($style->length_in_pt($bg_x) * DOMPDF_DPI) / 72); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( is_percent($bg_y) ) { |
|
162 | + if (is_percent($bg_y)) { |
|
163 | 163 | // The point $bg_y % from the left edge of the image is placed |
164 | 164 | // $bg_y % from the left edge of the background rectangle |
165 | - $p = ((float)$bg_y)/100.0; |
|
165 | + $p = ((float) $bg_y) / 100.0; |
|
166 | 166 | $y1 = $p * $img_h; |
167 | 167 | $y2 = $p * $bg_height; |
168 | 168 | |
169 | 169 | $bg_y = round($y2 - $y1); |
170 | 170 | } else { |
171 | - $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72); |
|
171 | + $bg_y = round((float) ($style->length_in_pt($bg_y) * DOMPDF_DPI) / 72); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | //clip background to the image area on partial repeat. Nothing to do if img off area |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | //On no repeat with positive offset: move size/start to have offset==0 |
177 | 177 | //Handle x/y Dimensions separately |
178 | 178 | |
179 | - if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) { |
|
179 | + if ($repeat !== "repeat" && $repeat !== "repeat-x") { |
|
180 | 180 | //No repeat x |
181 | 181 | if ($bg_x < 0) { |
182 | 182 | $bg_width = $img_w + $bg_x; |
183 | 183 | } else { |
184 | - $x += ($bg_x * 72)/DOMPDF_DPI; |
|
184 | + $x += ($bg_x * 72) / DOMPDF_DPI; |
|
185 | 185 | $bg_width = $bg_width - $bg_x; |
186 | 186 | if ($bg_width > $img_w) { |
187 | 187 | $bg_width = $img_w; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | if ($bg_width <= 0) { |
192 | 192 | return; |
193 | 193 | } |
194 | - $width = (float)($bg_width * 72)/DOMPDF_DPI; |
|
194 | + $width = (float) ($bg_width * 72) / DOMPDF_DPI; |
|
195 | 195 | } else { |
196 | 196 | //repeat x |
197 | 197 | if ($bg_x < 0) { |
@@ -204,12 +204,12 @@ discard block |
||
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
207 | - if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) { |
|
207 | + if ($repeat !== "repeat" && $repeat !== "repeat-y") { |
|
208 | 208 | //no repeat y |
209 | 209 | if ($bg_y < 0) { |
210 | 210 | $bg_height = $img_h + $bg_y; |
211 | 211 | } else { |
212 | - $y += ($bg_y * 72)/DOMPDF_DPI; |
|
212 | + $y += ($bg_y * 72) / DOMPDF_DPI; |
|
213 | 213 | $bg_height = $bg_height - $bg_y; |
214 | 214 | if ($bg_height > $img_h) { |
215 | 215 | $bg_height = $img_h; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | if ($bg_height <= 0) { |
220 | 220 | return; |
221 | 221 | } |
222 | - $height = (float)($bg_height * 72)/DOMPDF_DPI; |
|
222 | + $height = (float) ($bg_height * 72) / DOMPDF_DPI; |
|
223 | 223 | } else { |
224 | 224 | //repeat y |
225 | 225 | if ($bg_y < 0) { |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | //Optimization, if repeat has no effect |
236 | - if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) { |
|
236 | + if ($repeat === "repeat" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height) { |
|
237 | 237 | $repeat = "repeat-x"; |
238 | 238 | } |
239 | - if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) { |
|
239 | + if ($repeat === "repeat" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) { |
|
240 | 240 | $repeat = "repeat-y"; |
241 | 241 | } |
242 | - if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) || |
|
243 | - ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) { |
|
242 | + if (($repeat === "repeat-x" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) || |
|
243 | + ($repeat === "repeat-y" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height)) { |
|
244 | 244 | $repeat = "no-repeat"; |
245 | 245 | } |
246 | 246 | |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | //Optimization to avoid multiple times rendering the same image. |
282 | 282 | //If check functions are existing and identical image already cached, |
283 | 283 | //then skip creation of duplicate, because it is not needed by addImagePng |
284 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && |
|
285 | - method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) && |
|
286 | - method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) && |
|
287 | - $this->_canvas->get_cpdf()->image_iscached($filedummy) ) { |
|
284 | + if (method_exists($this->_canvas, "get_cpdf") && |
|
285 | + method_exists($this->_canvas->get_cpdf(), "addImagePng") && |
|
286 | + method_exists($this->_canvas->get_cpdf(), "image_iscached") && |
|
287 | + $this->_canvas->get_cpdf()->image_iscached($filedummy)) { |
|
288 | 288 | $bg = null; |
289 | 289 | |
290 | 290 | //debugpng |
@@ -327,15 +327,15 @@ discard block |
||
327 | 327 | //to keep the transparency when copying over the non transparent parts of the tiles. |
328 | 328 | $ti = imagecolortransparent($src); |
329 | 329 | if ($ti >= 0) { |
330 | - $tc = imagecolorsforindex($src,$ti); |
|
331 | - $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']); |
|
332 | - imagefill($bg,0,0,$ti); |
|
330 | + $tc = imagecolorsforindex($src, $ti); |
|
331 | + $ti = imagecolorallocate($bg, $tc['red'], $tc['green'], $tc['blue']); |
|
332 | + imagefill($bg, 0, 0, $ti); |
|
333 | 333 | imagecolortransparent($bg, $ti); |
334 | 334 | } |
335 | 335 | |
336 | 336 | //This has only an effect for the non repeatable dimension. |
337 | 337 | //compute start of src and dest coordinates of the single copy |
338 | - if ( $bg_x < 0 ) { |
|
338 | + if ($bg_x < 0) { |
|
339 | 339 | $dst_x = 0; |
340 | 340 | $src_x = -$bg_x; |
341 | 341 | } else { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $dst_x = $bg_x; |
344 | 344 | } |
345 | 345 | |
346 | - if ( $bg_y < 0 ) { |
|
346 | + if ($bg_y < 0) { |
|
347 | 347 | $dst_y = 0; |
348 | 348 | $src_y = -$bg_y; |
349 | 349 | } else { |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | |
359 | 359 | // Copy regions from the source image to the background |
360 | 360 | |
361 | - if ( $repeat === "no-repeat" ) { |
|
361 | + if ($repeat === "no-repeat") { |
|
362 | 362 | |
363 | 363 | // Simply place the image on the background |
364 | 364 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h); |
365 | 365 | |
366 | - } else if ( $repeat === "repeat-x" ) { |
|
366 | + } else if ($repeat === "repeat-x") { |
|
367 | 367 | |
368 | - for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
369 | - if ( $bg_x < 0 ) { |
|
368 | + for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) { |
|
369 | + if ($bg_x < 0) { |
|
370 | 370 | $dst_x = 0; |
371 | 371 | $src_x = -$bg_x; |
372 | 372 | $w = $img_w + $bg_x; |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h); |
379 | 379 | } |
380 | 380 | |
381 | - } else if ( $repeat === "repeat-y" ) { |
|
381 | + } else if ($repeat === "repeat-y") { |
|
382 | 382 | |
383 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
384 | - if ( $bg_y < 0 ) { |
|
383 | + for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) { |
|
384 | + if ($bg_y < 0) { |
|
385 | 385 | $dst_y = 0; |
386 | 386 | $src_y = -$bg_y; |
387 | 387 | $h = $img_h + $bg_y; |
@@ -394,12 +394,12 @@ discard block |
||
394 | 394 | |
395 | 395 | } |
396 | 396 | |
397 | - } else if ( $repeat === "repeat" ) { |
|
397 | + } else if ($repeat === "repeat") { |
|
398 | 398 | |
399 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
400 | - for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
399 | + for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) { |
|
400 | + for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) { |
|
401 | 401 | |
402 | - if ( $bg_x < 0 ) { |
|
402 | + if ($bg_x < 0) { |
|
403 | 403 | $dst_x = 0; |
404 | 404 | $src_x = -$bg_x; |
405 | 405 | $w = $img_w + $bg_x; |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | $w = $img_w; |
410 | 410 | } |
411 | 411 | |
412 | - if ( $bg_y < 0 ) { |
|
412 | + if ($bg_y < 0) { |
|
413 | 413 | $dst_y = 0; |
414 | 414 | $src_y = -$bg_y; |
415 | 415 | $h = $img_h + $bg_y; |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | //$src: GD object of original image |
439 | 439 | //When using cpdf and optimization to direct png creation from gd object is available, |
440 | 440 | //don't create temp file, but place gd object directly into the pdf |
441 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) { |
|
441 | + if (method_exists($this->_canvas, "get_cpdf") && method_exists($this->_canvas->get_cpdf(), "addImagePng")) { |
|
442 | 442 | //Note: CPDF_Adapter image converts y position |
443 | 443 | $this->_canvas->get_cpdf()->addImagePng( |
444 | 444 | $filedummy, |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
468 | 468 | list($top, $right, $bottom, $left) = $widths; |
469 | 469 | |
470 | - if ( $$side < 2 ) |
|
470 | + if ($$side < 2) |
|
471 | 471 | $dash = array($$side, 2); |
472 | 472 | else |
473 | 473 | $dash = array($$side); |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | switch ($side) { |
530 | 530 | |
531 | 531 | case "top": |
532 | - if ( $corner_style === "bevel" ) { |
|
532 | + if ($corner_style === "bevel") { |
|
533 | 533 | |
534 | 534 | $points = array($x, $y, |
535 | 535 | $x + $length, $y, |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | break; |
543 | 543 | |
544 | 544 | case "bottom": |
545 | - if ( $corner_style === "bevel" ) { |
|
545 | + if ($corner_style === "bevel") { |
|
546 | 546 | $points = array($x, $y, |
547 | 547 | $x + $length, $y, |
548 | 548 | $x + $length - $right, $y - $bottom, |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | break; |
555 | 555 | |
556 | 556 | case "left": |
557 | - if ( $corner_style === "bevel" ) { |
|
557 | + if ($corner_style === "bevel") { |
|
558 | 558 | $points = array($x, $y, |
559 | 559 | $x, $y + $length, |
560 | 560 | $x + $left, $y + $length - $bottom, |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | break; |
567 | 567 | |
568 | 568 | case "right": |
569 | - if ( $corner_style === "bevel" ) { |
|
569 | + if ($corner_style === "bevel") { |
|
570 | 570 | $points = array($x, $y, |
571 | 571 | $x, $y + $length, |
572 | 572 | $x - $right, $y + $length - $bottom, |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | switch ($side) { |
597 | 597 | |
598 | 598 | case "top": |
599 | - if ( $corner_style === "bevel" ) { |
|
599 | + if ($corner_style === "bevel") { |
|
600 | 600 | $left_line_width = $left / 4; |
601 | 601 | $right_line_width = $right / 4; |
602 | 602 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | break; |
621 | 621 | |
622 | 622 | case "bottom": |
623 | - if ( $corner_style === "bevel" ) { |
|
623 | + if ($corner_style === "bevel") { |
|
624 | 624 | $left_line_width = $left / 4; |
625 | 625 | $right_line_width = $right / 4; |
626 | 626 | |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | break; |
645 | 645 | |
646 | 646 | case "left": |
647 | - if ( $corner_style === "bevel" ) { |
|
647 | + if ($corner_style === "bevel") { |
|
648 | 648 | $top_line_width = $top / 4; |
649 | 649 | $bottom_line_width = $bottom / 4; |
650 | 650 | |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | break; |
669 | 669 | |
670 | 670 | case "right": |
671 | - if ( $corner_style === "bevel" ) { |
|
671 | + if ($corner_style === "bevel") { |
|
672 | 672 | $top_line_width = $top / 4; |
673 | 673 | $bottom_line_width = $bottom / 4; |
674 | 674 | |
@@ -784,14 +784,14 @@ discard block |
||
784 | 784 | } |
785 | 785 | |
786 | 786 | protected function _tint($c) { |
787 | - if ( !is_numeric($c) ) |
|
787 | + if (!is_numeric($c)) |
|
788 | 788 | return $c; |
789 | 789 | |
790 | 790 | return min(1, $c + 0.66); |
791 | 791 | } |
792 | 792 | |
793 | 793 | protected function _shade($c) { |
794 | - if ( !is_numeric($c) ) |
|
794 | + if (!is_numeric($c)) |
|
795 | 795 | return $c; |
796 | 796 | |
797 | 797 | return max(0, $c - 0.66); |
@@ -109,11 +109,14 @@ discard block |
||
109 | 109 | $sheet = $style->get_stylesheet(); |
110 | 110 | |
111 | 111 | // Skip degenerate cases |
112 | - if ( $width == 0 || $height == 0 ) |
|
113 | - return; |
|
112 | + if ( $width == 0 || $height == 0 ) { |
|
113 | + return; |
|
114 | + } |
|
114 | 115 | |
115 | 116 | //debugpng |
116 | - if (DEBUGPNG) print '[_background_image '.$url.']'; |
|
117 | + if (DEBUGPNG) { |
|
118 | + print '[_background_image '.$url.']'; |
|
119 | + } |
|
117 | 120 | |
118 | 121 | list($img, $ext) = Image_Cache::resolve_url($url, |
119 | 122 | $sheet->get_protocol(), |
@@ -121,8 +124,9 @@ discard block |
||
121 | 124 | $sheet->get_base_path()); |
122 | 125 | |
123 | 126 | // Bail if the image is no good |
124 | - if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) |
|
125 | - return; |
|
127 | + if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) { |
|
128 | + return; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | //Try to optimize away reading and composing of same background multiple times |
128 | 132 | //Postponing read with imagecreatefrom ...() |
@@ -446,16 +450,21 @@ discard block |
||
446 | 450 | } else { |
447 | 451 | $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
448 | 452 | //debugpng |
449 | - if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
453 | + if (DEBUGPNG) { |
|
454 | + print '[_background_image '.$tmp_file.']'; |
|
455 | + } |
|
450 | 456 | |
451 | 457 | imagepng($bg, $tmp_file); |
452 | 458 | $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
453 | 459 | |
454 | 460 | //debugpng |
455 | - if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
461 | + if (DEBUGPNG) { |
|
462 | + print '[_background_image unlink '.$tmp_file.']'; |
|
463 | + } |
|
456 | 464 | |
457 | - if (!DEBUGKEEPTEMP) |
|
458 | - unlink($tmp_file); |
|
465 | + if (!DEBUGKEEPTEMP) { |
|
466 | + unlink($tmp_file); |
|
467 | + } |
|
459 | 468 | } |
460 | 469 | } |
461 | 470 | |
@@ -467,10 +476,11 @@ discard block |
||
467 | 476 | protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
468 | 477 | list($top, $right, $bottom, $left) = $widths; |
469 | 478 | |
470 | - if ( $$side < 2 ) |
|
471 | - $dash = array($$side, 2); |
|
472 | - else |
|
473 | - $dash = array($$side); |
|
479 | + if ( $$side < 2 ) { |
|
480 | + $dash = array($$side, 2); |
|
481 | + } else { |
|
482 | + $dash = array($$side); |
|
483 | + } |
|
474 | 484 | |
475 | 485 | |
476 | 486 | switch ($side) { |
@@ -536,8 +546,9 @@ discard block |
||
536 | 546 | $x + $length - $right, $y + $top, |
537 | 547 | $x + $left, $y + $top); |
538 | 548 | $this->_canvas->polygon($points, $color, null, null, true); |
539 | - } else |
|
540 | - $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
549 | + } else { |
|
550 | + $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
551 | + } |
|
541 | 552 | |
542 | 553 | break; |
543 | 554 | |
@@ -548,8 +559,9 @@ discard block |
||
548 | 559 | $x + $length - $right, $y - $bottom, |
549 | 560 | $x + $left, $y - $bottom); |
550 | 561 | $this->_canvas->polygon($points, $color, null, null, true); |
551 | - } else |
|
552 | - $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
562 | + } else { |
|
563 | + $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
564 | + } |
|
553 | 565 | |
554 | 566 | break; |
555 | 567 | |
@@ -560,8 +572,9 @@ discard block |
||
560 | 572 | $x + $left, $y + $length - $bottom, |
561 | 573 | $x + $left, $y + $top); |
562 | 574 | $this->_canvas->polygon($points, $color, null, null, true); |
563 | - } else |
|
564 | - $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
575 | + } else { |
|
576 | + $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
577 | + } |
|
565 | 578 | |
566 | 579 | break; |
567 | 580 | |
@@ -572,8 +585,9 @@ discard block |
||
572 | 585 | $x - $right, $y + $length - $bottom, |
573 | 586 | $x - $right, $y + $top); |
574 | 587 | $this->_canvas->polygon($points, $color, null, null, true); |
575 | - } else |
|
576 | - $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
588 | + } else { |
|
589 | + $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
590 | + } |
|
577 | 591 | |
578 | 592 | break; |
579 | 593 | |
@@ -784,15 +798,17 @@ discard block |
||
784 | 798 | } |
785 | 799 | |
786 | 800 | protected function _tint($c) { |
787 | - if ( !is_numeric($c) ) |
|
788 | - return $c; |
|
801 | + if ( !is_numeric($c) ) { |
|
802 | + return $c; |
|
803 | + } |
|
789 | 804 | |
790 | 805 | return min(1, $c + 0.66); |
791 | 806 | } |
792 | 807 | |
793 | 808 | protected function _shade($c) { |
794 | - if ( !is_numeric($c) ) |
|
795 | - return $c; |
|
809 | + if ( !is_numeric($c) ) { |
|
810 | + return $c; |
|
811 | + } |
|
796 | 812 | |
797 | 813 | return max(0, $c - 0.66); |
798 | 814 | } |
@@ -1,54 +1,54 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: abstract_renderer.cls.php,v $ |
|
6 | - * Created on: 2004-06-01 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @contributor Helmut Tischer <[email protected]> |
|
37 | - * @package dompdf |
|
38 | - * |
|
39 | - * Changes |
|
40 | - * @contributor Helmut Tischer <[email protected]> |
|
41 | - * @version 0.5.1.htischer.20090507 |
|
42 | - * - On background image |
|
43 | - * - Clip invisible areas from background images, then merge identical |
|
44 | - * image/size/offset to a single image. |
|
45 | - * - Fix rounding of background image size. |
|
46 | - * - Fix background image position given as percent |
|
47 | - * - Check if identical image is already cached by cpdf. Then do not create |
|
48 | - * duplicates to save memory and CPU time |
|
49 | - * - Fix skipping of image repetition if area is too small |
|
50 | - * - Do not create temporary files, but pass gd object directly |
|
51 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: abstract_renderer.cls.php,v $ |
|
6 | + * Created on: 2004-06-01 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @contributor Helmut Tischer <[email protected]> |
|
37 | + * @package dompdf |
|
38 | + * |
|
39 | + * Changes |
|
40 | + * @contributor Helmut Tischer <[email protected]> |
|
41 | + * @version 0.5.1.htischer.20090507 |
|
42 | + * - On background image |
|
43 | + * - Clip invisible areas from background images, then merge identical |
|
44 | + * image/size/offset to a single image. |
|
45 | + * - Fix rounding of background image size. |
|
46 | + * - Fix background image position given as percent |
|
47 | + * - Check if identical image is already cached by cpdf. Then do not create |
|
48 | + * duplicates to save memory and CPU time |
|
49 | + * - Fix skipping of image repetition if area is too small |
|
50 | + * - Do not create temporary files, but pass gd object directly |
|
51 | + */ |
|
52 | 52 | |
53 | 53 | /* $Id: abstract_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
54 | 54 | |
@@ -60,57 +60,57 @@ discard block |
||
60 | 60 | */ |
61 | 61 | abstract class Abstract_Renderer { |
62 | 62 | |
63 | - /** |
|
64 | - * Rendering backend |
|
65 | - * |
|
66 | - * @var Canvas |
|
67 | - */ |
|
68 | - protected $_canvas; |
|
69 | - |
|
70 | - /** |
|
71 | - * Current dompdf instance |
|
72 | - * |
|
73 | - * @var DOMPDF |
|
74 | - */ |
|
75 | - protected $_dompdf; |
|
63 | + /** |
|
64 | + * Rendering backend |
|
65 | + * |
|
66 | + * @var Canvas |
|
67 | + */ |
|
68 | + protected $_canvas; |
|
69 | + |
|
70 | + /** |
|
71 | + * Current dompdf instance |
|
72 | + * |
|
73 | + * @var DOMPDF |
|
74 | + */ |
|
75 | + protected $_dompdf; |
|
76 | 76 | |
77 | - /** |
|
78 | - * Class constructor |
|
79 | - * |
|
80 | - * @param DOMPDF $dompdf The current dompdf instance |
|
81 | - */ |
|
82 | - function __construct(DOMPDF $dompdf) { |
|
77 | + /** |
|
78 | + * Class constructor |
|
79 | + * |
|
80 | + * @param DOMPDF $dompdf The current dompdf instance |
|
81 | + */ |
|
82 | + function __construct(DOMPDF $dompdf) { |
|
83 | 83 | $this->_dompdf = $dompdf; |
84 | 84 | $this->_canvas = $dompdf->get_canvas(); |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Render a frame. |
|
89 | - * |
|
90 | - * Specialized in child classes |
|
91 | - * |
|
92 | - * @param Frame $frame The frame to render |
|
93 | - */ |
|
94 | - abstract function render(Frame $frame); |
|
95 | - |
|
96 | - //........................................................................ |
|
97 | - |
|
98 | - /** |
|
99 | - * Render a background image over a rectangular area |
|
100 | - * |
|
101 | - * @param string $img The background image to load |
|
102 | - * @param float $x The left edge of the rectangular area |
|
103 | - * @param float $y The top edge of the rectangular area |
|
104 | - * @param float $width The width of the rectangular area |
|
105 | - * @param float $height The height of the rectangular area |
|
106 | - * @param Style $style The associated Style object |
|
107 | - */ |
|
108 | - protected function _background_image($url, $x, $y, $width, $height, $style) { |
|
87 | + /** |
|
88 | + * Render a frame. |
|
89 | + * |
|
90 | + * Specialized in child classes |
|
91 | + * |
|
92 | + * @param Frame $frame The frame to render |
|
93 | + */ |
|
94 | + abstract function render(Frame $frame); |
|
95 | + |
|
96 | + //........................................................................ |
|
97 | + |
|
98 | + /** |
|
99 | + * Render a background image over a rectangular area |
|
100 | + * |
|
101 | + * @param string $img The background image to load |
|
102 | + * @param float $x The left edge of the rectangular area |
|
103 | + * @param float $y The top edge of the rectangular area |
|
104 | + * @param float $width The width of the rectangular area |
|
105 | + * @param float $height The height of the rectangular area |
|
106 | + * @param Style $style The associated Style object |
|
107 | + */ |
|
108 | + protected function _background_image($url, $x, $y, $width, $height, $style) { |
|
109 | 109 | $sheet = $style->get_stylesheet(); |
110 | 110 | |
111 | 111 | // Skip degenerate cases |
112 | 112 | if ( $width == 0 || $height == 0 ) |
113 | - return; |
|
113 | + return; |
|
114 | 114 | |
115 | 115 | //debugpng |
116 | 116 | if (DEBUGPNG) print '[_background_image '.$url.']'; |
@@ -122,24 +122,24 @@ discard block |
||
122 | 122 | |
123 | 123 | // Bail if the image is no good |
124 | 124 | if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) |
125 | - return; |
|
125 | + return; |
|
126 | 126 | |
127 | - //Try to optimize away reading and composing of same background multiple times |
|
128 | - //Postponing read with imagecreatefrom ...() |
|
129 | - //final composition paramters and name not known yet |
|
130 | - //Therefore read dimension directly from file, instead of creating gd object first. |
|
127 | + //Try to optimize away reading and composing of same background multiple times |
|
128 | + //Postponing read with imagecreatefrom ...() |
|
129 | + //final composition paramters and name not known yet |
|
130 | + //Therefore read dimension directly from file, instead of creating gd object first. |
|
131 | 131 | //$img_w = imagesx($src); $img_h = imagesy($src); |
132 | 132 | |
133 | 133 | list($img_w, $img_h) = getimagesize($img); |
134 | 134 | if (!isset($img_w) || $img_w == 0 || !isset($img_h) || $img_h == 0) { |
135 | - return; |
|
135 | + return; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | $repeat = $style->background_repeat; |
139 | 139 | $bg_color = $style->background_color; |
140 | 140 | |
141 | - //Increase background resolution and dependent box size according to image resolution to be placed in |
|
142 | - //Then image can be copied in without resize |
|
141 | + //Increase background resolution and dependent box size according to image resolution to be placed in |
|
142 | + //Then image can be copied in without resize |
|
143 | 143 | $bg_width = round((float)($width * DOMPDF_DPI) / 72); |
144 | 144 | $bg_height = round((float)($height * DOMPDF_DPI) / 72); |
145 | 145 | |
@@ -148,27 +148,27 @@ discard block |
||
148 | 148 | list($bg_x, $bg_y) = $style->background_position; |
149 | 149 | |
150 | 150 | if ( is_percent($bg_x) ) { |
151 | - // The point $bg_x % from the left edge of the image is placed |
|
152 | - // $bg_x % from the left edge of the background rectangle |
|
153 | - $p = ((float)$bg_x)/100.0; |
|
154 | - $x1 = $p * $img_w; |
|
155 | - $x2 = $p * $bg_width; |
|
151 | + // The point $bg_x % from the left edge of the image is placed |
|
152 | + // $bg_x % from the left edge of the background rectangle |
|
153 | + $p = ((float)$bg_x)/100.0; |
|
154 | + $x1 = $p * $img_w; |
|
155 | + $x2 = $p * $bg_width; |
|
156 | 156 | |
157 | - $bg_x = round($x2 - $x1); |
|
157 | + $bg_x = round($x2 - $x1); |
|
158 | 158 | } else { |
159 | - $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72); |
|
159 | + $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | if ( is_percent($bg_y) ) { |
163 | - // The point $bg_y % from the left edge of the image is placed |
|
164 | - // $bg_y % from the left edge of the background rectangle |
|
165 | - $p = ((float)$bg_y)/100.0; |
|
166 | - $y1 = $p * $img_h; |
|
167 | - $y2 = $p * $bg_height; |
|
163 | + // The point $bg_y % from the left edge of the image is placed |
|
164 | + // $bg_y % from the left edge of the background rectangle |
|
165 | + $p = ((float)$bg_y)/100.0; |
|
166 | + $y1 = $p * $img_h; |
|
167 | + $y2 = $p * $bg_height; |
|
168 | 168 | |
169 | - $bg_y = round($y2 - $y1); |
|
169 | + $bg_y = round($y2 - $y1); |
|
170 | 170 | } else { |
171 | - $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72); |
|
171 | + $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | //clip background to the image area on partial repeat. Nothing to do if img off area |
@@ -177,79 +177,79 @@ discard block |
||
177 | 177 | //Handle x/y Dimensions separately |
178 | 178 | |
179 | 179 | if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) { |
180 | - //No repeat x |
|
181 | - if ($bg_x < 0) { |
|
180 | + //No repeat x |
|
181 | + if ($bg_x < 0) { |
|
182 | 182 | $bg_width = $img_w + $bg_x; |
183 | - } else { |
|
183 | + } else { |
|
184 | 184 | $x += ($bg_x * 72)/DOMPDF_DPI; |
185 | 185 | $bg_width = $bg_width - $bg_x; |
186 | 186 | if ($bg_width > $img_w) { |
187 | - $bg_width = $img_w; |
|
187 | + $bg_width = $img_w; |
|
188 | 188 | } |
189 | 189 | $bg_x = 0; |
190 | - } |
|
191 | - if ($bg_width <= 0) { |
|
192 | - return; |
|
193 | - } |
|
194 | - $width = (float)($bg_width * 72)/DOMPDF_DPI; |
|
190 | + } |
|
191 | + if ($bg_width <= 0) { |
|
192 | + return; |
|
193 | + } |
|
194 | + $width = (float)($bg_width * 72)/DOMPDF_DPI; |
|
195 | 195 | } else { |
196 | - //repeat x |
|
197 | - if ($bg_x < 0) { |
|
196 | + //repeat x |
|
197 | + if ($bg_x < 0) { |
|
198 | 198 | $bg_x = - ((-$bg_x) % $img_w); |
199 | - } else { |
|
199 | + } else { |
|
200 | 200 | $bg_x = $bg_x % $img_w; |
201 | 201 | if ($bg_x > 0) { |
202 | - $bg_x -= $img_w; |
|
202 | + $bg_x -= $img_w; |
|
203 | + } |
|
203 | 204 | } |
204 | - } |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) { |
208 | - //no repeat y |
|
209 | - if ($bg_y < 0) { |
|
208 | + //no repeat y |
|
209 | + if ($bg_y < 0) { |
|
210 | 210 | $bg_height = $img_h + $bg_y; |
211 | - } else { |
|
211 | + } else { |
|
212 | 212 | $y += ($bg_y * 72)/DOMPDF_DPI; |
213 | 213 | $bg_height = $bg_height - $bg_y; |
214 | 214 | if ($bg_height > $img_h) { |
215 | - $bg_height = $img_h; |
|
215 | + $bg_height = $img_h; |
|
216 | 216 | } |
217 | 217 | $bg_y = 0; |
218 | - } |
|
219 | - if ($bg_height <= 0) { |
|
220 | - return; |
|
221 | - } |
|
222 | - $height = (float)($bg_height * 72)/DOMPDF_DPI; |
|
218 | + } |
|
219 | + if ($bg_height <= 0) { |
|
220 | + return; |
|
221 | + } |
|
222 | + $height = (float)($bg_height * 72)/DOMPDF_DPI; |
|
223 | 223 | } else { |
224 | - //repeat y |
|
225 | - if ($bg_y < 0) { |
|
224 | + //repeat y |
|
225 | + if ($bg_y < 0) { |
|
226 | 226 | $bg_y = - ((-$bg_y) % $img_h); |
227 | - } else { |
|
227 | + } else { |
|
228 | 228 | $bg_y = $bg_y % $img_h; |
229 | 229 | if ($bg_y > 0) { |
230 | - $bg_y -= $img_h; |
|
230 | + $bg_y -= $img_h; |
|
231 | + } |
|
231 | 232 | } |
232 | - } |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | //Optimization, if repeat has no effect |
236 | 236 | if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) { |
237 | - $repeat = "repeat-x"; |
|
237 | + $repeat = "repeat-x"; |
|
238 | 238 | } |
239 | 239 | if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) { |
240 | - $repeat = "repeat-y"; |
|
240 | + $repeat = "repeat-y"; |
|
241 | 241 | } |
242 | 242 | if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) || |
243 | 243 | ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) { |
244 | - $repeat = "no-repeat"; |
|
244 | + $repeat = "no-repeat"; |
|
245 | 245 | } |
246 | 246 | |
247 | - //Use filename as indicator only |
|
248 | - //different names for different variants to have different copies in the pdf |
|
249 | - //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color) |
|
250 | - //Note: Here, bg_* are the start values, not end values after going through the tile loops! |
|
247 | + //Use filename as indicator only |
|
248 | + //different names for different variants to have different copies in the pdf |
|
249 | + //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color) |
|
250 | + //Note: Here, bg_* are the start values, not end values after going through the tile loops! |
|
251 | 251 | |
252 | - $filedummy = $img; |
|
252 | + $filedummy = $img; |
|
253 | 253 | |
254 | 254 | /* |
255 | 255 | //Make shorter strings with limited characters for cache associative array index - needed? |
@@ -274,50 +274,50 @@ discard block |
||
274 | 274 | } |
275 | 275 | */ |
276 | 276 | |
277 | - $filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat; |
|
277 | + $filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat; |
|
278 | 278 | //debugpng |
279 | 279 | //if (DEBUGPNG) print '<pre>[_background_image name '.$filedummy.']</pre>'; |
280 | 280 | |
281 | 281 | //Optimization to avoid multiple times rendering the same image. |
282 | 282 | //If check functions are existing and identical image already cached, |
283 | 283 | //then skip creation of duplicate, because it is not needed by addImagePng |
284 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && |
|
285 | - method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) && |
|
286 | - method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) && |
|
287 | - $this->_canvas->get_cpdf()->image_iscached($filedummy) ) { |
|
288 | - $bg = null; |
|
284 | + if ( method_exists( $this->_canvas, "get_cpdf" ) && |
|
285 | + method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) && |
|
286 | + method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) && |
|
287 | + $this->_canvas->get_cpdf()->image_iscached($filedummy) ) { |
|
288 | + $bg = null; |
|
289 | 289 | |
290 | - //debugpng |
|
291 | - //if (DEBUGPNG) print '[_background_image skip]'; |
|
290 | + //debugpng |
|
291 | + //if (DEBUGPNG) print '[_background_image skip]'; |
|
292 | 292 | |
293 | - } else { |
|
293 | + } else { |
|
294 | 294 | |
295 | 295 | // Create a new image to fit over the background rectangle |
296 | 296 | $bg = imagecreatetruecolor($bg_width, $bg_height); |
297 | 297 | //anyway default |
298 | - //imagealphablending($img, true); |
|
298 | + //imagealphablending($img, true); |
|
299 | 299 | |
300 | 300 | switch (strtolower($ext)) { |
301 | 301 | |
302 | 302 | case "png": |
303 | 303 | $src = imagecreatefrompng($img); |
304 | - break; |
|
304 | + break; |
|
305 | 305 | |
306 | 306 | case "jpg": |
307 | 307 | case "jpeg": |
308 | 308 | $src = imagecreatefromjpeg($img); |
309 | - break; |
|
309 | + break; |
|
310 | 310 | |
311 | 311 | case "gif": |
312 | 312 | $src = imagecreatefromgif($img); |
313 | - break; |
|
313 | + break; |
|
314 | 314 | |
315 | 315 | default: |
316 | 316 | return; // Unsupported image type |
317 | 317 | } |
318 | 318 | |
319 | 319 | if ($src == null) { |
320 | - return; |
|
320 | + return; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | //Background color if box is not relevant here |
@@ -325,34 +325,34 @@ discard block |
||
325 | 325 | //Transparent image: The image controls the transparency and lets shine through whatever background. |
326 | 326 | //However on transparent imaage preset the composed image with the transparency color, |
327 | 327 | //to keep the transparency when copying over the non transparent parts of the tiles. |
328 | - $ti = imagecolortransparent($src); |
|
329 | - if ($ti >= 0) { |
|
330 | - $tc = imagecolorsforindex($src,$ti); |
|
331 | - $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']); |
|
332 | - imagefill($bg,0,0,$ti); |
|
333 | - imagecolortransparent($bg, $ti); |
|
328 | + $ti = imagecolortransparent($src); |
|
329 | + if ($ti >= 0) { |
|
330 | + $tc = imagecolorsforindex($src,$ti); |
|
331 | + $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']); |
|
332 | + imagefill($bg,0,0,$ti); |
|
333 | + imagecolortransparent($bg, $ti); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | //This has only an effect for the non repeatable dimension. |
337 | 337 | //compute start of src and dest coordinates of the single copy |
338 | 338 | if ( $bg_x < 0 ) { |
339 | - $dst_x = 0; |
|
340 | - $src_x = -$bg_x; |
|
339 | + $dst_x = 0; |
|
340 | + $src_x = -$bg_x; |
|
341 | 341 | } else { |
342 | - $src_x = 0; |
|
343 | - $dst_x = $bg_x; |
|
342 | + $src_x = 0; |
|
343 | + $dst_x = $bg_x; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | if ( $bg_y < 0 ) { |
347 | - $dst_y = 0; |
|
348 | - $src_y = -$bg_y; |
|
347 | + $dst_y = 0; |
|
348 | + $src_y = -$bg_y; |
|
349 | 349 | } else { |
350 | - $src_y = 0; |
|
351 | - $dst_y = $bg_y; |
|
350 | + $src_y = 0; |
|
351 | + $dst_y = $bg_y; |
|
352 | 352 | } |
353 | 353 | |
354 | - //For historical reasons exchange meanings of variables: |
|
355 | - //start_* will be the start values, while bg_* will be the temporary start values in the loops |
|
354 | + //For historical reasons exchange meanings of variables: |
|
355 | + //start_* will be the start values, while bg_* will be the temporary start values in the loops |
|
356 | 356 | $start_x = $bg_x; |
357 | 357 | $start_y = $bg_y; |
358 | 358 | |
@@ -360,117 +360,117 @@ discard block |
||
360 | 360 | |
361 | 361 | if ( $repeat === "no-repeat" ) { |
362 | 362 | |
363 | - // Simply place the image on the background |
|
364 | - imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h); |
|
363 | + // Simply place the image on the background |
|
364 | + imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h); |
|
365 | 365 | |
366 | 366 | } else if ( $repeat === "repeat-x" ) { |
367 | 367 | |
368 | - for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
368 | + for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
369 | 369 | if ( $bg_x < 0 ) { |
370 | - $dst_x = 0; |
|
371 | - $src_x = -$bg_x; |
|
372 | - $w = $img_w + $bg_x; |
|
370 | + $dst_x = 0; |
|
371 | + $src_x = -$bg_x; |
|
372 | + $w = $img_w + $bg_x; |
|
373 | 373 | } else { |
374 | - $dst_x = $bg_x; |
|
375 | - $src_x = 0; |
|
376 | - $w = $img_w; |
|
374 | + $dst_x = $bg_x; |
|
375 | + $src_x = 0; |
|
376 | + $w = $img_w; |
|
377 | 377 | } |
378 | 378 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h); |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | 381 | } else if ( $repeat === "repeat-y" ) { |
382 | 382 | |
383 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
383 | + for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
384 | 384 | if ( $bg_y < 0 ) { |
385 | - $dst_y = 0; |
|
386 | - $src_y = -$bg_y; |
|
387 | - $h = $img_h + $bg_y; |
|
385 | + $dst_y = 0; |
|
386 | + $src_y = -$bg_y; |
|
387 | + $h = $img_h + $bg_y; |
|
388 | 388 | } else { |
389 | - $dst_y = $bg_y; |
|
390 | - $src_y = 0; |
|
391 | - $h = $img_h; |
|
389 | + $dst_y = $bg_y; |
|
390 | + $src_y = 0; |
|
391 | + $h = $img_h; |
|
392 | 392 | } |
393 | 393 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $h); |
394 | 394 | |
395 | - } |
|
395 | + } |
|
396 | 396 | |
397 | 397 | } else if ( $repeat === "repeat" ) { |
398 | 398 | |
399 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
399 | + for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
400 | 400 | for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
401 | 401 | |
402 | - if ( $bg_x < 0 ) { |
|
402 | + if ( $bg_x < 0 ) { |
|
403 | 403 | $dst_x = 0; |
404 | 404 | $src_x = -$bg_x; |
405 | 405 | $w = $img_w + $bg_x; |
406 | - } else { |
|
406 | + } else { |
|
407 | 407 | $dst_x = $bg_x; |
408 | 408 | $src_x = 0; |
409 | 409 | $w = $img_w; |
410 | - } |
|
410 | + } |
|
411 | 411 | |
412 | - if ( $bg_y < 0 ) { |
|
412 | + if ( $bg_y < 0 ) { |
|
413 | 413 | $dst_y = 0; |
414 | 414 | $src_y = -$bg_y; |
415 | 415 | $h = $img_h + $bg_y; |
416 | - } else { |
|
416 | + } else { |
|
417 | 417 | $dst_y = $bg_y; |
418 | 418 | $src_y = 0; |
419 | 419 | $h = $img_h; |
420 | - } |
|
421 | - imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h); |
|
420 | + } |
|
421 | + imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h); |
|
422 | + } |
|
422 | 423 | } |
423 | - } |
|
424 | 424 | } else { |
425 | - print 'Unknown repeat!'; |
|
425 | + print 'Unknown repeat!'; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | } /* End optimize away creation of duplicates */ |
429 | 429 | |
430 | 430 | //img: image url string |
431 | - //img_w, img_h: original image size in px |
|
432 | - //width, height: box size in pt |
|
433 | - //bg_width, bg_height: box size in px |
|
434 | - //x, y: left/top edge of box on page in pt |
|
435 | - //start_x, start_y: placement of image relativ to pattern |
|
436 | - //$repeat: repeat mode |
|
437 | - //$bg: GD object of result image |
|
438 | - //$src: GD object of original image |
|
431 | + //img_w, img_h: original image size in px |
|
432 | + //width, height: box size in pt |
|
433 | + //bg_width, bg_height: box size in px |
|
434 | + //x, y: left/top edge of box on page in pt |
|
435 | + //start_x, start_y: placement of image relativ to pattern |
|
436 | + //$repeat: repeat mode |
|
437 | + //$bg: GD object of result image |
|
438 | + //$src: GD object of original image |
|
439 | 439 | //When using cpdf and optimization to direct png creation from gd object is available, |
440 | 440 | //don't create temp file, but place gd object directly into the pdf |
441 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) { |
|
442 | - //Note: CPDF_Adapter image converts y position |
|
443 | - $this->_canvas->get_cpdf()->addImagePng( |
|
444 | - $filedummy, |
|
445 | - $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg); |
|
446 | - } else { |
|
447 | - $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
|
448 | - //debugpng |
|
449 | - if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
441 | + if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) { |
|
442 | + //Note: CPDF_Adapter image converts y position |
|
443 | + $this->_canvas->get_cpdf()->addImagePng( |
|
444 | + $filedummy, |
|
445 | + $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg); |
|
446 | + } else { |
|
447 | + $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
|
448 | + //debugpng |
|
449 | + if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
450 | 450 | |
451 | - imagepng($bg, $tmp_file); |
|
452 | - $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
|
451 | + imagepng($bg, $tmp_file); |
|
452 | + $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
|
453 | 453 | |
454 | - //debugpng |
|
455 | - if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
454 | + //debugpng |
|
455 | + if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
456 | 456 | |
457 | - if (!DEBUGKEEPTEMP) |
|
457 | + if (!DEBUGKEEPTEMP) |
|
458 | 458 | unlink($tmp_file); |
459 | 459 | } |
460 | - } |
|
460 | + } |
|
461 | 461 | |
462 | - protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
462 | + protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
463 | 463 | return; |
464 | - } |
|
464 | + } |
|
465 | 465 | |
466 | - // Border rendering functions |
|
467 | - protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
466 | + // Border rendering functions |
|
467 | + protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
468 | 468 | list($top, $right, $bottom, $left) = $widths; |
469 | 469 | |
470 | 470 | if ( $$side < 2 ) |
471 | - $dash = array($$side, 2); |
|
471 | + $dash = array($$side, 2); |
|
472 | 472 | else |
473 | - $dash = array($$side); |
|
473 | + $dash = array($$side); |
|
474 | 474 | |
475 | 475 | |
476 | 476 | switch ($side) { |
@@ -479,24 +479,24 @@ discard block |
||
479 | 479 | $delta = $top / 2; |
480 | 480 | case "bottom": |
481 | 481 | $delta = isset($delta) ? $delta : -$bottom / 2; |
482 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
483 | - break; |
|
482 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
483 | + break; |
|
484 | 484 | |
485 | 485 | case "left": |
486 | 486 | $delta = $left / 2; |
487 | 487 | case "right": |
488 | 488 | $delta = isset($delta) ? $delta : - $right / 2; |
489 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
490 | - break; |
|
489 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
490 | + break; |
|
491 | 491 | |
492 | 492 | default: |
493 | 493 | return; |
494 | 494 | |
495 | 495 | } |
496 | - } |
|
496 | + } |
|
497 | 497 | |
498 | 498 | |
499 | - protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
499 | + protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
500 | 500 | list($top, $right, $bottom, $left) = $widths; |
501 | 501 | |
502 | 502 | switch ($side) { |
@@ -505,24 +505,24 @@ discard block |
||
505 | 505 | $delta = $top / 2; |
506 | 506 | case "bottom": |
507 | 507 | $delta = isset($delta) ? $delta : -$bottom / 2; |
508 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
509 | - break; |
|
508 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
509 | + break; |
|
510 | 510 | |
511 | 511 | case "left": |
512 | 512 | $delta = $left / 2; |
513 | 513 | case "right": |
514 | 514 | $delta = isset($delta) ? $delta : - $right / 2; |
515 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
516 | - break; |
|
515 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
516 | + break; |
|
517 | 517 | |
518 | 518 | default: |
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | 524 | |
525 | - protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
525 | + protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
526 | 526 | list($top, $right, $bottom, $left) = $widths; |
527 | 527 | |
528 | 528 | // All this polygon business is for beveled corners... |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | $x + $length - $right, $y + $top, |
537 | 537 | $x + $left, $y + $top); |
538 | 538 | $this->_canvas->polygon($points, $color, null, null, true); |
539 | - } else |
|
539 | + } else |
|
540 | 540 | $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
541 | 541 | |
542 | - break; |
|
542 | + break; |
|
543 | 543 | |
544 | 544 | case "bottom": |
545 | 545 | if ( $corner_style === "bevel" ) { |
@@ -548,10 +548,10 @@ discard block |
||
548 | 548 | $x + $length - $right, $y - $bottom, |
549 | 549 | $x + $left, $y - $bottom); |
550 | 550 | $this->_canvas->polygon($points, $color, null, null, true); |
551 | - } else |
|
551 | + } else |
|
552 | 552 | $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
553 | 553 | |
554 | - break; |
|
554 | + break; |
|
555 | 555 | |
556 | 556 | case "left": |
557 | 557 | if ( $corner_style === "bevel" ) { |
@@ -560,10 +560,10 @@ discard block |
||
560 | 560 | $x + $left, $y + $length - $bottom, |
561 | 561 | $x + $left, $y + $top); |
562 | 562 | $this->_canvas->polygon($points, $color, null, null, true); |
563 | - } else |
|
563 | + } else |
|
564 | 564 | $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
565 | 565 | |
566 | - break; |
|
566 | + break; |
|
567 | 567 | |
568 | 568 | case "right": |
569 | 569 | if ( $corner_style === "bevel" ) { |
@@ -572,20 +572,20 @@ discard block |
||
572 | 572 | $x - $right, $y + $length - $bottom, |
573 | 573 | $x - $right, $y + $top); |
574 | 574 | $this->_canvas->polygon($points, $color, null, null, true); |
575 | - } else |
|
575 | + } else |
|
576 | 576 | $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
577 | 577 | |
578 | - break; |
|
578 | + break; |
|
579 | 579 | |
580 | 580 | default: |
581 | 581 | return; |
582 | 582 | |
583 | 583 | } |
584 | 584 | |
585 | - } |
|
585 | + } |
|
586 | 586 | |
587 | 587 | |
588 | - protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
588 | + protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
589 | 589 | list($top, $right, $bottom, $left) = $widths; |
590 | 590 | |
591 | 591 | $line_width = $$side / 4; |
@@ -612,12 +612,12 @@ discard block |
||
612 | 612 | $x + $left, $y + $top); |
613 | 613 | $this->_canvas->polygon($points, $color, null, null, true); |
614 | 614 | |
615 | - } else { |
|
615 | + } else { |
|
616 | 616 | $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color); |
617 | 617 | $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color); |
618 | 618 | |
619 | - } |
|
620 | - break; |
|
619 | + } |
|
620 | + break; |
|
621 | 621 | |
622 | 622 | case "bottom": |
623 | 623 | if ( $corner_style === "bevel" ) { |
@@ -636,12 +636,12 @@ discard block |
||
636 | 636 | $x + $left, $y - $bottom); |
637 | 637 | $this->_canvas->polygon($points, $color, null, null, true); |
638 | 638 | |
639 | - } else { |
|
639 | + } else { |
|
640 | 640 | $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color); |
641 | 641 | $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color); |
642 | - } |
|
642 | + } |
|
643 | 643 | |
644 | - break; |
|
644 | + break; |
|
645 | 645 | |
646 | 646 | case "left": |
647 | 647 | if ( $corner_style === "bevel" ) { |
@@ -660,12 +660,12 @@ discard block |
||
660 | 660 | $x + $left, $y + $top); |
661 | 661 | $this->_canvas->polygon($points, $color, null, null, true); |
662 | 662 | |
663 | - } else { |
|
663 | + } else { |
|
664 | 664 | $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color); |
665 | 665 | $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color); |
666 | - } |
|
666 | + } |
|
667 | 667 | |
668 | - break; |
|
668 | + break; |
|
669 | 669 | |
670 | 670 | case "right": |
671 | 671 | if ( $corner_style === "bevel" ) { |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | |
675 | 675 | |
676 | 676 | $points = array($x, $y, |
677 | - $x, $y + $length, |
|
677 | + $x, $y + $length, |
|
678 | 678 | $x - $line_width, $y + $length - $bottom_line_width, |
679 | 679 | $x - $line_width, $y + $top_line_width); |
680 | 680 | $this->_canvas->polygon($points, $color, null, null, true); |
@@ -685,21 +685,21 @@ discard block |
||
685 | 685 | $x - $right, $y + $top); |
686 | 686 | $this->_canvas->polygon($points, $color, null, null, true); |
687 | 687 | |
688 | - } else { |
|
688 | + } else { |
|
689 | 689 | $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color); |
690 | 690 | $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color); |
691 | - } |
|
691 | + } |
|
692 | 692 | |
693 | - break; |
|
693 | + break; |
|
694 | 694 | |
695 | 695 | default: |
696 | 696 | return; |
697 | 697 | |
698 | 698 | } |
699 | 699 | |
700 | - } |
|
700 | + } |
|
701 | 701 | |
702 | - protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
702 | + protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
703 | 703 | list($top, $right, $bottom, $left) = $widths; |
704 | 704 | |
705 | 705 | $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2); |
@@ -710,27 +710,27 @@ discard block |
||
710 | 710 | |
711 | 711 | case "top": |
712 | 712 | $x += $left / 2; |
713 | - $y += $top / 2; |
|
714 | - $length -= $left / 2 + $right / 2; |
|
715 | - break; |
|
713 | + $y += $top / 2; |
|
714 | + $length -= $left / 2 + $right / 2; |
|
715 | + break; |
|
716 | 716 | |
717 | 717 | case "bottom": |
718 | 718 | $x += $left / 2; |
719 | - $y -= $bottom / 2; |
|
720 | - $length -= $left / 2 + $right / 2; |
|
721 | - break; |
|
719 | + $y -= $bottom / 2; |
|
720 | + $length -= $left / 2 + $right / 2; |
|
721 | + break; |
|
722 | 722 | |
723 | 723 | case "left": |
724 | 724 | $x += $left / 2; |
725 | - $y += $top / 2; |
|
726 | - $length -= $top / 2 + $bottom / 2; |
|
727 | - break; |
|
725 | + $y += $top / 2; |
|
726 | + $length -= $top / 2 + $bottom / 2; |
|
727 | + break; |
|
728 | 728 | |
729 | 729 | case "right": |
730 | 730 | $x -= $right / 2; |
731 | - $y += $top / 2; |
|
732 | - $length -= $top / 2 + $bottom / 2; |
|
733 | - break; |
|
731 | + $y += $top / 2; |
|
732 | + $length -= $top / 2 + $bottom / 2; |
|
733 | + break; |
|
734 | 734 | |
735 | 735 | default: |
736 | 736 | return; |
@@ -739,9 +739,9 @@ discard block |
||
739 | 739 | |
740 | 740 | $this->_border_outset($x, $y, $length, $color, $half_widths, $side); |
741 | 741 | |
742 | - } |
|
742 | + } |
|
743 | 743 | |
744 | - protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
744 | + protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
745 | 745 | list($top, $right, $bottom, $left) = $widths; |
746 | 746 | |
747 | 747 | $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2); |
@@ -752,27 +752,27 @@ discard block |
||
752 | 752 | |
753 | 753 | case "top": |
754 | 754 | $x += $left / 2; |
755 | - $y += $top / 2; |
|
756 | - $length -= $left / 2 + $right / 2; |
|
757 | - break; |
|
755 | + $y += $top / 2; |
|
756 | + $length -= $left / 2 + $right / 2; |
|
757 | + break; |
|
758 | 758 | |
759 | 759 | case "bottom": |
760 | 760 | $x += $left / 2; |
761 | - $y -= $bottom / 2; |
|
762 | - $length -= $left / 2 + $right / 2; |
|
763 | - break; |
|
761 | + $y -= $bottom / 2; |
|
762 | + $length -= $left / 2 + $right / 2; |
|
763 | + break; |
|
764 | 764 | |
765 | 765 | case "left": |
766 | 766 | $x += $left / 2; |
767 | - $y += $top / 2; |
|
768 | - $length -= $top / 2 + $bottom / 2; |
|
769 | - break; |
|
767 | + $y += $top / 2; |
|
768 | + $length -= $top / 2 + $bottom / 2; |
|
769 | + break; |
|
770 | 770 | |
771 | 771 | case "right": |
772 | 772 | $x -= $right / 2; |
773 | - $y += $top / 2; |
|
774 | - $length -= $top / 2 + $bottom / 2; |
|
775 | - break; |
|
773 | + $y += $top / 2; |
|
774 | + $length -= $top / 2 + $bottom / 2; |
|
775 | + break; |
|
776 | 776 | |
777 | 777 | default: |
778 | 778 | return; |
@@ -781,23 +781,23 @@ discard block |
||
781 | 781 | |
782 | 782 | $this->_border_inset($x, $y, $length, $color, $half_widths, $side); |
783 | 783 | |
784 | - } |
|
784 | + } |
|
785 | 785 | |
786 | - protected function _tint($c) { |
|
786 | + protected function _tint($c) { |
|
787 | 787 | if ( !is_numeric($c) ) |
788 | - return $c; |
|
788 | + return $c; |
|
789 | 789 | |
790 | 790 | return min(1, $c + 0.66); |
791 | - } |
|
791 | + } |
|
792 | 792 | |
793 | - protected function _shade($c) { |
|
793 | + protected function _shade($c) { |
|
794 | 794 | if ( !is_numeric($c) ) |
795 | - return $c; |
|
795 | + return $c; |
|
796 | 796 | |
797 | 797 | return max(0, $c - 0.66); |
798 | - } |
|
798 | + } |
|
799 | 799 | |
800 | - protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
800 | + protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
801 | 801 | list($top, $right, $bottom, $left) = $widths; |
802 | 802 | |
803 | 803 | switch ($side) { |
@@ -805,43 +805,43 @@ discard block |
||
805 | 805 | case "top": |
806 | 806 | case "left": |
807 | 807 | $shade = array_map(array($this, "_shade"), $color); |
808 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
809 | - break; |
|
808 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
809 | + break; |
|
810 | 810 | |
811 | 811 | case "bottom": |
812 | 812 | case "right": |
813 | 813 | $tint = array_map(array($this, "_tint"), $color); |
814 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
815 | - break; |
|
814 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
815 | + break; |
|
816 | 816 | |
817 | 817 | default: |
818 | 818 | return; |
819 | 819 | } |
820 | - } |
|
820 | + } |
|
821 | 821 | |
822 | - protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
822 | + protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
823 | 823 | list($top, $right, $bottom, $left) = $widths; |
824 | 824 | |
825 | 825 | switch ($side) { |
826 | 826 | case "top": |
827 | 827 | case "left": |
828 | 828 | $tint = array_map(array($this, "_tint"), $color); |
829 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
830 | - break; |
|
829 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
830 | + break; |
|
831 | 831 | |
832 | 832 | case "bottom": |
833 | 833 | case "right": |
834 | 834 | $shade = array_map(array($this, "_shade"), $color); |
835 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
836 | - break; |
|
835 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
836 | + break; |
|
837 | 837 | |
838 | 838 | default: |
839 | 839 | return; |
840 | 840 | |
841 | 841 | } |
842 | - } |
|
842 | + } |
|
843 | 843 | |
844 | - //........................................................................ |
|
844 | + //........................................................................ |
|
845 | 845 | |
846 | 846 | |
847 | 847 | } |