Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Middleware/RequestLogger.php
Show All 20 Lines | class RequestLogger | ||||
{ | { | ||||
if (\App::environment('local')) { | if (\App::environment('local')) { | ||||
$url = $request->fullUrl(); | $url = $request->fullUrl(); | ||||
$method = $request->getMethod(); | $method = $request->getMethod(); | ||||
$mem = round(memory_get_peak_usage() / 1024 / 1024, 1); | $mem = round(memory_get_peak_usage() / 1024 / 1024, 1); | ||||
$time = microtime(true) - self::$start; | $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)); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |