@@ -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 | * Appends log events to mail using php function {@link PHP_MANUAL#mail}. |
@@ -47,85 +47,84 @@ discard block |
||
47 | 47 | * Tue Sep 8 21:51:04 2009,120 [5485] FATAL root - Some critical message! |
48 | 48 | * Tue Sep 8 21:51:06 2009,120 [5485] FATAL root - Some more critical message! |
49 | 49 | * </pre> |
50 | - |
|
51 | 50 | * @version $Revision: 883108 $ |
52 | 51 | * @package log4php |
53 | 52 | * @subpackage appenders |
54 | 53 | */ |
55 | 54 | class LoggerAppenderMail extends LoggerAppender { |
56 | 55 | |
57 | - /** @var string 'from' field */ |
|
58 | - private $from = null; |
|
56 | + /** @var string 'from' field */ |
|
57 | + private $from = null; |
|
59 | 58 | |
60 | - /** @var string 'subject' field */ |
|
61 | - private $subject = 'Log4php Report'; |
|
59 | + /** @var string 'subject' field */ |
|
60 | + private $subject = 'Log4php Report'; |
|
62 | 61 | |
63 | - /** @var string 'to' field */ |
|
64 | - private $to = null; |
|
62 | + /** @var string 'to' field */ |
|
63 | + private $to = null; |
|
65 | 64 | |
66 | - /** @var indiciates if this appender should run in dry mode */ |
|
67 | - private $dry = false; |
|
65 | + /** @var indiciates if this appender should run in dry mode */ |
|
66 | + private $dry = false; |
|
68 | 67 | |
69 | - /** @var string used to create mail body */ |
|
70 | - private $body = ''; |
|
68 | + /** @var string used to create mail body */ |
|
69 | + private $body = ''; |
|
71 | 70 | |
72 | - /** |
|
73 | - * Constructor. |
|
74 | - * |
|
75 | - * @param string $name appender name |
|
76 | - */ |
|
77 | - public function __construct($name = '') { |
|
78 | - parent::__construct($name); |
|
79 | - $this->requiresLayout = true; |
|
80 | - } |
|
71 | + /** |
|
72 | + * Constructor. |
|
73 | + * |
|
74 | + * @param string $name appender name |
|
75 | + */ |
|
76 | + public function __construct($name = '') { |
|
77 | + parent::__construct($name); |
|
78 | + $this->requiresLayout = true; |
|
79 | + } |
|
81 | 80 | |
82 | - public function __destruct() { |
|
83 | - $this->close(); |
|
84 | - } |
|
81 | + public function __destruct() { |
|
82 | + $this->close(); |
|
83 | + } |
|
85 | 84 | |
86 | - public function activateOptions() { |
|
87 | - $this->closed = false; |
|
88 | - } |
|
85 | + public function activateOptions() { |
|
86 | + $this->closed = false; |
|
87 | + } |
|
89 | 88 | |
90 | - public function close() { |
|
91 | - if($this->closed != true) { |
|
92 | - $from = $this->from; |
|
93 | - $to = $this->to; |
|
89 | + public function close() { |
|
90 | + if($this->closed != true) { |
|
91 | + $from = $this->from; |
|
92 | + $to = $this->to; |
|
94 | 93 | |
95 | - if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) { |
|
96 | - $subject = $this->subject; |
|
97 | - if(!$this->dry) { |
|
98 | - mail( |
|
99 | - $to, $subject, |
|
100 | - $this->layout->getHeader() . $this->body . $this->layout->getFooter(), |
|
101 | - "From: {$from}\r\n"); |
|
102 | - } else { |
|
103 | - echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body; |
|
104 | - } |
|
105 | - } |
|
106 | - $this->closed = true; |
|
107 | - } |
|
108 | - } |
|
94 | + if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) { |
|
95 | + $subject = $this->subject; |
|
96 | + if(!$this->dry) { |
|
97 | + mail( |
|
98 | + $to, $subject, |
|
99 | + $this->layout->getHeader() . $this->body . $this->layout->getFooter(), |
|
100 | + "From: {$from}\r\n"); |
|
101 | + } else { |
|
102 | + echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body; |
|
103 | + } |
|
104 | + } |
|
105 | + $this->closed = true; |
|
106 | + } |
|
107 | + } |
|
109 | 108 | |
110 | - public function setSubject($subject) { |
|
111 | - $this->subject = $subject; |
|
112 | - } |
|
109 | + public function setSubject($subject) { |
|
110 | + $this->subject = $subject; |
|
111 | + } |
|
113 | 112 | |
114 | - public function setTo($to) { |
|
115 | - $this->to = $to; |
|
116 | - } |
|
113 | + public function setTo($to) { |
|
114 | + $this->to = $to; |
|
115 | + } |
|
117 | 116 | |
118 | - public function setFrom($from) { |
|
119 | - $this->from = $from; |
|
120 | - } |
|
117 | + public function setFrom($from) { |
|
118 | + $this->from = $from; |
|
119 | + } |
|
121 | 120 | |
122 | - public function setDry($dry) { |
|
123 | - $this->dry = $dry; |
|
124 | - } |
|
121 | + public function setDry($dry) { |
|
122 | + $this->dry = $dry; |
|
123 | + } |
|
125 | 124 | |
126 | - public function append(LoggerLoggingEvent $event) { |
|
127 | - if($this->layout !== null) { |
|
128 | - $this->body .= $this->layout->format($event); |
|
129 | - } |
|
130 | - } |
|
125 | + public function append(LoggerLoggingEvent $event) { |
|
126 | + if($this->layout !== null) { |
|
127 | + $this->body .= $this->layout->format($event); |
|
128 | + } |
|
129 | + } |
|
131 | 130 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 is the global repository of user mappings |
@@ -55,62 +55,62 @@ discard block |
||
55 | 55 | * @package log4php |
56 | 56 | */ |
57 | 57 | class LoggerMDC { |
58 | - /** |
|
59 | - * Put a context value as identified with the key parameter into the current thread's |
|
60 | - * context map. |
|
61 | - * |
|
62 | - * <p>If the current thread does not have a context map it is |
|
63 | - * created as a side effect.</p> |
|
64 | - * |
|
65 | - * <p>Note that you cannot put more than {@link self::HT_SIZE} keys.</p> |
|
66 | - * |
|
67 | - * @param string $key the key |
|
68 | - * @param string $value the value |
|
69 | - * @static |
|
70 | - */ |
|
71 | - public static function put($key, $value) { |
|
72 | - $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value; |
|
73 | - } |
|
58 | + /** |
|
59 | + * Put a context value as identified with the key parameter into the current thread's |
|
60 | + * context map. |
|
61 | + * |
|
62 | + * <p>If the current thread does not have a context map it is |
|
63 | + * created as a side effect.</p> |
|
64 | + * |
|
65 | + * <p>Note that you cannot put more than {@link self::HT_SIZE} keys.</p> |
|
66 | + * |
|
67 | + * @param string $key the key |
|
68 | + * @param string $value the value |
|
69 | + * @static |
|
70 | + */ |
|
71 | + public static function put($key, $value) { |
|
72 | + $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Get the context identified by the key parameter. |
|
77 | - * |
|
78 | - * <p>You can use special key identifiers to map values in |
|
79 | - * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.' |
|
80 | - * followed by the var name you want to refer.</p> |
|
81 | - * |
|
82 | - * <p>This method has no side effects.</p> |
|
83 | - * |
|
84 | - * @param string $key |
|
85 | - * @return string |
|
86 | - * @static |
|
87 | - */ |
|
88 | - public static function get($key) { |
|
89 | - if(!empty($key)) { |
|
90 | - if(strpos($key, 'server.') === 0) { |
|
91 | - $varName = substr($key, 7); |
|
92 | - return @$_SERVER[$varName]; |
|
93 | - } else if(strpos($key, 'env.') === 0) { |
|
94 | - $varName = substr($key, 4); |
|
95 | - return @$_ENV[$varName]; |
|
96 | - } else if (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) { |
|
97 | - return $GLOBALS['log4php.LoggerMDC.ht'][$key]; |
|
98 | - } |
|
99 | - } |
|
100 | - return ''; |
|
101 | - } |
|
75 | + /** |
|
76 | + * Get the context identified by the key parameter. |
|
77 | + * |
|
78 | + * <p>You can use special key identifiers to map values in |
|
79 | + * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.' |
|
80 | + * followed by the var name you want to refer.</p> |
|
81 | + * |
|
82 | + * <p>This method has no side effects.</p> |
|
83 | + * |
|
84 | + * @param string $key |
|
85 | + * @return string |
|
86 | + * @static |
|
87 | + */ |
|
88 | + public static function get($key) { |
|
89 | + if(!empty($key)) { |
|
90 | + if(strpos($key, 'server.') === 0) { |
|
91 | + $varName = substr($key, 7); |
|
92 | + return @$_SERVER[$varName]; |
|
93 | + } else if(strpos($key, 'env.') === 0) { |
|
94 | + $varName = substr($key, 4); |
|
95 | + return @$_ENV[$varName]; |
|
96 | + } else if (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) { |
|
97 | + return $GLOBALS['log4php.LoggerMDC.ht'][$key]; |
|
98 | + } |
|
99 | + } |
|
100 | + return ''; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Remove the the context identified by the key parameter. |
|
105 | - * |
|
106 | - * It only affects user mappings. |
|
107 | - * |
|
108 | - * @param string $key |
|
109 | - * @return string |
|
110 | - * @static |
|
111 | - */ |
|
112 | - public static function remove($key) { |
|
113 | - unset($GLOBALS['log4php.LoggerMDC.ht'][$key]); |
|
114 | - } |
|
103 | + /** |
|
104 | + * Remove the the context identified by the key parameter. |
|
105 | + * |
|
106 | + * It only affects user mappings. |
|
107 | + * |
|
108 | + * @param string $key |
|
109 | + * @return string |
|
110 | + * @static |
|
111 | + */ |
|
112 | + public static function remove($key) { |
|
113 | + unset($GLOBALS['log4php.LoggerMDC.ht'][$key]); |
|
114 | + } |
|
115 | 115 | |
116 | 116 | } |
@@ -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 | } |