@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $name = trim($name, ' \\'); |
| 44 | 44 | $fragments = explode('\\', $name); |
| 45 | 45 | |
| 46 | - foreach($fragments as $key => $fragment) { |
|
| 46 | + foreach ($fragments as $key => $fragment) { |
|
| 47 | 47 | if (trim($fragment) === '') { |
| 48 | 48 | unset($fragments[$key]); |
| 49 | 49 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return $name; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - foreach($fragments as $key => &$fragment) { |
|
| 97 | + foreach ($fragments as $key => &$fragment) { |
|
| 98 | 98 | |
| 99 | 99 | // Never shorten last fragment |
| 100 | 100 | if ($key == $count - 1) { |
@@ -80,14 +80,14 @@ |
||
| 80 | 80 | |
| 81 | 81 | public function activateOptions() { |
| 82 | 82 | $this->fp = fopen($this->target, 'w'); |
| 83 | - if(is_resource($this->fp) && $this->layout !== null) { |
|
| 83 | + if (is_resource($this->fp) && $this->layout !== null) { |
|
| 84 | 84 | fwrite($this->fp, $this->layout->getHeader()); |
| 85 | 85 | } |
| 86 | 86 | $this->closed = (bool)is_resource($this->fp) === false; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function close() { |
| 90 | - if($this->closed != true) { |
|
| 90 | + if ($this->closed != true) { |
|
| 91 | 91 | if (is_resource($this->fp) && $this->layout !== null) { |
| 92 | 92 | fwrite($this->fp, $this->layout->getFooter()); |
| 93 | 93 | fclose($this->fp); |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | private function rollOver() { |
| 116 | 116 | // If maxBackups <= 0, then there is no file renaming to be done. |
| 117 | - if($this->maxBackupIndex > 0) { |
|
| 117 | + if ($this->maxBackupIndex > 0) { |
|
| 118 | 118 | $fileName = $this->getExpandedFileName(); |
| 119 | 119 | |
| 120 | 120 | // Delete the oldest file, to keep Windows happy. |
| 121 | 121 | $file = $fileName . '.' . $this->maxBackupIndex; |
| 122 | - if(is_writable($file)) |
|
| 122 | + if (is_writable($file)) |
|
| 123 | 123 | unlink($file); |
| 124 | 124 | |
| 125 | 125 | // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
| 126 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 126 | + for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 127 | 127 | $file = $fileName . "." . $i; |
| 128 | - if(is_readable($file)) { |
|
| 128 | + if (is_readable($file)) { |
|
| 129 | 129 | $target = $fileName . '.' . ($i + 1); |
| 130 | 130 | rename($file, $target); |
| 131 | 131 | } |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
| 198 | - if($this->fp and $this->layout !== null) { |
|
| 199 | - if(flock($this->fp, LOCK_EX)) { |
|
| 198 | + if ($this->fp and $this->layout !== null) { |
|
| 199 | + if (flock($this->fp, LOCK_EX)) { |
|
| 200 | 200 | fwrite($this->fp, $this->layout->format($event)); |
| 201 | 201 | |
| 202 | 202 | // Stats cache must be cleared, otherwise filesize() returns cached results |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | public function close() { |
| 232 | - if($this->closed != true) { |
|
| 232 | + if ($this->closed != true) { |
|
| 233 | 233 | closelog(); |
| 234 | 234 | $this->closed = true; |
| 235 | 235 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | /** Determines which syslog priority to use based on the given level. */ |
| 257 | 257 | private function getSyslogPriority(Payone_Log4php_LoggerLevel $level) { |
| 258 | - if($this->overridePriority) { |
|
| 258 | + if ($this->overridePriority) { |
|
| 259 | 259 | return $this->intPriority; |
| 260 | 260 | } |
| 261 | 261 | return $level->getSyslogEquivalent(); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $value = 0; |
| 267 | 267 | $options = explode('|', $this->option); |
| 268 | 268 | |
| 269 | - foreach($options as $option) { |
|
| 269 | + foreach ($options as $option) { |
|
| 270 | 270 | if (!empty($option)) { |
| 271 | 271 | $constant = "LOG_" . trim($option); |
| 272 | 272 | if (defined($constant)) { |
@@ -133,7 +133,7 @@ |
||
| 133 | 133 | * @param string $className The name of the class to load. |
| 134 | 134 | */ |
| 135 | 135 | public static function autoload($className) { |
| 136 | - if(isset(self::$classes[$className])) { |
|
| 136 | + if (isset(self::$classes[$className])) { |
|
| 137 | 137 | require_once dirname(__FILE__) . self::$classes[$className]; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @subpackage layouts |
| 55 | 55 | */ |
| 56 | 56 | class Payone_Log4php_LoggerLayoutXml extends Payone_Log4php_LoggerLayout { |
| 57 | - const LOG4J_NS_PREFIX ='log4j'; |
|
| 57 | + const LOG4J_NS_PREFIX = 'log4j'; |
|
| 58 | 58 | const LOG4J_NS = 'http://jakarta.apache.org/log4j/'; |
| 59 | 59 | |
| 60 | 60 | const LOG4PHP_NS_PREFIX = 'log4php'; |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | * @return string |
| 100 | 100 | */ |
| 101 | 101 | public function getHeader() { |
| 102 | - return "<{$this->namespacePrefix}:eventSet ". |
|
| 103 | - "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ". |
|
| 104 | - "version=\"0.3\" ". |
|
| 105 | - "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"". |
|
| 102 | + return "<{$this->namespacePrefix}:eventSet " . |
|
| 103 | + "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" " . |
|
| 104 | + "version=\"0.3\" " . |
|
| 105 | + "includesLocationInfo=\"" . ($this->getLocationInfo() ? "true" : "false") . "\"" . |
|
| 106 | 106 | ">" . PHP_EOL; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -120,38 +120,38 @@ discard block |
||
| 120 | 120 | $thread = $event->getThreadName(); |
| 121 | 121 | $level = $event->getLevel()->toString(); |
| 122 | 122 | |
| 123 | - $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL; |
|
| 123 | + $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">" . PHP_EOL; |
|
| 124 | 124 | $buf .= "<$ns:message>"; |
| 125 | 125 | $buf .= $this->encodeCDATA($event->getRenderedMessage()); |
| 126 | - $buf .= "</$ns:message>".PHP_EOL; |
|
| 126 | + $buf .= "</$ns:message>" . PHP_EOL; |
|
| 127 | 127 | |
| 128 | 128 | $ndc = $event->getNDC(); |
| 129 | - if(!empty($ndc)) { |
|
| 129 | + if (!empty($ndc)) { |
|
| 130 | 130 | $buf .= "<$ns:NDC><![CDATA["; |
| 131 | 131 | $buf .= $this->encodeCDATA($ndc); |
| 132 | - $buf .= "]]></$ns:NDC>".PHP_EOL; |
|
| 132 | + $buf .= "]]></$ns:NDC>" . PHP_EOL; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $mdcMap = $event->getMDCMap(); |
| 136 | 136 | if (!empty($mdcMap)) { |
| 137 | - $buf .= "<$ns:properties>".PHP_EOL; |
|
| 137 | + $buf .= "<$ns:properties>" . PHP_EOL; |
|
| 138 | 138 | foreach ($mdcMap as $name=>$value) { |
| 139 | - $buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL; |
|
| 139 | + $buf .= "<$ns:data name=\"$name\" value=\"$value\" />" . PHP_EOL; |
|
| 140 | 140 | } |
| 141 | - $buf .= "</$ns:properties>".PHP_EOL; |
|
| 141 | + $buf .= "</$ns:properties>" . PHP_EOL; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if ($this->getLocationInfo()) { |
| 145 | 145 | $locationInfo = $event->getLocationInformation(); |
| 146 | - $buf .= "<$ns:locationInfo ". |
|
| 147 | - "class=\"" . $locationInfo->getClassName() . "\" ". |
|
| 148 | - "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ". |
|
| 149 | - "line=\"" . $locationInfo->getLineNumber() . "\" ". |
|
| 146 | + $buf .= "<$ns:locationInfo " . |
|
| 147 | + "class=\"" . $locationInfo->getClassName() . "\" " . |
|
| 148 | + "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" " . |
|
| 149 | + "line=\"" . $locationInfo->getLineNumber() . "\" " . |
|
| 150 | 150 | "method=\"" . $locationInfo->getMethodName() . "\" "; |
| 151 | - $buf .= "/>".PHP_EOL; |
|
| 151 | + $buf .= "/>" . PHP_EOL; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $buf .= "</$ns:event>".PHP_EOL; |
|
| 154 | + $buf .= "</$ns:event>" . PHP_EOL; |
|
| 155 | 155 | |
| 156 | 156 | return $buf; |
| 157 | 157 | } |
@@ -75,11 +75,11 @@ |
||
| 75 | 75 | * for given key. |
| 76 | 76 | */ |
| 77 | 77 | public static function get($key) { |
| 78 | - if(!empty($key)) { |
|
| 79 | - if(strpos($key, 'server.') === 0) { |
|
| 78 | + if (!empty($key)) { |
|
| 79 | + if (strpos($key, 'server.') === 0) { |
|
| 80 | 80 | $varName = substr($key, 7); |
| 81 | 81 | return isset($_SERVER[$varName]) ? $_SERVER[$varName] : ''; |
| 82 | - } else if(strpos($key, 'env.') === 0) { |
|
| 82 | + } else if (strpos($key, 'env.') === 0) { |
|
| 83 | 83 | $varName = substr($key, 4); |
| 84 | 84 | $value = getenv($varName); |
| 85 | 85 | return ($value !== false) ? $value : ''; |
@@ -50,17 +50,17 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Process <logger> nodes |
| 53 | - foreach($xml->logger as $logger) { |
|
| 53 | + foreach ($xml->logger as $logger) { |
|
| 54 | 54 | $this->parseLogger($logger); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // Process <appender> nodes |
| 58 | - foreach($xml->appender as $appender) { |
|
| 58 | + foreach ($xml->appender as $appender) { |
|
| 59 | 59 | $this->parseAppender($appender); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Process <renderer> nodes |
| 63 | - foreach($xml->renderer as $rendererNode) { |
|
| 63 | + foreach ($xml->renderer as $rendererNode) { |
|
| 64 | 64 | $this->parseRenderer($rendererNode); |
| 65 | 65 | } |
| 66 | 66 | return $this->config; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | if ($xml === false) { |
| 84 | 84 | |
| 85 | 85 | $errorStr = ""; |
| 86 | - foreach(libxml_get_errors() as $error) { |
|
| 86 | + foreach (libxml_get_errors() as $error) { |
|
| 87 | 87 | $errorStr .= $error->message; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | private function parseConfiguration(SimpleXMLElement $xml) { |
| 103 | 103 | $attributes = $xml->attributes(); |
| 104 | 104 | if (isset($attributes['threshold'])) { |
| 105 | - $this->config['threshold'] = (string) $attributes['threshold']; |
|
| 105 | + $this->config['threshold'] = (string)$attributes['threshold']; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
@@ -122,14 +122,14 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | if (isset($node->layout)) { |
| 125 | - $appender['layout']= $this->parseLayout($node->layout, $name); |
|
| 125 | + $appender['layout'] = $this->parseLayout($node->layout, $name); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | if (count($node->param) > 0) { |
| 129 | 129 | $appender['params'] = $this->parseParameters($node); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - foreach($node->filter as $filterNode) { |
|
| 132 | + foreach ($node->filter as $filterNode) { |
|
| 133 | 133 | $appender['filters'][] = $this->parseFilter($filterNode); |
| 134 | 134 | } |
| 135 | 135 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | private function parseParameters($paramsNode) { |
| 153 | 153 | $params = array(); |
| 154 | 154 | |
| 155 | - foreach($paramsNode->param as $paramNode) { |
|
| 155 | + foreach ($paramsNode->param as $paramNode) { |
|
| 156 | 156 | if (empty($paramNode['name'])) { |
| 157 | 157 | $this->warn("A <param> node is missing the required 'name' attribute. Skipping parameter."); |
| 158 | 158 | continue; |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $logger['appenders'] = array(); |
| 179 | - foreach($node->appender_ref as $appender) { |
|
| 179 | + foreach ($node->appender_ref as $appender) { |
|
| 180 | 180 | $logger['appenders'][] = $this->getAttributeValue($appender, 'ref'); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | private function parseAppenderReferences(SimpleXMLElement $node, $name) { |
| 218 | 218 | $refs = array(); |
| 219 | - foreach($node->appender_ref as $ref) { |
|
| 219 | + foreach ($node->appender_ref as $ref) { |
|
| 220 | 220 | $refs[] = $this->getAttributeValue($ref, 'ref'); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | // ****************************************** |
| 249 | 249 | |
| 250 | 250 | private function getAttributeValue(SimpleXMLElement $node, $name) { |
| 251 | - return isset($node[$name]) ? (string) $node[$name] : null; |
|
| 251 | + return isset($node[$name]) ? (string)$node[$name] : null; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | private function warn($message) { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param LoggerFilter $filter add a new LoggerFilter |
| 102 | 102 | */ |
| 103 | 103 | public function addFilter($filter) { |
| 104 | - if($this->filter === null) { |
|
| 104 | + if ($this->filter === null) { |
|
| 105 | 105 | $this->filter = $filter; |
| 106 | 106 | } else { |
| 107 | 107 | $this->filter->addNext($filter); |
@@ -140,16 +140,16 @@ discard block |
||
| 140 | 140 | * @param Payone_Log4php_LoggerLoggingEvent $event |
| 141 | 141 | */ |
| 142 | 142 | public function doAppend(Payone_Log4php_LoggerLoggingEvent $event) { |
| 143 | - if($this->closed) { |
|
| 143 | + if ($this->closed) { |
|
| 144 | 144 | return; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if(!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
| 147 | + if (!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
| 148 | 148 | return; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $f = $this->getFirstFilter(); |
| 152 | - while($f !== null) { |
|
| 152 | + while ($f !== null) { |
|
| 153 | 153 | switch ($f->decide($event)) { |
| 154 | 154 | case Payone_Log4php_LoggerFilter::DENY: return; |
| 155 | 155 | case Payone_Log4php_LoggerFilter::ACCEPT: return $this->append($event); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param Payone_Log4php_LoggerLayout $layout |
| 165 | 165 | */ |
| 166 | 166 | public function setLayout($layout) { |
| 167 | - if($this->requiresLayout()) { |
|
| 167 | + if ($this->requiresLayout()) { |
|
| 168 | 168 | $this->layout = $layout; |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * threshold, or if the threshold is not set. Otherwise returns false. |
| 244 | 244 | */ |
| 245 | 245 | public function isAsSevereAsThreshold($level) { |
| 246 | - if($this->threshold === null) { |
|
| 246 | + if ($this->threshold === null) { |
|
| 247 | 247 | return true; |
| 248 | 248 | } |
| 249 | 249 | return $level->isGreaterOrEqual($this->getThreshold()); |