mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 11:11:39 +09:00
Completely disable Debug logging if it is not enabled for the current user
관리자 또는 특정 IP에서만 디버그 기능을 사용하도록 설정된 경우, 그 밖의 요청에서는 어떤 에러메시지, 쿼리, 트리거 소요시간 등의 기록도 디버그 클래스에 저장하지 않도록 변경합니다. 워닝이 많이 발생하는 PHP 8.0에서는 20~30%의 성능 개선 효과가 있습니다.
This commit is contained in:
parent
02122cb383
commit
1a204d8c52
11 changed files with 108 additions and 74 deletions
|
|
@ -175,7 +175,7 @@ class DisplayHandler extends Handler
|
|||
}
|
||||
|
||||
// Check if debugging is enabled for this request.
|
||||
if (!config('debug.enabled') || !Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
if (!Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,10 +273,12 @@ class HTMLDisplayHandler
|
|||
$oModuleController->replaceDefinedLangCode($output);
|
||||
|
||||
// remove template path comment tag
|
||||
/*
|
||||
if(!Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
$output = preg_replace('/\n<!-- Template (?:start|end) : .*? -->\r?\n/', "\n", $output);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -344,29 +344,32 @@ class FileHandler
|
|||
$log['status'] = $response ? $response->status_code : 0;
|
||||
$log['elapsed_time'] = $elapsed_time;
|
||||
|
||||
if (config('debug.enabled') && in_array('slow_remote_requests', config('debug.display_content')))
|
||||
if (Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
$bt = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
foreach($bt as $no => $call)
|
||||
if (in_array('slow_remote_requests', config('debug.display_content')))
|
||||
{
|
||||
if(strncasecmp($call['function'], 'getRemote', 9) === 0)
|
||||
$bt = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
foreach($bt as $no => $call)
|
||||
{
|
||||
$call_no = $no + 1;
|
||||
$log['called_file'] = $bt[$call_no]['file'];
|
||||
$log['called_line'] = $bt[$call_no]['line'];
|
||||
$call_no++;
|
||||
$log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function'];
|
||||
$log['backtrace'] = array_slice($bt, $call_no, 1);
|
||||
break;
|
||||
if(strncasecmp($call['function'], 'getRemote', 9) === 0)
|
||||
{
|
||||
$call_no = $no + 1;
|
||||
$log['called_file'] = $bt[$call_no]['file'];
|
||||
$log['called_line'] = $bt[$call_no]['line'];
|
||||
$call_no++;
|
||||
$log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function'];
|
||||
$log['backtrace'] = array_slice($bt, $call_no, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$log['called_file'] = $log['called_line'] = $log['called_method'] = null;
|
||||
$log['backtrace'] = array();
|
||||
}
|
||||
Rhymix\Framework\Debug::addRemoteRequest($log);
|
||||
}
|
||||
else
|
||||
{
|
||||
$log['called_file'] = $log['called_line'] = $log['called_method'] = null;
|
||||
$log['backtrace'] = array();
|
||||
}
|
||||
Rhymix\Framework\Debug::addRemoteRequest($log);
|
||||
|
||||
foreach($response->cookies as $cookie)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1229,12 +1229,15 @@ class ModuleHandler extends Handler
|
|||
{
|
||||
$trigger_target = $module . ($type === 'class' ? '' : $type) . '.' . $called_method;
|
||||
|
||||
Rhymix\Framework\Debug::addTrigger(array(
|
||||
'name' => $trigger_name . '.' . $called_position,
|
||||
'target' => $trigger_target,
|
||||
'target_plugin' => $module,
|
||||
'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time,
|
||||
));
|
||||
if (Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Rhymix\Framework\Debug::addTrigger(array(
|
||||
'name' => $trigger_name . '.' . $called_position,
|
||||
'target' => $trigger_target,
|
||||
'target_plugin' => $module,
|
||||
'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if($output instanceof BaseObject && !$output->toBool())
|
||||
|
|
@ -1280,12 +1283,15 @@ class ModuleHandler extends Handler
|
|||
$trigger_target = 'closure';
|
||||
}
|
||||
|
||||
Rhymix\Framework\Debug::addTrigger(array(
|
||||
'name' => $trigger_name . '.' . $called_position,
|
||||
'target' => $trigger_target,
|
||||
'target_plugin' => null,
|
||||
'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time,
|
||||
));
|
||||
if (Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Rhymix\Framework\Debug::addTrigger(array(
|
||||
'name' => $trigger_name . '.' . $called_position,
|
||||
'target' => $trigger_target,
|
||||
'target_plugin' => null,
|
||||
'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue