@@ -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 | } |
@@ -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 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @var integer |
80 | 80 | */ |
81 | - private $maxBackupIndex = 1; |
|
81 | + private $maxBackupIndex = 1; |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @var string the filename expanded |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | */ |
118 | 118 | private function rollOver() { |
119 | 119 | // If maxBackups <= 0, then there is no file renaming to be done. |
120 | - if($this->maxBackupIndex > 0) { |
|
120 | + if ($this->maxBackupIndex > 0) { |
|
121 | 121 | $fileName = $this->getExpandedFileName(); |
122 | 122 | // Delete the oldest file, to keep Windows happy. |
123 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
124 | - if(is_writable($file)) |
|
123 | + $file = $fileName.'.'.$this->maxBackupIndex; |
|
124 | + if (is_writable($file)) |
|
125 | 125 | unlink($file); |
126 | 126 | // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
127 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
128 | - $file = $fileName . "." . $i; |
|
129 | - if(is_readable($file)) { |
|
130 | - $target = $fileName . '.' . ($i + 1); |
|
127 | + for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
128 | + $file = $fileName.".".$i; |
|
129 | + if (is_readable($file)) { |
|
130 | + $target = $fileName.'.'.($i + 1); |
|
131 | 131 | rename($file, $target); |
132 | 132 | } |
133 | 133 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $this->close(); |
136 | 136 | |
137 | 137 | // Rename fileName to fileName.1 |
138 | - $target = $fileName . ".1"; |
|
138 | + $target = $fileName.".1"; |
|
139 | 139 | $file = $fileName; |
140 | 140 | rename($file, $target); |
141 | 141 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param mixed $maxBackups |
168 | 168 | */ |
169 | 169 | public function setMaxBackupIndex($maxBackups) { |
170 | - if(is_numeric($maxBackups)) { |
|
171 | - $this->maxBackupIndex = abs((int)$maxBackups); |
|
170 | + if (is_numeric($maxBackups)) { |
|
171 | + $this->maxBackupIndex = abs((int) $maxBackups); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -199,20 +199,20 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function setMaxFileSize($value) { |
201 | 201 | $maxFileSize = null; |
202 | - $numpart = substr($value,0, strlen($value) -2); |
|
202 | + $numpart = substr($value, 0, strlen($value) - 2); |
|
203 | 203 | $suffix = strtoupper(substr($value, -2)); |
204 | 204 | |
205 | - switch($suffix) { |
|
206 | - case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
207 | - case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
208 | - case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
205 | + switch ($suffix) { |
|
206 | + case 'KB': $maxFileSize = (int) ((int) $numpart * 1024); break; |
|
207 | + case 'MB': $maxFileSize = (int) ((int) $numpart * 1024 * 1024); break; |
|
208 | + case 'GB': $maxFileSize = (int) ((int) $numpart * 1024 * 1024 * 1024); break; |
|
209 | 209 | default: |
210 | - if(is_numeric($value)) { |
|
211 | - $maxFileSize = (int)$value; |
|
210 | + if (is_numeric($value)) { |
|
211 | + $maxFileSize = (int) $value; |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if($maxFileSize !== null) { |
|
215 | + if ($maxFileSize !== null) { |
|
216 | 216 | $this->maxFileSize = abs($maxFileSize); |
217 | 217 | } |
218 | 218 | return $this->maxFileSize; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function append(LoggerLoggingEvent $event) { |
225 | 225 | parent::append($event); |
226 | - if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
226 | + if (ftell($this->fp) > $this->getMaximumFileSize()) { |
|
227 | 227 | $this->rollOver(); |
228 | 228 | } |
229 | 229 | } |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | public function close() { |
91 | - if($this->closed != true) { |
|
91 | + if ($this->closed != true) { |
|
92 | 92 | $from = $this->from; |
93 | 93 | $to = $this->to; |
94 | 94 | |
95 | - if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) { |
|
95 | + if (!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) { |
|
96 | 96 | $subject = $this->subject; |
97 | - if(!$this->dry) { |
|
97 | + if (!$this->dry) { |
|
98 | 98 | mail( |
99 | 99 | $to, $subject, |
100 | - $this->layout->getHeader() . $this->body . $this->layout->getFooter(), |
|
100 | + $this->layout->getHeader().$this->body.$this->layout->getFooter(), |
|
101 | 101 | "From: {$from}\r\n"); |
102 | 102 | } else { |
103 | 103 | echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | public function append(LoggerLoggingEvent $event) { |
127 | - if($this->layout !== null) { |
|
127 | + if ($this->layout !== null) { |
|
128 | 128 | $this->body .= $this->layout->format($event); |
129 | 129 | } |
130 | 130 | } |
@@ -84,17 +84,17 @@ |
||
84 | 84 | |
85 | 85 | public function activateOptions() { |
86 | 86 | $this->fp = fopen($this->target, 'w'); |
87 | - if(is_resource($this->fp) && $this->layout !== null) { |
|
87 | + if (is_resource($this->fp) && $this->layout !== null) { |
|
88 | 88 | fwrite($this->fp, $this->layout->getHeader()); |
89 | 89 | } |
90 | - $this->closed = (bool)is_resource($this->fp) === false; |
|
90 | + $this->closed = (bool) is_resource($this->fp) === false; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @see LoggerAppender::close() |
95 | 95 | */ |
96 | 96 | public function close() { |
97 | - if($this->closed != true) { |
|
97 | + if ($this->closed != true) { |
|
98 | 98 | if (is_resource($this->fp) && $this->layout !== null) { |
99 | 99 | fwrite($this->fp, $this->layout->getFooter()); |
100 | 100 | fclose($this->fp); |
@@ -165,19 +165,19 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | public function close() { |
168 | - if($this->closed != true) { |
|
168 | + if ($this->closed != true) { |
|
169 | 169 | closelog(); |
170 | 170 | $this->closed = true; |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | 174 | public function append(LoggerLoggingEvent $event) { |
175 | - if($this->_option == NULL){ |
|
175 | + if ($this->_option == NULL) { |
|
176 | 176 | $this->_option = LOG_PID | LOG_CONS; |
177 | 177 | } |
178 | 178 | |
179 | - $level = $event->getLevel(); |
|
180 | - if($this->layout === null) { |
|
179 | + $level = $event->getLevel(); |
|
180 | + if ($this->layout === null) { |
|
181 | 181 | $message = $event->getRenderedMessage(); |
182 | 182 | } else { |
183 | 183 | $message = $this->layout->format($event); |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | |
186 | 186 | // If the priority of a syslog message can be overridden by a value defined in the properties-file, |
187 | 187 | // use that value, else use the one that is defined in the code. |
188 | - if(!$this->dry) { |
|
188 | + if (!$this->dry) { |
|
189 | 189 | // Attach the process ID to the message, use the facility defined in the .properties-file |
190 | 190 | openlog($this->_ident, $this->_option, $this->_facility); |
191 | 191 | |
192 | - if($this->_overridePriority) { |
|
192 | + if ($this->_overridePriority) { |
|
193 | 193 | syslog($this->_priority, $message); |
194 | 194 | } else { |
195 | - if($level->isGreaterOrEqual(LoggerLevel::getLevelFatal())) { |
|
195 | + if ($level->isGreaterOrEqual(LoggerLevel::getLevelFatal())) { |
|
196 | 196 | syslog(LOG_ALERT, $message); |
197 | 197 | } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
198 | 198 | syslog(LOG_ERR, $message); |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | public function activateOptions() { |
68 | 68 | $fileName = $this->getFile(); |
69 | 69 | |
70 | - if(!is_file($fileName)) { |
|
70 | + if (!is_file($fileName)) { |
|
71 | 71 | $dir = dirname($fileName); |
72 | - if(!is_dir($dir)) { |
|
72 | + if (!is_dir($dir)) { |
|
73 | 73 | mkdir($dir, 0777, true); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
78 | - if($this->fp) { |
|
79 | - if(flock($this->fp, LOCK_EX)) { |
|
80 | - if($this->getAppend()) { |
|
77 | + $this->fp = fopen($fileName, ($this->getAppend() ? 'a' : 'w')); |
|
78 | + if ($this->fp) { |
|
79 | + if (flock($this->fp, LOCK_EX)) { |
|
80 | + if ($this->getAppend()) { |
|
81 | 81 | fseek($this->fp, 0, SEEK_END); |
82 | 82 | } |
83 | 83 | fwrite($this->fp, $this->layout->getHeader()); |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | public function close() { |
96 | - if($this->closed != true) { |
|
97 | - if($this->fp and $this->layout !== null) { |
|
98 | - if(flock($this->fp, LOCK_EX)) { |
|
96 | + if ($this->closed != true) { |
|
97 | + if ($this->fp and $this->layout !== null) { |
|
98 | + if (flock($this->fp, LOCK_EX)) { |
|
99 | 99 | fwrite($this->fp, $this->layout->getFooter()); |
100 | 100 | flock($this->fp, LOCK_UN); |
101 | 101 | } |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | public function append(LoggerLoggingEvent $event) { |
109 | - if($this->fp and $this->layout !== null) { |
|
110 | - if(flock($this->fp, LOCK_EX)) { |
|
109 | + if ($this->fp and $this->layout !== null) { |
|
110 | + if (flock($this->fp, LOCK_EX)) { |
|
111 | 111 | fwrite($this->fp, $this->layout->format($event)); |
112 | 112 | flock($this->fp, LOCK_UN); |
113 | 113 | } else { |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function setFile() { |
129 | 129 | $numargs = func_num_args(); |
130 | - $args = func_get_args(); |
|
130 | + $args = func_get_args(); |
|
131 | 131 | |
132 | - if($numargs == 1 and is_string($args[0])) { |
|
132 | + if ($numargs == 1 and is_string($args[0])) { |
|
133 | 133 | $this->setFileName($args[0]); |
134 | - } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
134 | + } else if ($numargs >= 2 and is_string($args[0]) and is_bool($args[1])) { |
|
135 | 135 | $this->setFile($args[0]); |
136 | 136 | $this->setAppend($args[1]); |
137 | 137 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | public function setPort($port) { |
127 | - $this->port = (int)$port; |
|
127 | + $this->port = (int) $port; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | public function setSmtpHost($smtpHost) { |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | public function append(LoggerLoggingEvent $event) { |
147 | 147 | $smtpHost = $this->smtpHost; |
148 | 148 | $prevSmtpHost = ini_get('SMTP'); |
149 | - if(!empty($smtpHost)) { |
|
149 | + if (!empty($smtpHost)) { |
|
150 | 150 | ini_set('SMTP', $smtpHost); |
151 | 151 | } |
152 | 152 | |
153 | 153 | $smtpPort = $this->port; |
154 | - $prevSmtpPort= ini_get('smtp_port'); |
|
155 | - if($smtpPort > 0 and $smtpPort < 65535) { |
|
154 | + $prevSmtpPort = ini_get('smtp_port'); |
|
155 | + if ($smtpPort > 0 and $smtpPort < 65535) { |
|
156 | 156 | ini_set('smtp_port', $smtpPort); |
157 | 157 | } |
158 | 158 | |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | |
161 | 161 | $addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n"; |
162 | 162 | |
163 | - if(!$this->dry) { |
|
163 | + if (!$this->dry) { |
|
164 | 164 | $result = mail($this->to, $this->subject, |
165 | - $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), |
|
165 | + $this->layout->getHeader().$this->layout->format($event).$this->layout->getFooter($event), |
|
166 | 166 | $addHeader); |
167 | 167 | if ($result === false) { |
168 | 168 | // The error message is only printed to stderr as warning. Any idea how to get it? |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | public function close() { |
62 | - if($this->closed != true) { |
|
63 | - if(!$this->firstAppend) { |
|
62 | + if ($this->closed != true) { |
|
63 | + if (!$this->firstAppend) { |
|
64 | 64 | echo $this->layout->getFooter(); |
65 | 65 | } |
66 | 66 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function append(LoggerLoggingEvent $event) { |
71 | - if($this->layout !== null) { |
|
72 | - if($this->firstAppend) { |
|
71 | + if ($this->layout !== null) { |
|
72 | + if ($this->firstAppend) { |
|
73 | 73 | echo $this->layout->getHeader(); |
74 | 74 | $this->firstAppend = false; |
75 | 75 | } |