/** * 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->filehandle)) { $this->initFile(); } if ($this->filehandle !== false) { $map = array('%d' => date('Y-m-d H:i:s', $item->getDateTime()), '%m' => $item->getDescription(), '%p' => $this->prefix, '%s' => $item->getSeverityDescriptionString(), '%t' => $item->getDateTime(), '%r' => $item->getRequest(), '%f' => $item->getCallerFile(), '%l' => $item->getCallerLine()); if (strpos($this->format, '%b')) { $map['%b'] = 'Backtrace not yet supported'; } $str = strtr($this->format, $map) . PHP_EOL; @fwrite($this->filehandle, $str); } }
/** * 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 } }
/** * Short description of method doLog * * @access public * @author Joel Bout, <*****@*****.**> * @param Item item * @return mixed */ public function doLog(common_log_Item $item) { $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $success = @$doc->load($this->filename); if (!$success) { $doc->loadXML('<events></events>'); } $event_element = $doc->createElement("event"); $message = $doc->createElement("description"); $message->appendChild($doc->createCDATASection($item->getDescription())); $event_element->appendChild($message); $file = $doc->createElement("file"); $file->appendChild($doc->createCDATASection($item->getCallerFile())); $event_element->appendChild($file); $line = $doc->createElement("line"); $line->appendChild($doc->createCDATASection($item->getCallerLine())); $event_element->appendChild($line); $datetime = $doc->createElement("datetime"); $datetime->appendChild($doc->createCDATASection($item->getDateTime())); $event_element->appendChild($datetime); $severity = $doc->createElement("severity"); $severity->appendChild($doc->createCDATASection($item->getSeverity())); $event_element->appendChild($severity); $doc->documentElement->appendChild($event_element); @$doc->save($this->filename); }