示例#1
0
文件: Base.php 项目: miaokuan/simrp
 public function progress($i, $max)
 {
     if ($i % 100 == 0) {
         Log::notice("progress: {$i}/{$max}");
     }
 }
示例#2
0
文件: Db.php 项目: miaokuan/wee
 /**
  * Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a MySQLi_Result object. For other successful queries mysqli_query() will return TRUE.
  */
 public function query($sql)
 {
     $this->lastSql = $sql;
     $begin = intval(microtime(true) * 1000000);
     $this->connect();
     $res = $this->mysqli->query($sql);
     #reconnect max times 3
     for ($i = 0; $i < 3; $i++) {
         if (in_array($this->mysqli->errno, $this->retryErrno)) {
             Log::warning("db reconnect. [errno:" . $this->mysqli->errno . " error:" . $this->mysqli->error . " sql:{$sql}]");
             usleep(100000);
             $this->connect(true);
             $res = $this->mysqli->query($sql);
         } else {
             break;
         }
     }
     if (false === $res) {
         Log::warning("db error. [errno:" . $this->mysqli->errno . " error:" . $this->mysqli->error . " sql: {$sql}]");
     }
     $this->lastCost = intval(microtime(true) * 1000000) - $begin;
     $this->totalCost += $this->lastCost;
     if ($this->profile) {
         Log::debug('query success. [cost: ' . $this->lastCost . 'us] [sql: ' . $sql . ']');
     }
     return $res;
 }
示例#3
0
文件: App.php 项目: miaokuan/wee
 public function __destruct()
 {
     if (!empty($this->pidfile) && file_exists($this->pidfile)) {
         if (!unlink($this->pidfile)) {
             Log::warning("Could not delete pid file " . $this->pidfile);
         }
     }
 }
示例#4
0
文件: Common.php 项目: miaokuan/wee
 public static function exceptionHandler($e)
 {
     $log = $e->getMessage() . "\n" . $e->getTraceAsString() . "\n";
     Log::Warning('Unhandled Exception' . $log);
     if (self::$config['exception']) {
         $code = $e->getCode();
         echo "Code:{$code}\n";
         $errfile = $e->getFile();
         echo "File:{$errfile}\n";
         $errline = $e->getLine();
         echo "Line:{$errline}\n";
         echo "Message:\n";
         echo $e->getMessage(), "\n";
         echo $e->getTraceAsString(), "\n";
         // var_dump($e->getTrace());
         echo "\n\n";
     } else {
         self::error($e);
     }
     // exit(1);
 }