export() public method

Writes log messages to a file.
public export ( )
Exemplo n.º 1
0
 public function recode_log($msg)
 {
     $log = new FileTarget();
     $log->logFile = Yii::$app->getRuntimePath() . '/logs/wx_debug_' . date("Y-m-d") . '.log';
     $log->messages[] = [$msg, 1, 'application', microtime(true)];
     $log->export();
 }
Exemplo n.º 2
0
 public function recode($msg)
 {
     $time = microtime(true);
     $log = new FileTarget();
     $log->logFile = Yii::$app->getRuntimePath() . '/logs/err.log';
     $log->messages[] = [$msg . " [url:{$_SERVER['REQUEST_URI']}][post:" . http_build_query($_POST) . "]", 1, 'application', $time];
     $log->export();
 }
Exemplo n.º 3
0
 public function actionError()
 {
     $code = 404;
     $msg = CommonException::OBJECT_NOT_FOUND;
     $error = Yii::$app->errorHandler->exception;
     if ($error) {
         $code = $error->getCode();
         $msg = $error->getMessage();
         $file = $error->getFile();
         $line = $error->getLine();
         $time = microtime(true);
         $log = new FileTarget();
         $log->logFile = Yii::$app->getRuntimePath() . '/logs/err.log';
         $log->messages[] = [$msg . " [file: {$file}][line: {$line}][err code:{$code}.][url:{$_SERVER['REQUEST_URI']}][post:" . http_build_query($_POST) . "]", 1, 'application', $time];
         $log->export();
         $code = -1;
         $msg = "系统错误,请稍后重试";
     }
     return $this->goHome();
 }