mirror of
https://github.com/torrentpier/torrentpier-lts.git
synced 2025-02-28 15:10:54 +03:00
Updated
This commit is contained in:
parent
1dcfa83a4f
commit
67e625e992
@ -123,7 +123,7 @@ class sql_db
|
|||||||
*/
|
*/
|
||||||
function connect ()
|
function connect ()
|
||||||
{
|
{
|
||||||
$this->cur_query = 'connect';
|
$this->cur_query = "connect to: '{$this->cfg['dbhost']}'";
|
||||||
$this->debug('start');
|
$this->debug('start');
|
||||||
|
|
||||||
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
|
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
|
||||||
@ -402,30 +402,24 @@ class sql_db
|
|||||||
|
|
||||||
if ($mode == 'start')
|
if ($mode == 'start')
|
||||||
{
|
{
|
||||||
if (SQL_CALC_QUERY_TIME || DBG_LOG_TRACKER || SQL_LOG_SLOW_QUERIES)
|
$this->sql_starttime = utime();
|
||||||
{
|
$this->sql_last_time = 0;
|
||||||
$this->sql_starttime = utime();
|
|
||||||
$this->sql_last_time = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif ($mode == 'end')
|
elseif ($mode == 'end')
|
||||||
{
|
{
|
||||||
if (SQL_CALC_QUERY_TIME || DBG_LOG_TRACKER || SQL_LOG_SLOW_QUERIES)
|
$this->sql_last_time = utime() - $this->sql_starttime;
|
||||||
{
|
$this->sql_timetotal += $this->sql_last_time;
|
||||||
$this->sql_last_time = utime() - $this->sql_starttime;
|
$this->DBS['sql_timetotal'] += $this->sql_last_time;
|
||||||
$this->sql_timetotal += $this->sql_last_time;
|
|
||||||
$this->DBS['sql_timetotal'] += $this->sql_last_time;
|
|
||||||
|
|
||||||
if (SQL_LOG_SLOW_QUERIES && $this->sql_last_time > $this->slow_time)
|
if (SQL_LOG_SLOW_QUERIES && $this->sql_last_time > $this->slow_time)
|
||||||
{
|
{
|
||||||
$msg = date('m-d H:i:s') . LOG_SEPR;
|
$msg = date('m-d H:i:s') . LOG_SEPR;
|
||||||
$msg .= sprintf('%03d', round($this->sql_last_time));
|
$msg .= sprintf('%03d', round($this->sql_last_time));
|
||||||
$msg .= LOG_SEPR . sprintf('%.1f', sys('la'));
|
$msg .= LOG_SEPR . sprintf('%.1f', sys('la'));
|
||||||
$msg .= LOG_SEPR . str_compact($this->cur_query);
|
$msg .= LOG_SEPR . str_compact($this->cur_query);
|
||||||
$msg .= LOG_SEPR .' # '. $this->query_info();
|
$msg .= LOG_SEPR .' # '. $this->query_info();
|
||||||
$msg .= LOG_SEPR . $this->debug_find_source();
|
$msg .= LOG_SEPR . $this->debug_find_source();
|
||||||
bb_log($msg . LOG_LF, 'sql_slow_tr');
|
bb_log($msg . LOG_LF, 'sql_slow_tr');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ class sql_db
|
|||||||
*/
|
*/
|
||||||
function connect ()
|
function connect ()
|
||||||
{
|
{
|
||||||
$this->cur_query = ($this->dbg_enabled) ? ($this->cfg['persist'] ? 'p' : '') . "connect to: {$this->cfg['dbhost']}" : 'connect';
|
$this->cur_query = ($this->dbg_enabled) ? ($this->cfg['persist'] ? 'p' : '') . "connect to: '{$this->cfg['dbhost']}'" : 'connect';
|
||||||
$this->debug('start');
|
$this->debug('start');
|
||||||
|
|
||||||
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
|
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
|
||||||
@ -748,10 +748,7 @@ class sql_db
|
|||||||
|
|
||||||
if ($mode == 'start')
|
if ($mode == 'start')
|
||||||
{
|
{
|
||||||
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
|
$this->sql_starttime = utime();
|
||||||
{
|
|
||||||
$this->sql_starttime = utime();
|
|
||||||
}
|
|
||||||
if ($this->dbg_enabled)
|
if ($this->dbg_enabled)
|
||||||
{
|
{
|
||||||
$dbg['sql'] = preg_replace('#^(\s*)(/\*)(.*)(\*/)(\s*)#', '', $this->cur_query);
|
$dbg['sql'] = preg_replace('#^(\s*)(/\*)(.*)(\*/)(\s*)#', '', $this->cur_query);
|
||||||
@ -769,16 +766,13 @@ class sql_db
|
|||||||
}
|
}
|
||||||
else if ($mode == 'stop')
|
else if ($mode == 'stop')
|
||||||
{
|
{
|
||||||
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
|
$this->cur_query_time = utime() - $this->sql_starttime;
|
||||||
{
|
$this->sql_timetotal += $this->cur_query_time;
|
||||||
$this->cur_query_time = utime() - $this->sql_starttime;
|
$this->DBS['sql_timetotal'] += $this->cur_query_time;
|
||||||
$this->sql_timetotal += $this->cur_query_time;
|
|
||||||
$this->DBS['sql_timetotal'] += $this->cur_query_time;
|
|
||||||
|
|
||||||
if (SQL_LOG_SLOW_QUERIES && $this->cur_query_time > $this->slow_time)
|
if (SQL_LOG_SLOW_QUERIES && $this->cur_query_time > $this->slow_time)
|
||||||
{
|
{
|
||||||
$this->log_slow_query();
|
$this->log_slow_query();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($this->dbg_enabled)
|
if ($this->dbg_enabled)
|
||||||
{
|
{
|
||||||
|
@ -47,8 +47,8 @@ function get_sql_log_html ($db_obj, $log_name)
|
|||||||
{
|
{
|
||||||
$id = "sql_{$i}_". mt_rand();
|
$id = "sql_{$i}_". mt_rand();
|
||||||
$sql = short_query($dbg['sql'], true);
|
$sql = short_query($dbg['sql'], true);
|
||||||
$time = sprintf('%.4f', $dbg['time']);
|
$time = SQL_CALC_QUERY_TIME ? sprintf('%.4f', $dbg['time']) : '';
|
||||||
$perc = @sprintf('[%d%%]', round($dbg['time']*100/$db_obj->sql_timetotal));
|
$perc = SQL_CALC_QUERY_TIME ? @sprintf('[%d%%]', round($dbg['time']*100/$db_obj->sql_timetotal)) : '';
|
||||||
$info = !empty($dbg['info']) ? $dbg['info'] .' ['. $dbg['src'] .']' : $dbg['src'];
|
$info = !empty($dbg['info']) ? $dbg['info'] .' ['. $dbg['src'] .']' : $dbg['src'];
|
||||||
|
|
||||||
$log .= ''
|
$log .= ''
|
||||||
|
@ -38,7 +38,7 @@ if ($show_dbg_info)
|
|||||||
if (!empty($DBS))
|
if (!empty($DBS))
|
||||||
{
|
{
|
||||||
$sql_t = $DBS->sql_timetotal;
|
$sql_t = $DBS->sql_timetotal;
|
||||||
$sql_time_txt = ($sql_t) ? sprintf('%.3f '.$lang['SEC'].' (%d%%) · ', $sql_t, round($sql_t*100/$gen_time)) : '';
|
$sql_time_txt = ($sql_t && SQL_CALC_QUERY_TIME) ? sprintf('%.3f '.$lang['SEC'].' (%d%%) · ', $sql_t, round($sql_t*100/$gen_time)) : '';
|
||||||
$num_q = $DBS->num_queries;
|
$num_q = $DBS->num_queries;
|
||||||
$stat .= " | {$DBS->get_db_obj()->engine}: {$sql_time_txt}{$num_q} " . $lang['QUERIES'];
|
$stat .= " | {$DBS->get_db_obj()->engine}: {$sql_time_txt}{$num_q} " . $lang['QUERIES'];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user