示例#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
     }
 }
示例#2
0
 /**
  * decides whenever the Item should be logged by doLog
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Item item
  * @return mixed
  * @see doLog
  */
 public function log(common_log_Item $item)
 {
     if ((1 << $item->getSeverity() & $this->mask) > 0 && (empty($this->tags) || count(array_intersect($item->getTags(), $this->tags))) > 0) {
         $this->doLog($item);
     }
 }