From 08c09b7ca85af3b4c2b94c124e97a5f5c0fc0653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 12 Mar 2024 11:10:32 +0100 Subject: [PATCH] Add extra logs --- app/http.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/http.php b/app/http.php index 950ec3f05d..a2fdfca8f3 100644 --- a/app/http.php +++ b/app/http.php @@ -264,7 +264,14 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo $app = new App('UTC'); $l = new Log(); + + $fd = $swooleRequest->fd; + $fd_info = $http->getClientInfo($fd); + $packetTimeStart = $fd_info['last_time']; + $l->addExtra('packetTimeStart', \strval($packetTimeStart)); + App::setResource('log', fn() => $l); + App::setResource('swooleStartTime', fn() => \floatval($packetTimeStart)); $l->addExtra('GetPoolsStart', \strval(\microtime(true))); @@ -355,15 +362,15 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo }); App::shutdown() - ->inject('startTime') + ->inject('swooleStartTime') ->inject('log') - ->action(function(float $startTime, Log $log) { + ->action(function(float $swooleStartTime, Log $log) { $endTime = \microtime(true); $log->addExtra('veryLastShutdown', \strval(\microtime(true))); - $log->addExtra('duration', \strval($endTime - $startTime)); + $log->addExtra('durationSwoole', \strval($endTime - $swooleStartTime)); - if($endTime - $startTime < 10) { + if($endTime - $swooleStartTime > 10) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Our amazing timeout.'); } });