Пример #1
0
 public function write($priority, $message)
 {
     $socket = fsockopen($this->host, $this->port, $errorCode, $errorMessage, $this->timeout);
     if ($socket === false) {
         LoggerPolicy::processIOError("Could not open socket to {$this->host}:{$this->port} – {$errorCode} {$errorMessage}. Closing appender.");
         return;
     }
     $write = fwrite($socket, $message);
     fclose($socket);
     if ($write === false) {
         LoggerPolicy::processIOError("Error writing to socket to {$this->host}:{$this->port}");
         return;
     }
 }
Пример #2
0
 /**
  * @return resource
  *
  * @throws LoggerIOException
  */
 private function getStream()
 {
     if ($this->stream && get_resource_type($this->stream) === 'Unknown') {
         fclose($this->stream);
         $this->stream = null;
     }
     if (!$this->stream) {
         $this->stream = @fopen($this->streamUrl, 'a');
         if (!$this->stream) {
             LoggerPolicy::processIOError("Error open {$this->streamUrl}");
             $this->stream = null;
         }
     }
     return $this->stream;
 }