mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 11:11:39 +09:00
트리거 slowlog를 writeSlowlog() 함수를 이용하도록 변경
- 트리거 전체 수행 시간을 기록하는 기능 제거
This commit is contained in:
parent
cd41365ce8
commit
9b1633dcfa
1 changed files with 13 additions and 58 deletions
|
|
@ -1152,7 +1152,7 @@ class ModuleHandler extends Handler
|
||||||
$before_trigger_time = NULL;
|
$before_trigger_time = NULL;
|
||||||
if(__LOG_SLOW_TRIGGER__> 0)
|
if(__LOG_SLOW_TRIGGER__> 0)
|
||||||
{
|
{
|
||||||
$before_trigger_time = microtime(true);
|
$before_trigger_time = microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($triggers as $item)
|
foreach($triggers as $item)
|
||||||
|
|
@ -1160,12 +1160,6 @@ class ModuleHandler extends Handler
|
||||||
$module = $item->module;
|
$module = $item->module;
|
||||||
$type = $item->type;
|
$type = $item->type;
|
||||||
$called_method = $item->called_method;
|
$called_method = $item->called_method;
|
||||||
|
|
||||||
$before_each_trigger_time = NULL;
|
|
||||||
if(__LOG_SLOW_TRIGGER__> 0)
|
|
||||||
{
|
|
||||||
$before_each_trigger_time = microtime(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo why don't we call a normal class object ?
|
// todo why don't we call a normal class object ?
|
||||||
$oModule = getModule($module, $type);
|
$oModule = getModule($module, $type);
|
||||||
|
|
@ -1174,63 +1168,24 @@ class ModuleHandler extends Handler
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$before_each_trigger_time = microtime(true);
|
||||||
|
|
||||||
$output = $oModule->{$called_method}($obj);
|
$output = $oModule->{$called_method}($obj);
|
||||||
|
|
||||||
|
$after_each_trigger_time = microtime(true);
|
||||||
|
$elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time;
|
||||||
|
|
||||||
|
$slowlog = new stdClass;
|
||||||
|
$slowlog->caller = $trigger_name . '.' . $called_position;
|
||||||
|
$slowlog->called = $module . '.' . $called_method;
|
||||||
|
$slowlog->called_extension = $module;
|
||||||
|
if($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog);
|
||||||
|
|
||||||
if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
|
if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
|
||||||
{
|
{
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
unset($oModule);
|
unset($oModule);
|
||||||
|
|
||||||
//store after trigger call time
|
|
||||||
$after_each_trigger_time = NULL;
|
|
||||||
//init value to 0
|
|
||||||
$elapsed_time_trigger = 0;
|
|
||||||
|
|
||||||
if(__LOG_SLOW_TRIGGER__> 0)
|
|
||||||
{
|
|
||||||
$after_each_trigger_time = microtime(true);
|
|
||||||
$elapsed_time_trigger = ($after_each_trigger_time - $before_each_trigger_time) * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if __LOG_SLOW_TRIGGER__ is defined, check elapsed time and leave trigger time log
|
|
||||||
if(__LOG_SLOW_TRIGGER__> 0 && $elapsed_time_trigger > __LOG_SLOW_TRIGGER__)
|
|
||||||
{
|
|
||||||
$buff = '';
|
|
||||||
$log_file = _XE_PATH_ . 'files/_db_slow_trigger.php';
|
|
||||||
if(!file_exists($log_file))
|
|
||||||
{
|
|
||||||
$buff = '<?php exit(); ?' . '>' . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$buff .= sprintf("%s\t%s.%s.%s.%s(%s)\n\t%0.6f msec\n\n", date("Y-m-d H:i"), $item->trigger_name,$item->module,$item->called_method,$item->called_position,$item->type, $elapsed_time_trigger);
|
|
||||||
|
|
||||||
@file_put_contents($log_file, $buff, FILE_APPEND|LOCK_EX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//store after trigger call time
|
|
||||||
$after_trigger_time = NULL;
|
|
||||||
//init value to 0
|
|
||||||
$elapsed_time = 0;
|
|
||||||
if(__LOG_SLOW_TRIGGER__> 0)
|
|
||||||
{
|
|
||||||
$after_trigger_time = microtime(true);
|
|
||||||
$elapsed_time = ($after_trigger_time - $before_trigger_time) * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if __LOG_SLOW_TRIGGER__ is defined, check elapsed time and leave trigger time log
|
|
||||||
if(__LOG_SLOW_TRIGGER__> 0 && $elapsed_time > __LOG_SLOW_TRIGGER__)
|
|
||||||
{
|
|
||||||
$buff = '';
|
|
||||||
$log_file = _XE_PATH_ . 'files/_slow_trigger.php';
|
|
||||||
if(!file_exists($log_file))
|
|
||||||
{
|
|
||||||
$buff = '<?php exit(); ?' . '>' . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$buff .= sprintf("%s\t%s.totaltime\n\t%0.6f msec\n\n", date("Y-m-d H:i"), $trigger_name,$elapsed_time);
|
|
||||||
|
|
||||||
@file_put_contents($log_file, $buff, FILE_APPEND|LOCK_EX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Object();
|
return new Object();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue