Beispiel #1
0
 public function log($message)
 {
     if (!$this->_logDb->log($message)) {
         $this->_logFile->log($message);
         $this->_logFile->log($this->_logDb->getLastError());
     }
 }
Beispiel #2
0
 /**
  * Записування кожного повідомлення в Базу Даних SQLite.
  *
  *     $writer->write($messages);
  *
  * @param   array   $messages
  * @return  void
  */
 public function write(array $messages)
 {
     try {
         $this->init_model()->insert($messages);
     } catch (Exception $e) {
         $file_log_writer = new Log_File(APPPATH . 'logs');
         $file_log_writer->write($messages);
         $message = [];
         $trace = $e->getTrace();
         $message[0] = ['time' => time(), 'level' => Log::ERROR, 'body' => 'Log_SQLiteWriter failed: ' . $e->getMessage(), 'trace' => $trace, 'file' => isset($trace[0]['file']) ? $trace[0]['file'] : NULL, 'line' => isset($trace[0]['line']) ? $trace[0]['line'] : NULL, 'class' => isset($trace[0]['class']) ? $trace[0]['class'] : NULL, 'function' => isset($trace[0]['function']) ? $trace[0]['function'] : NULL, 'additional' => ['exception' => $e]];
         $file_log_writer->write($message);
         $this->after_catch();
     }
 }