mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 02:01:40 +09:00
Do not get backtrace if query logging is disabled
This commit is contained in:
parent
1e69d7404a
commit
fe54e83379
1 changed files with 21 additions and 12 deletions
|
|
@ -366,22 +366,29 @@ class DB
|
|||
$log['time'] = date('Y-m-d H:i:s');
|
||||
$log['backtrace'] = array();
|
||||
|
||||
$bt = version_compare(PHP_VERSION, '5.3.6', '>=') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
|
||||
|
||||
foreach($bt as $no => $call)
|
||||
if (config('debug.enabled') && config('debug.log_queries'))
|
||||
{
|
||||
if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray')
|
||||
$bt = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
|
||||
foreach($bt as $no => $call)
|
||||
{
|
||||
$call_no = $no;
|
||||
$call_no++;
|
||||
$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($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray')
|
||||
{
|
||||
$call_no = $no;
|
||||
$call_no++;
|
||||
$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();
|
||||
}
|
||||
|
||||
// leave error log if an error occured
|
||||
if($this->isError())
|
||||
|
|
@ -393,6 +400,8 @@ class DB
|
|||
else
|
||||
{
|
||||
$log['result'] = 'success';
|
||||
$log['errno'] = null;
|
||||
$log['errstr'] = null;
|
||||
}
|
||||
|
||||
$this->setQueryLog($log);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue