Selaa lähdekoodia

日志记录中文不转义

彭俊 6 vuotta sitten
vanhempi
commit
3ef9465cd7
2 muutettua tiedostoa jossa 24 lisäystä ja 23 poistoa
  1. 20 21
      app/Http/Controllers/Api/WriteSportsController.php
  2. 4 2
      app/Lib/Biz/Sport/Common.php

+ 20 - 21
app/Http/Controllers/Api/WriteSportsController.php

@@ -245,13 +245,13 @@ class WriteSportsController extends BaseController{
              //提交事务
              DB::commit();
              //写请求数据 日志记录
-             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
              return Response::success();
          } catch (\Exception $e) {
              //回滚事务
              DB::rollBack();
              //写请求数据 日志记录
-             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
              return $e->getMessage();
          }
     }
@@ -466,13 +466,13 @@ class WriteSportsController extends BaseController{
              //提交事务
              DB::commit();
              //写请求数据 日志记录
-             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
              return Response::success();
          } catch (\Exception $e) {
              //回滚事务
              DB::rollBack();
              //写请求数据 日志记录
-             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
              return $e->getMessage();
          }
 
@@ -678,13 +678,13 @@ class WriteSportsController extends BaseController{
              //提交事务
              DB::commit();
              //写请求数据 日志记录
-             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
              return Response::success();
          } catch (\Exception $e) {
              //回滚事务
              DB::rollBack();
              //写请求数据 日志记录
-             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+             if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
              return $e->getMessage();
          }
 
@@ -805,13 +805,13 @@ class WriteSportsController extends BaseController{
               //提交事务
               DB::commit();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
               return Response::success();
           } catch (\Exception $e) {
               //回滚事务
               DB::rollBack();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
               return $e->getMessage();
           }
 
@@ -926,13 +926,13 @@ class WriteSportsController extends BaseController{
               //提交事务
               DB::commit();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
               return Response::success();
           } catch (\Exception $e) {
               //回滚事务
               DB::rollBack();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
               return $e->getMessage();
           }
 
@@ -1085,13 +1085,13 @@ class WriteSportsController extends BaseController{
               //提交事务
               DB::commit();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
               return Response::success();
           } catch (\Exception $e) {
               //回滚事务
               DB::rollBack();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
               return $e->getMessage();
           }
     }
@@ -1236,13 +1236,13 @@ class WriteSportsController extends BaseController{
               //提交事务
               DB::commit();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
               return Response::success();
           } catch (\Exception $e) {
               //回滚事务
               DB::rollBack();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
               return $e->getMessage();
           }
     }
@@ -1391,13 +1391,13 @@ class WriteSportsController extends BaseController{
               //提交事务
               DB::commit();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
               return Response::success();
           } catch (\Exception $e) {
               //回滚事务
               DB::rollBack();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
               return $e->getMessage();
           }
     }
@@ -1458,13 +1458,13 @@ class WriteSportsController extends BaseController{
               //提交事务
               DB::commit();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
               return Response::success();
           } catch (\Exception $e) {
               //回滚事务
               DB::rollBack();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
               return $e->getMessage();
           }
     }
@@ -1793,13 +1793,13 @@ class WriteSportsController extends BaseController{
               //提交事务
               DB::commit();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],Response::success());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],Response::success());
               return Response::success();
           } catch (\Exception $e) {
               //回滚事务
               DB::rollBack();
               //写请求数据 日志记录
-              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$obt,$getData['title'],$e->getMessage());
+              if($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code,$getData,$getData['title'],$e->getMessage());
               return $e->getMessage();
           }
     }
@@ -2171,7 +2171,6 @@ class WriteSportsController extends BaseController{
      * json转数组
      */
     public function getAddData($data){
-
         $data = json_decode($data,true);
 
         return $data;

+ 4 - 2
app/Lib/Biz/Sport/Common.php

@@ -1181,10 +1181,12 @@ class Common {
     }
 
     //写入赛事数据日志文件
-    static function SET_SPORTS_RECORD($game_code,$obt,$title,$msg){
+    static function SET_SPORTS_RECORD($game_code,$getData=[],$title,$msg){
+        //中文不转义
+        $json_data = json_encode($getData,JSON_UNESCAPED_UNICODE);
         Log::getMonolog()->popHandler(); 
         Log::useFiles(storage_path('logs/set_sports_record/'.date('Y-m-d',time()).'/'.$game_code.'/'.$title.'.log'), 'info');
-        Log::info('--->msg:' . $msg . ';data:' . $obt);
+        Log::info('--->msg:' . $msg . ';data:' . $json_data);
     }
 }