@@ -58,9 +58,9 @@ |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | public function append(LoggerLoggingEvent $event) { |
61 | - if($this->layout !== null) { |
|
61 | + if ($this->layout !== null) { |
|
62 | 62 | $level = $event->getLevel(); |
63 | - if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
|
63 | + if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
|
64 | 64 | trigger_error($this->layout->format($event), E_USER_ERROR); |
65 | 65 | } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { |
66 | 66 | trigger_error($this->layout->format($event), E_USER_WARNING); |
@@ -82,10 +82,10 @@ |
||
82 | 82 | $numargs = func_num_args(); |
83 | 83 | $args = func_get_args(); |
84 | 84 | |
85 | - if($numargs == 1 and is_string($args[0])) { |
|
86 | - parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())) ); |
|
85 | + if ($numargs == 1 and is_string($args[0])) { |
|
86 | + parent::setFile(sprintf((string) $args[0], date($this->getDatePattern()))); |
|
87 | 87 | } else if ($numargs == 2 and is_string($args[0]) and is_bool($args[1])) { |
88 | - parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())), $args[1] ); |
|
88 | + parent::setFile(sprintf((string) $args[0], date($this->getDatePattern())), $args[1]); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function activateOptions() { |
116 | 116 | try { |
117 | - if($this->user === null) { |
|
117 | + if ($this->user === null) { |
|
118 | 118 | $this->db = new PDO($this->dsn); |
119 | - } else if($this->password === null) { |
|
119 | + } else if ($this->password === null) { |
|
120 | 120 | $this->db = new PDO($this->dsn, $this->user); |
121 | 121 | } else { |
122 | - $this->db = new PDO($this->dsn,$this->user,$this->password); |
|
122 | + $this->db = new PDO($this->dsn, $this->user, $this->password); |
|
123 | 123 | } |
124 | 124 | $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
125 | 125 | |
126 | 126 | // test if log table exists |
127 | 127 | try { |
128 | - $result = $this->db->query('SELECT * FROM ' . $this->table . ' WHERE 1 = 0'); |
|
128 | + $result = $this->db->query('SELECT * FROM '.$this->table.' WHERE 1 = 0'); |
|
129 | 129 | } catch (PDOException $e) { |
130 | 130 | // It could be something else but a "no such table" is the most likely |
131 | 131 | $result = false; |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | if ($result == false and $this->createTable) { |
136 | 136 | // The syntax should at least be compatible with MySQL, PostgreSQL, SQLite and Oracle. |
137 | 137 | $query = "CREATE TABLE {$this->table} (". |
138 | - "timestamp varchar(32)," . |
|
139 | - "logger varchar(64)," . |
|
140 | - "level varchar(32)," . |
|
141 | - "message varchar(9999)," . |
|
142 | - "thread varchar(32)," . |
|
143 | - "file varchar(255)," . |
|
138 | + "timestamp varchar(32),". |
|
139 | + "logger varchar(64),". |
|
140 | + "level varchar(32),". |
|
141 | + "message varchar(9999),". |
|
142 | + "thread varchar(32),". |
|
143 | + "file varchar(255),". |
|
144 | 144 | "line varchar(6))"; |
145 | 145 | $result = $this->db->query($query); |
146 | 146 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function append(LoggerLoggingEvent $event) { |
178 | 178 | // TODO: Can't activateOptions() simply throw an Exception if it encounters problems? |
179 | - if ( ! $this->canAppend) return; |
|
179 | + if (!$this->canAppend) return; |
|
180 | 180 | |
181 | 181 | try { |
182 | 182 | if (empty($this->sql)) { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * Closes the connection to the logging database |
198 | 198 | */ |
199 | 199 | public function close() { |
200 | - if($this->closed != true) { |
|
200 | + if ($this->closed != true) { |
|
201 | 201 | if ($this->db !== null) { |
202 | 202 | $db = null; |
203 | 203 | } |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | * Create a socket connection using defined parameters |
103 | 103 | */ |
104 | 104 | public function activateOptions() { |
105 | - if(!$this->dry) { |
|
105 | + if (!$this->dry) { |
|
106 | 106 | $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
107 | 107 | if ($this->sp === false) { |
108 | 108 | throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
109 | 109 | } |
110 | 110 | } |
111 | - if($this->getUseXml()) { |
|
111 | + if ($this->getUseXml()) { |
|
112 | 112 | $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
113 | - if($this->xmlLayout === null) { |
|
113 | + if ($this->xmlLayout === null) { |
|
114 | 114 | $this->setUseXml(false); |
115 | 115 | } else { |
116 | 116 | $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | public function close() { |
125 | - if($this->closed != true) { |
|
126 | - if(!$this->dry and $this->sp !== false) { |
|
125 | + if ($this->closed != true) { |
|
126 | + if (!$this->dry and $this->sp !== false) { |
|
127 | 127 | fclose($this->sp); |
128 | 128 | } |
129 | 129 | $this->closed = true; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function setPort($port) { |
206 | 206 | $port = LoggerOptionConverter::toInt($port, 0); |
207 | - if($port > 0 and $port < 65535) { |
|
207 | + if ($port > 0 and $port < 65535) { |
|
208 | 208 | $this->port = $port; |
209 | 209 | } |
210 | 210 | } |
@@ -231,20 +231,20 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | public function append(LoggerLoggingEvent $event) { |
234 | - if($this->sp || $this->dry) { |
|
235 | - if($this->getLocationInfo()) { |
|
234 | + if ($this->sp || $this->dry) { |
|
235 | + if ($this->getLocationInfo()) { |
|
236 | 236 | $event->getLocationInformation(); |
237 | 237 | } |
238 | 238 | |
239 | - if(!$this->getUseXml()) { |
|
239 | + if (!$this->getUseXml()) { |
|
240 | 240 | $sEvent = serialize($event); |
241 | - if(!$this->dry) { |
|
241 | + if (!$this->dry) { |
|
242 | 242 | fwrite($this->sp, $sEvent, strlen($sEvent)); |
243 | 243 | } else { |
244 | 244 | echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
245 | 245 | } |
246 | 246 | } else { |
247 | - if(!$this->dry) { |
|
247 | + if (!$this->dry) { |
|
248 | 248 | fwrite($this->sp, $this->xmlLayout->format($event)); |
249 | 249 | } else { |
250 | 250 | echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | // not sure about it... |
255 | - if(!$this->dry) { |
|
255 | + if (!$this->dry) { |
|
256 | 256 | fflush($this->sp); |
257 | 257 | } |
258 | 258 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class LoggerAppenderPool { |
28 | 28 | /* Appender Pool */ |
29 | - public static $appenderPool = null; |
|
29 | + public static $appenderPool = null; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | * @return LoggerAppender |
37 | 37 | */ |
38 | 38 | public static function getAppenderFromPool($name, $class = '') { |
39 | - if(isset(self::$appenderPool[$name])) { |
|
39 | + if (isset(self::$appenderPool[$name])) { |
|
40 | 40 | return self::$appenderPool[$name]; |
41 | 41 | } |
42 | 42 | |
43 | - if(empty($class)) { |
|
43 | + if (empty($class)) { |
|
44 | 44 | return null; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $appender = LoggerReflectionUtils::createObject($class); |
48 | 48 | $appender->setName($name); |
49 | - if($appender !== null) { |
|
49 | + if ($appender !== null) { |
|
50 | 50 | self::$appenderPool[$name] = $appender; |
51 | 51 | return self::$appenderPool[$name]; |
52 | 52 | } |
@@ -86,11 +86,11 @@ |
||
86 | 86 | * @static |
87 | 87 | */ |
88 | 88 | public static function get($key) { |
89 | - if(!empty($key)) { |
|
90 | - if(strpos($key, 'server.') === 0) { |
|
89 | + if (!empty($key)) { |
|
90 | + if (strpos($key, 'server.') === 0) { |
|
91 | 91 | $varName = substr($key, 7); |
92 | 92 | return @$_SERVER[$varName]; |
93 | - } else if(strpos($key, 'env.') === 0) { |
|
93 | + } else if (strpos($key, 'env.') === 0) { |
|
94 | 94 | $varName = substr($key, 4); |
95 | 95 | return @$_ENV[$varName]; |
96 | 96 | } else if (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return array |
122 | 122 | */ |
123 | 123 | public static function get() { |
124 | - if(!array_key_exists('log4php.LoggerNDC.ht', $GLOBALS)) { |
|
124 | + if (!array_key_exists('log4php.LoggerNDC.ht', $GLOBALS)) { |
|
125 | 125 | LoggerNDC::clear(); |
126 | 126 | } |
127 | 127 | return $GLOBALS['log4php.LoggerNDC.ht']; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @static |
150 | 150 | */ |
151 | 151 | public static function pop() { |
152 | - if(count($GLOBALS['log4php.LoggerNDC.ht']) > 0) { |
|
152 | + if (count($GLOBALS['log4php.LoggerNDC.ht']) > 0) { |
|
153 | 153 | return array_pop($GLOBALS['log4php.LoggerNDC.ht']); |
154 | 154 | } else { |
155 | 155 | return ''; |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * @return string The innermost diagnostic context. |
166 | 166 | * @static |
167 | 167 | */ |
168 | - public static function peek(){ |
|
169 | - if(count($GLOBALS['log4php.LoggerNDC.ht']) > 0) { |
|
168 | + public static function peek() { |
|
169 | + if (count($GLOBALS['log4php.LoggerNDC.ht']) > 0) { |
|
170 | 170 | return end($GLOBALS['log4php.LoggerNDC.ht']); |
171 | 171 | } else { |
172 | 172 | return ''; |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @static |
184 | 184 | */ |
185 | 185 | public static function push($message) { |
186 | - array_push($GLOBALS['log4php.LoggerNDC.ht'], (string)$message); |
|
186 | + array_push($GLOBALS['log4php.LoggerNDC.ht'], (string) $message); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * @static |
211 | 211 | */ |
212 | 212 | public static function setMaxDepth($maxDepth) { |
213 | - $maxDepth = (int)$maxDepth; |
|
214 | - if($maxDepth <= self::HT_SIZE) { |
|
215 | - if(LoggerNDC::getDepth() > $maxDepth) { |
|
213 | + $maxDepth = (int) $maxDepth; |
|
214 | + if ($maxDepth <= self::HT_SIZE) { |
|
215 | + if (LoggerNDC::getDepth() > $maxDepth) { |
|
216 | 216 | $GLOBALS['log4php.LoggerNDC.ht'] = array_slice($GLOBALS['log4php.LoggerNDC.ht'], $maxDepth); |
217 | 217 | } |
218 | 218 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function __construct($level = null) { |
35 | 35 | parent::__construct('root'); |
36 | 36 | |
37 | - if($level == null) { |
|
37 | + if ($level == null) { |
|
38 | 38 | $level = LoggerLevel::getLevelAll(); |
39 | 39 | } |
40 | 40 | $this->setLevel($level); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param LoggerLevel $level |
53 | 53 | */ |
54 | 54 | public function setLevel($level) { |
55 | - if($level != null) { |
|
55 | + if ($level != null) { |
|
56 | 56 | parent::setLevel($level); |
57 | 57 | } |
58 | 58 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @subpackage layouts |
50 | 50 | */ |
51 | 51 | class LoggerLayoutXml extends LoggerLayout { |
52 | - const LOG4J_NS_PREFIX ='log4j'; |
|
52 | + const LOG4J_NS_PREFIX = 'log4j'; |
|
53 | 53 | const LOG4J_NS = 'http://jakarta.apache.org/log4j/'; |
54 | 54 | |
55 | 55 | const LOG4PHP_NS_PREFIX = 'log4php'; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function format(LoggerLoggingEvent $event) { |
121 | 121 | $loggerName = $event->getLoggerName(); |
122 | - $timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', ''); |
|
122 | + $timeStamp = number_format((float) ($event->getTimeStamp() * 1000), 0, '', ''); |
|
123 | 123 | $thread = $event->getThreadName(); |
124 | 124 | $level = $event->getLevel(); |
125 | 125 | $levelStr = $level->toString(); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $buf .= "]]></{$this->_namespacePrefix}:message>".PHP_EOL; |
131 | 131 | |
132 | 132 | $ndc = $event->getNDC(); |
133 | - if($ndc != null) { |
|
133 | + if ($ndc != null) { |
|
134 | 134 | $buf .= "<{$this->_namespacePrefix}:NDC><![CDATA["; |
135 | 135 | $this->appendEscapingCDATA($buf, $ndc); |
136 | 136 | $buf .= "]]></{$this->_namespacePrefix}:NDC>".PHP_EOL; |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | if ($this->getLocationInfo()) { |
140 | 140 | $locationInfo = $event->getLocationInformation(); |
141 | 141 | $buf .= "<{$this->_namespacePrefix}:locationInfo ". |
142 | - "class=\"" . $locationInfo->getClassName() . "\" ". |
|
143 | - "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ". |
|
144 | - "line=\"" . $locationInfo->getLineNumber() . "\" ". |
|
145 | - "method=\"" . $locationInfo->getMethodName() . "\" "; |
|
142 | + "class=\"".$locationInfo->getClassName()."\" ". |
|
143 | + "file=\"".htmlentities($locationInfo->getFileName(), ENT_QUOTES)."\" ". |
|
144 | + "line=\"".$locationInfo->getLineNumber()."\" ". |
|
145 | + "method=\"".$locationInfo->getMethodName()."\" "; |
|
146 | 146 | $buf .= "/>".PHP_EOL; |
147 | 147 | |
148 | 148 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @static |
208 | 208 | */ |
209 | 209 | private function appendEscapingCDATA(&$buf, $str) { |
210 | - if(empty($str)) { |
|
210 | + if (empty($str)) { |
|
211 | 211 | return; |
212 | 212 | } |
213 | 213 |