mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 09:32:15 +09:00
writeSlowlog() 함수 추가
- query, trigger 수행 시 slowlog를 기록하는 역할 수행 - 파일에 기록 또는 `XE.writeSlowlog` trigger를 동작시킴
This commit is contained in:
parent
fc03dd27b1
commit
cd41365ce8
1 changed files with 54 additions and 0 deletions
|
|
@ -838,6 +838,60 @@ function debugPrint($debug_output = NULL, $display_option = TRUE, $file = '_debu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $type query, trigger
|
||||||
|
* @param float $elapsed_time
|
||||||
|
* @param object $obj
|
||||||
|
*/
|
||||||
|
function writeSlowlog($type, $elapsed_time, $obj)
|
||||||
|
{
|
||||||
|
static $log_filename = array(
|
||||||
|
'query' => 'files/_slowlog_query.php',
|
||||||
|
'trigger' => 'files/_slowlog_trigger.php',
|
||||||
|
'addon' => 'files/_slowlog_addon.php'
|
||||||
|
);
|
||||||
|
$write_file = true;
|
||||||
|
|
||||||
|
$log_file = _XE_PATH_ . $log_filename[$type];
|
||||||
|
|
||||||
|
$buff = array();
|
||||||
|
$buff[] = '<?php exit(); ?>';
|
||||||
|
$buff[] = date('c');
|
||||||
|
|
||||||
|
if($type == 'trigger' && __LOG_SLOW_TRIGGER__ > 0 && $elapsed_time > __LOG_SLOW_TRIGGER__)
|
||||||
|
{
|
||||||
|
$buff[] = "\tCaller : " . $obj->caller;
|
||||||
|
$buff[] = "\tCalled : " . $obj->called;
|
||||||
|
}
|
||||||
|
else if($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__)
|
||||||
|
{
|
||||||
|
|
||||||
|
$buff[] = $obj->query;
|
||||||
|
$buff[] = "\tQuery ID : " . $obj->query_id;
|
||||||
|
$buff[] = "\tCaller : " . $obj->caller;
|
||||||
|
$buff[] = "\tConnection : " . $obj->connection;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$write_file = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($write_file)
|
||||||
|
{
|
||||||
|
$buff[] = sprintf("\t%0.6f sec", $elapsed_time);
|
||||||
|
$buff[] = PHP_EOL . PHP_EOL;
|
||||||
|
file_put_contents($log_file, implode(PHP_EOL, $buff), FILE_APPEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
$trigger_args = $obj;
|
||||||
|
$trigger_args->_log_type = $type;
|
||||||
|
$trigger_args->_elapsed_time = $elapsed_time;
|
||||||
|
if($type != 'query')
|
||||||
|
{
|
||||||
|
ModuleHandler::triggerCall('XE.writeSlowlog', 'after', $trigger_args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* microtime() return
|
* microtime() return
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue