示例#1
0
 /**
  * Short description of method doLog
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Item item
  * @return mixed
  */
 public function doLog(common_log_Item $item)
 {
     if (is_null($this->resource)) {
         $this->resource = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
         socket_set_nonblock($this->resource);
     }
     if ($this->resource !== false) {
         $message = json_encode(array('s' => $item->getSeverity(), 'd' => $item->getDescription(), 'p' => $this->prefix, 't' => $item->getTags(), 'f' => $item->getCallerFile(), 'l' => $item->getCallerLine(), 'b' => $item->getBacktrace()));
         @socket_sendto($this->resource, $message, strlen($message), 0, $this->host, $this->port);
         //ignore errors, socket might already be closed because php is shutting down
     }
 }