ソースを参照

判断 LARAVEL_START是否存在

visuddhinanda 3 年 前
コミット
9222075073
1 ファイル変更9 行追加6 行削除
  1. 9 6
      app/Http/Middleware/ApiLog.php

+ 9 - 6
app/Http/Middleware/ApiLog.php

@@ -18,12 +18,15 @@ class ApiLog
     public function handle(Request $request, Closure $next)
     public function handle(Request $request, Closure $next)
     {
     {
         $response = $next($request);
         $response = $next($request);
-        $api = [];
-        $api[] = date("h:i:sa",LARAVEL_START);
-        $api[] = round((microtime(true) - LARAVEL_START)*1000,2);
-        $api[] = $request->method();
-        $api[] = $request->path();
-        Storage::disk('local')->append("logs/api/".date("Y-m-d").".log",\implode(',',$api) );
+        if (defined('LARAVEL_START'))
+        {
+            $api = [];
+            $api[] = date("h:i:sa",LARAVEL_START);
+            $api[] = round((microtime(true) - LARAVEL_START)*1000,2);
+            $api[] = $request->method();
+            $api[] = $request->path();
+            Storage::disk('local')->append("logs/api/".date("Y-m-d").".log",\implode(',',$api) );
+        }
         return $response;
         return $response;
     }
     }
 }
 }