diff --git a/src/app/Http/Controllers/API/V4/HealthController.php b/src/app/Http/Controllers/API/V4/HealthController.php index dcceb5e1..39be8d11 100644 --- a/src/app/Http/Controllers/API/V4/HealthController.php +++ b/src/app/Http/Controllers/API/V4/HealthController.php @@ -1,55 +1,59 @@ json('success', 200); + $response = response()->json('success', 200); + $response->noLogging = true; + return $response; } /** * Readiness probe * * @return \Illuminate\Http\JsonResponse The response */ public function readiness() { - return response()->json('success', 200); + $response = response()->json('success', 200); + $response->noLogging = true; + return $response; } /** * Run a health status check * * @return \Illuminate\Http\JsonResponse The response */ public function status() { $code = \Artisan::call("status:health --check=DB --check=Redis"); if ($code != 0) { \Log::info("Healthcheck failed"); $result = [ 'status' => 'error', 'output' => \Artisan::output() ]; return response()->json($result, 500); } $result = [ 'status' => 'ok', 'output' => \Artisan::output() ]; return response()->json($result, 200); } } diff --git a/src/app/Http/Middleware/RequestLogger.php b/src/app/Http/Middleware/RequestLogger.php index e677e01d..8989cf86 100644 --- a/src/app/Http/Middleware/RequestLogger.php +++ b/src/app/Http/Middleware/RequestLogger.php @@ -1,38 +1,40 @@ fullUrl(); - $method = $request->getMethod(); - $mem = round(memory_get_peak_usage() / 1024 / 1024, 1); - $time = microtime(true) - self::$start; + if (!isset($response->noLogging)) { + $url = $request->fullUrl(); + $method = $request->getMethod(); + $mem = round(memory_get_peak_usage() / 1024 / 1024, 1); + $time = microtime(true) - self::$start; - \Log::debug(sprintf("C: %s %s [%sM]: %.4f sec.", $method, $url, $mem, $time)); + \Log::debug(sprintf("C: %s %s [%sM]: %.4f sec.", $method, $url, $mem, $time)); + } } else { $threshold = \config('logging.slow_log'); if ($threshold && ($time = microtime(true) - self::$start) > $threshold) { $url = $request->fullUrl(); $method = $request->getMethod(); \Log::warning(sprintf("[STATS] %s %s: %.4f sec.", $method, $url, $time)); } } } }