Ejemplo n.º 1
0
 static function send_logged_queries()
 {
     set_error_handler(array('self', 'error_handler'));
     try {
         self::$query_line = null;
         if (!is_file(self::log_name('query'))) {
             restore_error_handler();
             return;
         }
         // Fixed: If the processing takes more than one second the self::log_name returns a different filename due to time() being used
         $query_log = self::log_name('query');
         $send_log = self::log_name('send');
         rename($query_log, $send_log);
         $fh_send = fopen($send_log, "r");
         if ($fh_send) {
             while (!feof($fh_send)) {
                 self::$query_line = fgets($fh_send);
                 if (self::$query_line == false) {
                     continue;
                 }
                 self::send_query(self::$query_line);
             }
             fclose($fh_send);
         }
         unlink($send_log);
         self::$query_line = null;
         restore_error_handler();
     } catch (Exception $e) {
         restore_error_handler();
         self::log_error($e->getMessage());
     }
 }
Ejemplo n.º 2
0
 static function error_handler ($errno, $errstr, $errfile, $errline)
 {
     self::log_error("[$errno] $errstr on line $errline in file $errfile");
     if (self::$query_line)
     {
         self::log_query(self::$query_line);
         self::$query_line = null;
     }
 }