|
51 | 51 | * Usage |
52 | 52 | * |
53 | 53 | * require_once('syslog.class.php'); |
54 | | - * $syslog = new Net_Syslog($hostname = "", $appname = NET_SYSLOG_NILVALUE, $protocol = NET_SYSLOG_UDP, |
55 | | - * $_procid = NET_SYSLOG_NILVALUE); |
| 54 | + * $syslog = new Net_Syslog($hostname = "", $appname = NET_SYSLOG_NILVALUE, |
| 55 | + * $protocol = NET_SYSLOG_UDP, $_procid = NET_SYSLOG_NILVALUE); |
56 | 56 | * $syslog->logger($priority = LOG_LOCAL0 + LOG_NOTICE, $content = ""); |
57 | 57 | * or |
58 | | - * $syslog->logger542X($priority = 133, $content = "Default content", $msgid = NET_SYSLOG_NILVALUE, |
59 | | - * $structured_data = NET_SYSLOG_NILVALUE); |
| 58 | + * $syslog->logger542X($priority = 133, $content = "Default content", |
| 59 | + * $msgid = NET_SYSLOG_NILVALUE, $structured_data = NET_SYSLOG_NILVALUE); |
60 | 60 | * or |
61 | 61 | * $syslog->logger3164($priority = 133, $content = "Default content"); |
62 | 62 | * |
|
121 | 121 | * You should have received a copy of the GNU General Public License |
122 | 122 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
123 | 123 | * |
124 | | - * @category Networking |
125 | | - * @package Net_Syslog |
126 | | - * @author Laurent Vromman <laurent@vromman.org> |
127 | | - * @copyright 2013 Laurent Vromman |
128 | | - * @license http://www.gnu.org/copyleft/lesser.html LGPL License 3 |
129 | | - * @version SVN: $Id$ |
130 | | - * @link http://pear.php.net/package/Net_Syslog |
| 124 | + * @category Networking |
| 125 | + * @package Net_Syslog |
| 126 | + * @author Laurent Vromman <laurent@vromman.org> |
| 127 | + * @copyright 2013 Laurent Vromman |
| 128 | + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 3 |
| 129 | + * @link http://pear.php.net/package/Net_Syslog |
131 | 130 | */ |
132 | 131 |
|
133 | 132 |
|
|
218 | 217 | */ |
219 | 218 | class Net_Syslog |
220 | 219 | { |
221 | | - private $_hostname; // no embedded space, no domain name, only a-z A-Z 0-9 and other authorized characters |
| 220 | + /** |
| 221 | + * Sender hostname |
| 222 | + * No domain name, only a-z A-Z 0-9 and other authorized characters |
| 223 | + * |
| 224 | + * @acess private |
| 225 | + * @var string |
| 226 | + */ |
| 227 | + private $_hostname; |
222 | 228 | private $_server; // Syslog destination server |
223 | 229 | private $_port; // Standard syslog port is 514 or 6514 for RFC 5425 (TLS) |
224 | 230 | private $_protocol; // Allow to specify between udp, tcp, ssl and tls |
@@ -257,7 +263,10 @@ public function Syslog($hostname = "", $appname = NET_SYSLOG_NILVALUE, |
257 | 263 | $this->setHostname($hostname); |
258 | 264 |
|
259 | 265 | $this->setProtocol($protocol); |
260 | | - if (!in_array($this->_protocol, array(NET_SYSLOG_UDP, NET_SYSLOG_TCP, NET_SYSLOG_SSL, NET_SYSLOG_TLS))) { |
| 266 | + if (!in_array($this->_protocol, |
| 267 | + array(NET_SYSLOG_UDP, NET_SYSLOG_TCP, NET_SYSLOG_SSL, NET_SYSLOG_TLS) |
| 268 | + ) |
| 269 | + ) { |
261 | 270 | $this->_protocol = NET_SYSLOG_UDP; |
262 | 271 | } |
263 | 272 | // RFC5425 |
@@ -349,7 +358,13 @@ private function openSocket () |
349 | 358 | } |
350 | 359 | $sslContext = stream_context_create($contextOptions); |
351 | 360 |
|
352 | | - $this->_socket = stream_socket_client($this->_protocol."://".$this->_server.":".$this->_port, $errno, $errstr, ini_get("default_socket_timeout"), STREAM_CLIENT_CONNECT, $sslContext); |
| 361 | + $this->_socket = stream_socket_client( |
| 362 | + $this->_protocol."://".$this->_server.":".$this->_port, |
| 363 | + $errno, |
| 364 | + $errstr, |
| 365 | + ini_get("default_socket_timeout"), |
| 366 | + STREAM_CLIENT_CONNECT, |
| 367 | + $sslContext); |
353 | 368 |
|
354 | 369 | if (!$this->_socket) { |
355 | 370 | throw new Exception("ERROR: $errno - $errstr"); |
@@ -406,7 +421,9 @@ public function logger($priority = 133, $content = "Default content", |
406 | 421 | } |
407 | 422 | else { |
408 | 423 | $actualtime = time(); |
409 | | - $timestamp = date("M ", $actualtime).substr(date(" j", $actualtime), -2).date(" H:i:s", $actualtime); |
| 424 | + $timestamp = date("M ", $actualtime) |
| 425 | + .substr(date(" j", $actualtime), -2) |
| 426 | + .date(" H:i:s", $actualtime); |
410 | 427 | $syslog_version = ""; |
411 | 428 | } |
412 | 429 | $header = $pri.$syslog_version.$timestamp." ".$this->_hostname." "; |
|
0 commit comments