Beispiel #1
0
 /**
 		Write specified text to log file
 			@param $_text string
 			@public
 	**/
 public function write($_text)
 {
     if (!self::ready()) {
         // Lock attempt failed
         trigger_error(self::TEXT_LogLock);
         return;
     }
     $_path = F3::$global['LOGS'];
     clearstatcache();
     if (filesize($_path . $this->filename) > F3::bytes(self::LOG_Size)) {
         // Perform log rotation sequence
         if (file_exists($_path . $this->filename . '.1')) {
             copy($_path . $this->filename . '.1', $_path . $this->filename . '.2');
         }
         copy($_path . $this->filename, $_path . $this->filename . '.1');
         ftruncate($this->handle, 0);
     }
     // Prepend text with timestamp, source IP, file name and
     // line number for tracking origin
     $_trace = debug_backtrace(FALSE);
     fwrite($this->handle, date('r') . ' [' . $_SERVER['REMOTE_ADDR'] . '] ' . F3::fixSlashes($_trace[0]['file']) . ':' . $_trace[0]['line'] . ' ' . preg_replace('/\\s+/', ' ', $_text) . "\n");
     flock($this->handle, LOCK_UN);
 }