Changeset 576 for trunk

Show
Ignore:
Timestamp:
09/02/08 16:08:00 (3 months ago)
Author:
sidtheduck
Message:

+ Adding debug information for tracking SQL queries and benchmark timing function ( define('PLOGGER_DEBUG', '1') in plog-config.php to use)

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/plog-includes/plog-functions.php

    r574 r576  
    497497function run_query($query) { 
    498498        global $PLOGGER_DBH; 
     499 
     500        if (defined('PLOGGER_DEBUG') && PLOGGER_DEBUG == '1') { 
     501                $GLOBALS['query_count']++; 
     502                $GLOBALS['queries'][] = $query; 
     503        } 
    499504 
    500505        $result = @mysql_query($query, $PLOGGER_DBH); 
     
    14511456} 
    14521457 
     1458function plog_timer($time = 'start') { 
     1459        if (defined('PLOGGER_DEBUG') && PLOGGER_DEBUG == '1') { 
     1460                global $plog_start_time; 
     1461 
     1462                $mtime = microtime();  
     1463                $mtime = explode(' ', $mtime);  
     1464                $mtime = $mtime[1] + $mtime[0]; 
     1465                if ($time == 'end') { 
     1466                        return 'Page created in ' . ($mtime-$plog_start_time) . ' seconds'; 
     1467                } else { 
     1468                        return $mtime; 
     1469                } 
     1470        } 
     1471} 
     1472 
    14531473function plogger_init() { 
    14541474        global $config; 
     
    19291949                include($config['basedir'] . 'plog-content/themes/default/footer.php'); 
    19301950        } 
     1951        if (defined('PLOGGER_DEBUG') && PLOGGER_DEBUG == '1') { 
     1952                trace('Queries: '.$GLOBALS['query_count']); 
     1953                foreach ($GLOBALS['queries'] as $q) { 
     1954                        trace($q); 
     1955                } 
     1956                trace(plog_timer('end')); 
     1957        } 
    19311958} 
    19321959 
  • trunk/plog-load-config.php

    r575 r576  
    2929} 
    3030require_once(PLOGGER_DIR."plog-includes/plog-functions.php"); 
     31 
     32if (defined('PLOGGER_DEBUG') && PLOGGER_DEBUG == '1') { 
     33        $GLOBALS['query_count'] = 0; 
     34        $GLOBALS['queries'] = array(); 
     35        $plog_start_time = plog_timer(); 
     36} 
     37 
    3138connect_db(); 
    3239