82 $this->_id = md5(microtime());
84 $this->_ident = $ident;
87 if (isset($conf[
'ip'])) {
88 $this->_ip = $conf[
'ip'];
90 if (isset($conf[
'proto'])) {
91 $this->_proto = $conf[
'proto'];
93 if (isset($conf[
'port'])) {
94 $this->_port = $conf[
'port'];
96 if (isset($conf[
'maxsize'])) {
97 $this->_maxsize = $conf[
'maxsize'];
99 if (isset($conf[
'timeout'])) {
100 $this->_timeout = $conf[
'timeout'];
102 $this->_proto = $this->_proto .
'://';
104 register_shutdown_function(array(&$this,
'_Log_daemon'));
124 if (!$this->_opened) {
125 $this->_opened = (bool)($this->_socket = @fsockopen(
126 $this->_proto . $this->_ip,
141 if ($this->_opened) {
142 $this->_opened =
false;
143 return fclose($this->_socket);
160 function log($message, $priority = null)
163 if ($priority === null) {
173 if (!$this->_opened && !$this->
open()) {
181 $facility_level = intval($this->_name) +
185 if (!empty($this->_ident)) {
186 $message = $this->_ident .
' ' . $message;
190 if (strlen($message) > $this->_maxsize) {
191 $message = substr($message, 0, ($this->_maxsize) - 10) .
' [...]';
195 fwrite($this->_socket,
'<' . $facility_level .
'>' . $message .
"\n");
197 $this->
_announce(array(
'priority' => $priority,
'message' => $message));
216 static $priorities = array(
228 if (!is_int($priority) || !in_array($priority, $priorities)) {
232 return $priorities[$priority];