Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120835937
RequestLogger.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
RequestLogger.php
View Options
<?php
namespace
App\Http\Middleware
;
use
Closure
;
class
RequestLogger
{
private
static
$start
;
public
function
handle
(
$request
,
Closure
$next
)
{
// FIXME: This is not really a request start, but we can't
// use LARAVEL_START constant when working with swoole
self
::
$start
=
microtime
(
true
);
return
$next
(
$request
);
}
public
function
terminate
(
$request
,
$response
)
{
if
(
\config
(
'app.debug'
))
{
if
(
empty
(
$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
));
}
}
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
));
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:23 PM (1 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18858706
Default Alt Text
RequestLogger.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline