@@ -41,40 +41,40 @@ |
||
41 | 41 | * @subpackage appenders |
42 | 42 | */ |
43 | 43 | class LoggerAppenderEcho extends LoggerAppender { |
44 | - /** boolean used internally to mark first append */ |
|
45 | - private $firstAppend = true; |
|
44 | + /** boolean used internally to mark first append */ |
|
45 | + private $firstAppend = true; |
|
46 | 46 | |
47 | - public function __construct($name = '') { |
|
48 | - parent::__construct($name); |
|
49 | - $this->requiresLayout = true; |
|
50 | - $this->firstAppend = true; |
|
51 | - } |
|
47 | + public function __construct($name = '') { |
|
48 | + parent::__construct($name); |
|
49 | + $this->requiresLayout = true; |
|
50 | + $this->firstAppend = true; |
|
51 | + } |
|
52 | 52 | |
53 | - public function __destruct() { |
|
54 | - $this->close(); |
|
55 | - } |
|
53 | + public function __destruct() { |
|
54 | + $this->close(); |
|
55 | + } |
|
56 | 56 | |
57 | - public function activateOptions() { |
|
58 | - $this->closed = false; |
|
59 | - } |
|
57 | + public function activateOptions() { |
|
58 | + $this->closed = false; |
|
59 | + } |
|
60 | 60 | |
61 | - public function close() { |
|
62 | - if($this->closed != true) { |
|
63 | - if(!$this->firstAppend) { |
|
64 | - echo $this->layout->getFooter(); |
|
65 | - } |
|
66 | - } |
|
67 | - $this->closed = true; |
|
68 | - } |
|
61 | + public function close() { |
|
62 | + if($this->closed != true) { |
|
63 | + if(!$this->firstAppend) { |
|
64 | + echo $this->layout->getFooter(); |
|
65 | + } |
|
66 | + } |
|
67 | + $this->closed = true; |
|
68 | + } |
|
69 | 69 | |
70 | - public function append(LoggerLoggingEvent $event) { |
|
71 | - if($this->layout !== null) { |
|
72 | - if($this->firstAppend) { |
|
73 | - echo $this->layout->getHeader(); |
|
74 | - $this->firstAppend = false; |
|
75 | - } |
|
76 | - echo $this->layout->format($event); |
|
77 | - } |
|
78 | - } |
|
70 | + public function append(LoggerLoggingEvent $event) { |
|
71 | + if($this->layout !== null) { |
|
72 | + if($this->firstAppend) { |
|
73 | + echo $this->layout->getHeader(); |
|
74 | + $this->firstAppend = false; |
|
75 | + } |
|
76 | + echo $this->layout->format($event); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 |
@@ -121,10 +121,10 @@ |
||
121 | 121 | { |
122 | 122 | $this->db = &ADONewConnection($this->type); |
123 | 123 | if (! $this->db->PConnect($this->host, $this->user, $this->password, $this->database)) { |
124 | - $this->db = null; |
|
125 | - $this->closed = true; |
|
126 | - $this->canAppend = false; |
|
127 | - return; |
|
124 | + $this->db = null; |
|
125 | + $this->closed = true; |
|
126 | + $this->canAppend = false; |
|
127 | + return; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $this->layout = LoggerReflectionUtils::createObject('LoggerLayoutPattern'); |
@@ -40,33 +40,33 @@ |
||
40 | 40 | */ |
41 | 41 | class LoggerAppenderPhp extends LoggerAppender { |
42 | 42 | |
43 | - public function __construct($name = '') { |
|
44 | - parent::__construct($name); |
|
45 | - $this->requiresLayout = true; |
|
46 | - } |
|
43 | + public function __construct($name = '') { |
|
44 | + parent::__construct($name); |
|
45 | + $this->requiresLayout = true; |
|
46 | + } |
|
47 | 47 | |
48 | - public function __destruct() { |
|
49 | - $this->close(); |
|
50 | - } |
|
48 | + public function __destruct() { |
|
49 | + $this->close(); |
|
50 | + } |
|
51 | 51 | |
52 | - public function activateOptions() { |
|
53 | - $this->closed = false; |
|
54 | - } |
|
52 | + public function activateOptions() { |
|
53 | + $this->closed = false; |
|
54 | + } |
|
55 | 55 | |
56 | - public function close() { |
|
57 | - $this->closed = true; |
|
58 | - } |
|
56 | + public function close() { |
|
57 | + $this->closed = true; |
|
58 | + } |
|
59 | 59 | |
60 | - public function append(LoggerLoggingEvent $event) { |
|
61 | - if($this->layout !== null) { |
|
62 | - $level = $event->getLevel(); |
|
63 | - if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
|
64 | - trigger_error($this->layout->format($event), E_USER_ERROR); |
|
65 | - } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { |
|
66 | - trigger_error($this->layout->format($event), E_USER_WARNING); |
|
67 | - } else { |
|
68 | - trigger_error($this->layout->format($event), E_USER_NOTICE); |
|
69 | - } |
|
70 | - } |
|
71 | - } |
|
60 | + public function append(LoggerLoggingEvent $event) { |
|
61 | + if($this->layout !== null) { |
|
62 | + $level = $event->getLevel(); |
|
63 | + if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
|
64 | + trigger_error($this->layout->format($event), E_USER_ERROR); |
|
65 | + } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { |
|
66 | + trigger_error($this->layout->format($event), E_USER_WARNING); |
|
67 | + } else { |
|
68 | + trigger_error($this->layout->format($event), E_USER_NOTICE); |
|
69 | + } |
|
70 | + } |
|
71 | + } |
|
72 | 72 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | /** Create the log table if it does not exists (optional). |
50 | 50 | * @var string */ |
51 | - private $createTable = true; |
|
51 | + private $createTable = true; |
|
52 | 52 | |
53 | 53 | /** Database user name. |
54 | 54 | * @var string */ |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | $this->requiresLayout = false; |
102 | 102 | } |
103 | 103 | |
104 | - public function __destruct() { |
|
105 | - $this->close(); |
|
106 | - } |
|
104 | + public function __destruct() { |
|
105 | + $this->close(); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Setup db connection. |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function activateOptions() { |
116 | 116 | try { |
117 | - if($this->user === null) { |
|
118 | - $this->db = new PDO($this->dsn); |
|
119 | - } else if($this->password === null) { |
|
120 | - $this->db = new PDO($this->dsn, $this->user); |
|
121 | - } else { |
|
122 | - $this->db = new PDO($this->dsn,$this->user,$this->password); |
|
123 | - } |
|
124 | - $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
117 | + if($this->user === null) { |
|
118 | + $this->db = new PDO($this->dsn); |
|
119 | + } else if($this->password === null) { |
|
120 | + $this->db = new PDO($this->dsn, $this->user); |
|
121 | + } else { |
|
122 | + $this->db = new PDO($this->dsn,$this->user,$this->password); |
|
123 | + } |
|
124 | + $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
125 | 125 | |
126 | 126 | // test if log table exists |
127 | 127 | try { |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | // The syntax should at least be compatible with MySQL, PostgreSQL, SQLite and Oracle. |
137 | 137 | $query = "CREATE TABLE {$this->table} (". |
138 | 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 | - "line varchar(6))"; |
|
139 | + "logger varchar(64)," . |
|
140 | + "level varchar(32)," . |
|
141 | + "message varchar(9999)," . |
|
142 | + "thread varchar(32)," . |
|
143 | + "file varchar(255)," . |
|
144 | + "line varchar(6))"; |
|
145 | 145 | $result = $this->db->query($query); |
146 | 146 | } |
147 | 147 | } catch (PDOException $e) { |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | * Closes the connection to the logging database |
198 | 198 | */ |
199 | 199 | public function close() { |
200 | - if($this->closed != true) { |
|
201 | - if ($this->db !== null) { |
|
202 | - $db = null; |
|
203 | - } |
|
204 | - $this->closed = true; |
|
205 | - } |
|
200 | + if($this->closed != true) { |
|
201 | + if ($this->db !== null) { |
|
202 | + $db = null; |
|
203 | + } |
|
204 | + $this->closed = true; |
|
205 | + } |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -229,19 +229,19 @@ discard block |
||
229 | 229 | $this->createTable = LoggerOptionConverter::toBoolean($flag, true); |
230 | 230 | } |
231 | 231 | |
232 | - /** |
|
233 | - * Sets the SQL string into which the event should be transformed. |
|
234 | - * Defaults to: |
|
235 | - * |
|
236 | - * INSERT INTO $this->table |
|
237 | - * ( timestamp, logger, level, message, thread, file, line) |
|
238 | - * VALUES |
|
239 | - * ('%d','%c','%p','%m','%t','%F','%L') |
|
240 | - * |
|
241 | - * It's not necessary to change this except you have customized logging' |
|
242 | - * |
|
243 | - * @deprecated See {@link setInsertSql} and {@link setInsertPattern}. |
|
244 | - */ |
|
232 | + /** |
|
233 | + * Sets the SQL string into which the event should be transformed. |
|
234 | + * Defaults to: |
|
235 | + * |
|
236 | + * INSERT INTO $this->table |
|
237 | + * ( timestamp, logger, level, message, thread, file, line) |
|
238 | + * VALUES |
|
239 | + * ('%d','%c','%p','%m','%t','%F','%L') |
|
240 | + * |
|
241 | + * It's not necessary to change this except you have customized logging' |
|
242 | + * |
|
243 | + * @deprecated See {@link setInsertSql} and {@link setInsertPattern}. |
|
244 | + */ |
|
245 | 245 | public function setSql($sql) { |
246 | 246 | $this->sql = $sql; |
247 | 247 | } |
@@ -35,26 +35,26 @@ |
||
35 | 35 | */ |
36 | 36 | class LoggerAppenderNull extends LoggerAppender { |
37 | 37 | |
38 | - protected $requiresLayout = false; |
|
38 | + protected $requiresLayout = false; |
|
39 | 39 | |
40 | - public function __destruct() { |
|
41 | - $this->close(); |
|
42 | - } |
|
40 | + public function __destruct() { |
|
41 | + $this->close(); |
|
42 | + } |
|
43 | 43 | |
44 | - public function activateOptions() { |
|
45 | - $this->closed = false; |
|
46 | - } |
|
44 | + public function activateOptions() { |
|
45 | + $this->closed = false; |
|
46 | + } |
|
47 | 47 | |
48 | - public function close() { |
|
49 | - $this->closed = true; |
|
50 | - } |
|
48 | + public function close() { |
|
49 | + $this->closed = true; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Do nothing. |
|
54 | - * |
|
55 | - * @param LoggerLoggingEvent $event |
|
56 | - */ |
|
57 | - public function append(LoggerLoggingEvent $event) { |
|
58 | - } |
|
52 | + /** |
|
53 | + * Do nothing. |
|
54 | + * |
|
55 | + * @param LoggerLoggingEvent $event |
|
56 | + */ |
|
57 | + public function append(LoggerLoggingEvent $event) { |
|
58 | + } |
|
59 | 59 | } |
60 | 60 |
@@ -46,215 +46,215 @@ |
||
46 | 46 | */ |
47 | 47 | class LoggerAppenderSocket extends LoggerAppender { |
48 | 48 | |
49 | - /** |
|
50 | - * @var mixed socket connection resource |
|
51 | - * @access private |
|
52 | - */ |
|
53 | - private $sp = false; |
|
49 | + /** |
|
50 | + * @var mixed socket connection resource |
|
51 | + * @access private |
|
52 | + */ |
|
53 | + private $sp = false; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Target host. On how to define remote hostaname see |
|
57 | - * {@link PHP_MANUAL#fsockopen} |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - private $remoteHost = ''; |
|
55 | + /** |
|
56 | + * Target host. On how to define remote hostaname see |
|
57 | + * {@link PHP_MANUAL#fsockopen} |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + private $remoteHost = ''; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @var integer the network port. |
|
64 | - */ |
|
65 | - private $port = 4446; |
|
62 | + /** |
|
63 | + * @var integer the network port. |
|
64 | + */ |
|
65 | + private $port = 4446; |
|
66 | 66 | |
67 | - /** |
|
68 | - * @var boolean get event's location info. |
|
69 | - */ |
|
70 | - private $locationInfo = false; |
|
67 | + /** |
|
68 | + * @var boolean get event's location info. |
|
69 | + */ |
|
70 | + private $locationInfo = false; |
|
71 | 71 | |
72 | - /** |
|
73 | - * @var integer connection timeout |
|
74 | - */ |
|
75 | - private $timeout = 30; |
|
72 | + /** |
|
73 | + * @var integer connection timeout |
|
74 | + */ |
|
75 | + private $timeout = 30; |
|
76 | 76 | |
77 | - /** |
|
78 | - * @var boolean output events via {@link LoggerXmlLayout} |
|
79 | - */ |
|
80 | - private $useXml = false; |
|
77 | + /** |
|
78 | + * @var boolean output events via {@link LoggerXmlLayout} |
|
79 | + */ |
|
80 | + private $useXml = false; |
|
81 | 81 | |
82 | - /** |
|
83 | - * @var boolean forward this option to {@link LoggerXmlLayout}. |
|
84 | - * Ignored if {@link $useXml} is <i>false</i>. |
|
85 | - */ |
|
86 | - private $log4jNamespace = false; |
|
82 | + /** |
|
83 | + * @var boolean forward this option to {@link LoggerXmlLayout}. |
|
84 | + * Ignored if {@link $useXml} is <i>false</i>. |
|
85 | + */ |
|
86 | + private $log4jNamespace = false; |
|
87 | 87 | |
88 | - /** |
|
89 | - * @var LoggerXmlLayout |
|
90 | - * @access private |
|
91 | - */ |
|
92 | - private $xmlLayout = null; |
|
88 | + /** |
|
89 | + * @var LoggerXmlLayout |
|
90 | + * @access private |
|
91 | + */ |
|
92 | + private $xmlLayout = null; |
|
93 | 93 | |
94 | - /** @var indiciates if this appender should run in dry mode */ |
|
95 | - private $dry = false; |
|
94 | + /** @var indiciates if this appender should run in dry mode */ |
|
95 | + private $dry = false; |
|
96 | 96 | |
97 | - public function __destruct() { |
|
98 | - $this->close(); |
|
99 | - } |
|
97 | + public function __destruct() { |
|
98 | + $this->close(); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Create a socket connection using defined parameters |
|
103 | - */ |
|
104 | - public function activateOptions() { |
|
105 | - if(!$this->dry) { |
|
106 | - $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
|
107 | - if ($this->sp === false) { |
|
108 | - throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
|
109 | - } |
|
110 | - } |
|
111 | - if($this->getUseXml()) { |
|
112 | - $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
|
113 | - if($this->xmlLayout === null) { |
|
114 | - $this->setUseXml(false); |
|
115 | - } else { |
|
116 | - $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
|
117 | - $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace()); |
|
118 | - $this->xmlLayout->activateOptions(); |
|
119 | - } |
|
120 | - } |
|
101 | + /** |
|
102 | + * Create a socket connection using defined parameters |
|
103 | + */ |
|
104 | + public function activateOptions() { |
|
105 | + if(!$this->dry) { |
|
106 | + $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
|
107 | + if ($this->sp === false) { |
|
108 | + throw new LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)"); |
|
109 | + } |
|
110 | + } |
|
111 | + if($this->getUseXml()) { |
|
112 | + $this->xmlLayout = LoggerReflectionUtils::createObject('LoggerLayoutXml'); |
|
113 | + if($this->xmlLayout === null) { |
|
114 | + $this->setUseXml(false); |
|
115 | + } else { |
|
116 | + $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
|
117 | + $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace()); |
|
118 | + $this->xmlLayout->activateOptions(); |
|
119 | + } |
|
120 | + } |
|
121 | 121 | $this->closed = false; |
122 | - } |
|
122 | + } |
|
123 | 123 | |
124 | - public function close() { |
|
125 | - if($this->closed != true) { |
|
126 | - if(!$this->dry and $this->sp !== false) { |
|
127 | - fclose($this->sp); |
|
128 | - } |
|
129 | - $this->closed = true; |
|
130 | - } |
|
131 | - } |
|
124 | + public function close() { |
|
125 | + if($this->closed != true) { |
|
126 | + if(!$this->dry and $this->sp !== false) { |
|
127 | + fclose($this->sp); |
|
128 | + } |
|
129 | + $this->closed = true; |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - public function setDry($dry) { |
|
134 | - $this->dry = $dry; |
|
135 | - } |
|
133 | + public function setDry($dry) { |
|
134 | + $this->dry = $dry; |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function getHostname() { |
|
141 | - return $this->getRemoteHost(); |
|
142 | - } |
|
137 | + /** |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function getHostname() { |
|
141 | + return $this->getRemoteHost(); |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * @return boolean |
|
146 | - */ |
|
147 | - public function getLocationInfo() { |
|
148 | - return $this->locationInfo; |
|
149 | - } |
|
144 | + /** |
|
145 | + * @return boolean |
|
146 | + */ |
|
147 | + public function getLocationInfo() { |
|
148 | + return $this->locationInfo; |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @return boolean |
|
153 | - */ |
|
154 | - public function getLog4jNamespace() { |
|
155 | - return $this->log4jNamespace; |
|
156 | - } |
|
151 | + /** |
|
152 | + * @return boolean |
|
153 | + */ |
|
154 | + public function getLog4jNamespace() { |
|
155 | + return $this->log4jNamespace; |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * @return integer |
|
160 | - */ |
|
161 | - public function getPort() { |
|
162 | - return $this->port; |
|
163 | - } |
|
158 | + /** |
|
159 | + * @return integer |
|
160 | + */ |
|
161 | + public function getPort() { |
|
162 | + return $this->port; |
|
163 | + } |
|
164 | 164 | |
165 | - public function getRemoteHost() { |
|
166 | - return $this->remoteHost; |
|
167 | - } |
|
165 | + public function getRemoteHost() { |
|
166 | + return $this->remoteHost; |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * @return integer |
|
171 | - */ |
|
172 | - public function getTimeout() { |
|
173 | - return $this->timeout; |
|
174 | - } |
|
169 | + /** |
|
170 | + * @return integer |
|
171 | + */ |
|
172 | + public function getTimeout() { |
|
173 | + return $this->timeout; |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * @var boolean |
|
178 | - */ |
|
179 | - public function getUseXml() { |
|
180 | - return $this->useXml; |
|
181 | - } |
|
176 | + /** |
|
177 | + * @var boolean |
|
178 | + */ |
|
179 | + public function getUseXml() { |
|
180 | + return $this->useXml; |
|
181 | + } |
|
182 | 182 | |
183 | - public function reset() { |
|
184 | - $this->close(); |
|
185 | - parent::reset(); |
|
186 | - } |
|
183 | + public function reset() { |
|
184 | + $this->close(); |
|
185 | + parent::reset(); |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * @param mixed |
|
190 | - */ |
|
191 | - public function setLocationInfo($flag) { |
|
192 | - $this->locationInfo = LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo()); |
|
193 | - } |
|
188 | + /** |
|
189 | + * @param mixed |
|
190 | + */ |
|
191 | + public function setLocationInfo($flag) { |
|
192 | + $this->locationInfo = LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo()); |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * @param mixed |
|
197 | - */ |
|
198 | - public function setLog4jNamespace($flag) { |
|
199 | - $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace()); |
|
200 | - } |
|
195 | + /** |
|
196 | + * @param mixed |
|
197 | + */ |
|
198 | + public function setLog4jNamespace($flag) { |
|
199 | + $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace()); |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * @param integer |
|
204 | - */ |
|
205 | - public function setPort($port) { |
|
206 | - $port = LoggerOptionConverter::toInt($port, 0); |
|
207 | - if($port > 0 and $port < 65535) { |
|
208 | - $this->port = $port; |
|
209 | - } |
|
210 | - } |
|
202 | + /** |
|
203 | + * @param integer |
|
204 | + */ |
|
205 | + public function setPort($port) { |
|
206 | + $port = LoggerOptionConverter::toInt($port, 0); |
|
207 | + if($port > 0 and $port < 65535) { |
|
208 | + $this->port = $port; |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * @param string |
|
214 | - */ |
|
215 | - public function setRemoteHost($hostname) { |
|
216 | - $this->remoteHost = $hostname; |
|
217 | - } |
|
212 | + /** |
|
213 | + * @param string |
|
214 | + */ |
|
215 | + public function setRemoteHost($hostname) { |
|
216 | + $this->remoteHost = $hostname; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * @param integer |
|
221 | - */ |
|
222 | - public function setTimeout($timeout) { |
|
223 | - $this->timeout = LoggerOptionConverter::toInt($timeout, $this->getTimeout()); |
|
224 | - } |
|
219 | + /** |
|
220 | + * @param integer |
|
221 | + */ |
|
222 | + public function setTimeout($timeout) { |
|
223 | + $this->timeout = LoggerOptionConverter::toInt($timeout, $this->getTimeout()); |
|
224 | + } |
|
225 | 225 | |
226 | - /** |
|
227 | - * @param mixed |
|
228 | - */ |
|
229 | - public function setUseXml($flag) { |
|
230 | - $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
|
231 | - } |
|
226 | + /** |
|
227 | + * @param mixed |
|
228 | + */ |
|
229 | + public function setUseXml($flag) { |
|
230 | + $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
|
231 | + } |
|
232 | 232 | |
233 | - public function append(LoggerLoggingEvent $event) { |
|
234 | - if($this->sp || $this->dry) { |
|
235 | - if($this->getLocationInfo()) { |
|
236 | - $event->getLocationInformation(); |
|
237 | - } |
|
233 | + public function append(LoggerLoggingEvent $event) { |
|
234 | + if($this->sp || $this->dry) { |
|
235 | + if($this->getLocationInfo()) { |
|
236 | + $event->getLocationInformation(); |
|
237 | + } |
|
238 | 238 | |
239 | - if(!$this->getUseXml()) { |
|
240 | - $sEvent = serialize($event); |
|
241 | - if(!$this->dry) { |
|
242 | - fwrite($this->sp, $sEvent, strlen($sEvent)); |
|
243 | - } else { |
|
244 | - echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
|
245 | - } |
|
246 | - } else { |
|
247 | - if(!$this->dry) { |
|
248 | - fwrite($this->sp, $this->xmlLayout->format($event)); |
|
249 | - } else { |
|
250 | - echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
|
251 | - } |
|
252 | - } |
|
239 | + if(!$this->getUseXml()) { |
|
240 | + $sEvent = serialize($event); |
|
241 | + if(!$this->dry) { |
|
242 | + fwrite($this->sp, $sEvent, strlen($sEvent)); |
|
243 | + } else { |
|
244 | + echo "DRY MODE OF SOCKET APPENDER: ".$sEvent; |
|
245 | + } |
|
246 | + } else { |
|
247 | + if(!$this->dry) { |
|
248 | + fwrite($this->sp, $this->xmlLayout->format($event)); |
|
249 | + } else { |
|
250 | + echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event); |
|
251 | + } |
|
252 | + } |
|
253 | 253 | |
254 | - // not sure about it... |
|
255 | - if(!$this->dry) { |
|
256 | - fflush($this->sp); |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
254 | + // not sure about it... |
|
255 | + if(!$this->dry) { |
|
256 | + fflush($this->sp); |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | 260 | } |
@@ -25,31 +25,31 @@ |
||
25 | 25 | * @package log4php |
26 | 26 | */ |
27 | 27 | class LoggerAppenderPool { |
28 | - /* Appender Pool */ |
|
29 | - public static $appenderPool = null; |
|
28 | + /* Appender Pool */ |
|
29 | + public static $appenderPool = null; |
|
30 | 30 | |
31 | - /** |
|
32 | - * |
|
33 | - * |
|
34 | - * @param string $name |
|
35 | - * @param string $class |
|
36 | - * @return LoggerAppender |
|
37 | - */ |
|
38 | - public static function getAppenderFromPool($name, $class = '') { |
|
39 | - if(isset(self::$appenderPool[$name])) { |
|
40 | - return self::$appenderPool[$name]; |
|
41 | - } |
|
31 | + /** |
|
32 | + * |
|
33 | + * |
|
34 | + * @param string $name |
|
35 | + * @param string $class |
|
36 | + * @return LoggerAppender |
|
37 | + */ |
|
38 | + public static function getAppenderFromPool($name, $class = '') { |
|
39 | + if(isset(self::$appenderPool[$name])) { |
|
40 | + return self::$appenderPool[$name]; |
|
41 | + } |
|
42 | 42 | |
43 | - if(empty($class)) { |
|
44 | - return null; |
|
45 | - } |
|
43 | + if(empty($class)) { |
|
44 | + return null; |
|
45 | + } |
|
46 | 46 | |
47 | - $appender = LoggerReflectionUtils::createObject($class); |
|
48 | - $appender->setName($name); |
|
49 | - if($appender !== null) { |
|
50 | - self::$appenderPool[$name] = $appender; |
|
51 | - return self::$appenderPool[$name]; |
|
52 | - } |
|
53 | - return null; |
|
54 | - } |
|
47 | + $appender = LoggerReflectionUtils::createObject($class); |
|
48 | + $appender->setName($name); |
|
49 | + if($appender !== null) { |
|
50 | + self::$appenderPool[$name] = $appender; |
|
51 | + return self::$appenderPool[$name]; |
|
52 | + } |
|
53 | + return null; |
|
54 | + } |
|
55 | 55 | } |
@@ -100,122 +100,122 @@ |
||
100 | 100 | * @since 0.3 |
101 | 101 | */ |
102 | 102 | class LoggerNDC { |
103 | - const HT_SIZE = 7; |
|
104 | - /** |
|
105 | - * Clear any nested diagnostic information if any. This method is |
|
106 | - * useful in cases where the same thread can be potentially used |
|
107 | - * over and over in different unrelated contexts. |
|
108 | - * |
|
109 | - * <p>This method is equivalent to calling the {@link setMaxDepth()} |
|
110 | - * method with a zero <var>maxDepth</var> argument. |
|
111 | - * |
|
112 | - * @static |
|
113 | - */ |
|
114 | - public static function clear() { |
|
115 | - $GLOBALS['log4php.LoggerNDC.ht'] = array(); |
|
116 | - } |
|
103 | + const HT_SIZE = 7; |
|
104 | + /** |
|
105 | + * Clear any nested diagnostic information if any. This method is |
|
106 | + * useful in cases where the same thread can be potentially used |
|
107 | + * over and over in different unrelated contexts. |
|
108 | + * |
|
109 | + * <p>This method is equivalent to calling the {@link setMaxDepth()} |
|
110 | + * method with a zero <var>maxDepth</var> argument. |
|
111 | + * |
|
112 | + * @static |
|
113 | + */ |
|
114 | + public static function clear() { |
|
115 | + $GLOBALS['log4php.LoggerNDC.ht'] = array(); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Never use this method directly, use the {@link LoggerLoggingEvent::getNDC()} method instead. |
|
120 | - * @static |
|
121 | - * @return array |
|
122 | - */ |
|
123 | - public static function get() { |
|
124 | - if(!array_key_exists('log4php.LoggerNDC.ht', $GLOBALS)) { |
|
125 | - LoggerNDC::clear(); |
|
126 | - } |
|
127 | - return $GLOBALS['log4php.LoggerNDC.ht']; |
|
128 | - } |
|
118 | + /** |
|
119 | + * Never use this method directly, use the {@link LoggerLoggingEvent::getNDC()} method instead. |
|
120 | + * @static |
|
121 | + * @return array |
|
122 | + */ |
|
123 | + public static function get() { |
|
124 | + if(!array_key_exists('log4php.LoggerNDC.ht', $GLOBALS)) { |
|
125 | + LoggerNDC::clear(); |
|
126 | + } |
|
127 | + return $GLOBALS['log4php.LoggerNDC.ht']; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Get the current nesting depth of this diagnostic context. |
|
132 | - * |
|
133 | - * @see setMaxDepth() |
|
134 | - * @return integer |
|
135 | - * @static |
|
136 | - */ |
|
137 | - public static function getDepth() { |
|
138 | - return count($GLOBALS['log4php.LoggerNDC.ht']); |
|
139 | - } |
|
130 | + /** |
|
131 | + * Get the current nesting depth of this diagnostic context. |
|
132 | + * |
|
133 | + * @see setMaxDepth() |
|
134 | + * @return integer |
|
135 | + * @static |
|
136 | + */ |
|
137 | + public static function getDepth() { |
|
138 | + return count($GLOBALS['log4php.LoggerNDC.ht']); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Clients should call this method before leaving a diagnostic |
|
143 | - * context. |
|
144 | - * |
|
145 | - * <p>The returned value is the value that was pushed last. If no |
|
146 | - * context is available, then the empty string "" is returned.</p> |
|
147 | - * |
|
148 | - * @return string The innermost diagnostic context. |
|
149 | - * @static |
|
150 | - */ |
|
151 | - public static function pop() { |
|
152 | - if(count($GLOBALS['log4php.LoggerNDC.ht']) > 0) { |
|
153 | - return array_pop($GLOBALS['log4php.LoggerNDC.ht']); |
|
154 | - } else { |
|
155 | - return ''; |
|
156 | - } |
|
157 | - } |
|
141 | + /** |
|
142 | + * Clients should call this method before leaving a diagnostic |
|
143 | + * context. |
|
144 | + * |
|
145 | + * <p>The returned value is the value that was pushed last. If no |
|
146 | + * context is available, then the empty string "" is returned.</p> |
|
147 | + * |
|
148 | + * @return string The innermost diagnostic context. |
|
149 | + * @static |
|
150 | + */ |
|
151 | + public static function pop() { |
|
152 | + if(count($GLOBALS['log4php.LoggerNDC.ht']) > 0) { |
|
153 | + return array_pop($GLOBALS['log4php.LoggerNDC.ht']); |
|
154 | + } else { |
|
155 | + return ''; |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Looks at the last diagnostic context at the top of this NDC |
|
161 | - * without removing it. |
|
162 | - * |
|
163 | - * <p>The returned value is the value that was pushed last. If no |
|
164 | - * context is available, then the empty string "" is returned.</p> |
|
165 | - * @return string The innermost diagnostic context. |
|
166 | - * @static |
|
167 | - */ |
|
168 | - public static function peek(){ |
|
169 | - if(count($GLOBALS['log4php.LoggerNDC.ht']) > 0) { |
|
170 | - return end($GLOBALS['log4php.LoggerNDC.ht']); |
|
171 | - } else { |
|
172 | - return ''; |
|
173 | - } |
|
174 | - } |
|
159 | + /** |
|
160 | + * Looks at the last diagnostic context at the top of this NDC |
|
161 | + * without removing it. |
|
162 | + * |
|
163 | + * <p>The returned value is the value that was pushed last. If no |
|
164 | + * context is available, then the empty string "" is returned.</p> |
|
165 | + * @return string The innermost diagnostic context. |
|
166 | + * @static |
|
167 | + */ |
|
168 | + public static function peek(){ |
|
169 | + if(count($GLOBALS['log4php.LoggerNDC.ht']) > 0) { |
|
170 | + return end($GLOBALS['log4php.LoggerNDC.ht']); |
|
171 | + } else { |
|
172 | + return ''; |
|
173 | + } |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * Push new diagnostic context information for the current thread. |
|
178 | - * |
|
179 | - * <p>The contents of the <var>message</var> parameter is |
|
180 | - * determined solely by the client. |
|
181 | - * |
|
182 | - * @param string $message The new diagnostic context information. |
|
183 | - * @static |
|
184 | - */ |
|
185 | - public static function push($message) { |
|
186 | - array_push($GLOBALS['log4php.LoggerNDC.ht'], (string)$message); |
|
187 | - } |
|
176 | + /** |
|
177 | + * Push new diagnostic context information for the current thread. |
|
178 | + * |
|
179 | + * <p>The contents of the <var>message</var> parameter is |
|
180 | + * determined solely by the client. |
|
181 | + * |
|
182 | + * @param string $message The new diagnostic context information. |
|
183 | + * @static |
|
184 | + */ |
|
185 | + public static function push($message) { |
|
186 | + array_push($GLOBALS['log4php.LoggerNDC.ht'], (string)$message); |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * Remove the diagnostic context for this thread. |
|
191 | - * @static |
|
192 | - */ |
|
193 | - public static function remove() { |
|
194 | - LoggerNDC::clear(); |
|
195 | - } |
|
189 | + /** |
|
190 | + * Remove the diagnostic context for this thread. |
|
191 | + * @static |
|
192 | + */ |
|
193 | + public static function remove() { |
|
194 | + LoggerNDC::clear(); |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * Set maximum depth of this diagnostic context. If the current |
|
199 | - * depth is smaller or equal to <var>maxDepth</var>, then no |
|
200 | - * action is taken. |
|
201 | - * |
|
202 | - * <p>This method is a convenient alternative to multiple |
|
203 | - * {@link pop()} calls. Moreover, it is often the case that at |
|
204 | - * the end of complex call sequences, the depth of the NDC is |
|
205 | - * unpredictable. The {@link setMaxDepth()} method circumvents |
|
206 | - * this problem. |
|
207 | - * |
|
208 | - * @param integer $maxDepth |
|
209 | - * @see getDepth() |
|
210 | - * @static |
|
211 | - */ |
|
212 | - public static function setMaxDepth($maxDepth) { |
|
213 | - $maxDepth = (int)$maxDepth; |
|
214 | - if($maxDepth <= self::HT_SIZE) { |
|
215 | - if(LoggerNDC::getDepth() > $maxDepth) { |
|
216 | - $GLOBALS['log4php.LoggerNDC.ht'] = array_slice($GLOBALS['log4php.LoggerNDC.ht'], $maxDepth); |
|
217 | - } |
|
218 | - } |
|
219 | - } |
|
197 | + /** |
|
198 | + * Set maximum depth of this diagnostic context. If the current |
|
199 | + * depth is smaller or equal to <var>maxDepth</var>, then no |
|
200 | + * action is taken. |
|
201 | + * |
|
202 | + * <p>This method is a convenient alternative to multiple |
|
203 | + * {@link pop()} calls. Moreover, it is often the case that at |
|
204 | + * the end of complex call sequences, the depth of the NDC is |
|
205 | + * unpredictable. The {@link setMaxDepth()} method circumvents |
|
206 | + * this problem. |
|
207 | + * |
|
208 | + * @param integer $maxDepth |
|
209 | + * @see getDepth() |
|
210 | + * @static |
|
211 | + */ |
|
212 | + public static function setMaxDepth($maxDepth) { |
|
213 | + $maxDepth = (int)$maxDepth; |
|
214 | + if($maxDepth <= self::HT_SIZE) { |
|
215 | + if(LoggerNDC::getDepth() > $maxDepth) { |
|
216 | + $GLOBALS['log4php.LoggerNDC.ht'] = array_slice($GLOBALS['log4php.LoggerNDC.ht'], $maxDepth); |
|
217 | + } |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | 221 | } |
@@ -26,45 +26,45 @@ |
||
26 | 26 | * @see Logger |
27 | 27 | */ |
28 | 28 | class LoggerRoot extends Logger { |
29 | - /** |
|
30 | - * Constructor |
|
31 | - * |
|
32 | - * @param integer $level initial log level |
|
33 | - */ |
|
34 | - public function __construct($level = null) { |
|
35 | - parent::__construct('root'); |
|
29 | + /** |
|
30 | + * Constructor |
|
31 | + * |
|
32 | + * @param integer $level initial log level |
|
33 | + */ |
|
34 | + public function __construct($level = null) { |
|
35 | + parent::__construct('root'); |
|
36 | 36 | |
37 | - if($level == null) { |
|
38 | - $level = LoggerLevel::getLevelAll(); |
|
39 | - } |
|
40 | - $this->setLevel($level); |
|
41 | - } |
|
37 | + if($level == null) { |
|
38 | + $level = LoggerLevel::getLevelAll(); |
|
39 | + } |
|
40 | + $this->setLevel($level); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return LoggerLevel the level |
|
45 | - */ |
|
46 | - public function getChainedLevel() { |
|
47 | - return parent::getLevel(); |
|
48 | - } |
|
43 | + /** |
|
44 | + * @return LoggerLevel the level |
|
45 | + */ |
|
46 | + public function getChainedLevel() { |
|
47 | + return parent::getLevel(); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Setting a null value to the level of the root category may have catastrophic results. |
|
52 | - * @param LoggerLevel $level |
|
53 | - */ |
|
54 | - public function setLevel($level) { |
|
55 | - if($level != null) { |
|
56 | - parent::setLevel($level); |
|
57 | - } |
|
58 | - } |
|
50 | + /** |
|
51 | + * Setting a null value to the level of the root category may have catastrophic results. |
|
52 | + * @param LoggerLevel $level |
|
53 | + */ |
|
54 | + public function setLevel($level) { |
|
55 | + if($level != null) { |
|
56 | + parent::setLevel($level); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Always returns false. |
|
62 | - * Because LoggerRoot has no parents, it returns false. |
|
63 | - * @param Logger $parent |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function setParent(Logger $parent) { |
|
67 | - return false; |
|
68 | - } |
|
60 | + /** |
|
61 | + * Always returns false. |
|
62 | + * Because LoggerRoot has no parents, it returns false. |
|
63 | + * @param Logger $parent |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function setParent(Logger $parent) { |
|
67 | + return false; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |