]> git.mjollnir.org Git - moodle.git/commitdiff
PERF logging - move handling to moodle_request_shutdown()
authormartinlanghoff <martinlanghoff>
Wed, 12 Sep 2007 02:57:26 +0000 (02:57 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 12 Sep 2007 02:57:26 +0000 (02:57 +0000)
By moving the performance profile logging to the very
end of PHP processing, we cover more pages, notably those
that don't end up with a footer or a redirect, like file
serving.

This should improve quality of our performance logs, and
help catch some piggies...

lib/moodlelib.php
lib/setup.php
lib/weblib.php

index 4ac46f0745b3c63f21f6701b20170853787ce888..2919c93336a0a7c83678ba03c32219c59ba979a9 100644 (file)
@@ -6791,6 +6791,12 @@ function moodle_request_shutdown() {
             @apache_child_terminate();
         }
     }
+    if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
+        if (defined('MDL_PERFTOLOG')) {
+            $perf = get_performance_info();
+            error_log("PERF: " . $perf['txt']);
+        }
+    }
 }
 
 /**
index 779cae82c3f5f4f273107c18903eda302341077e..bba85068bb3d32cad0c3b224c07ca07b4589b5af 100644 (file)
@@ -227,7 +227,7 @@ global $HTTPSPAGEREQUIRED;
 
 
 /// For now, only needed under apache (and probably unstable in other contexts)
-    if (function_exists('apache_child_terminate')) {
+    if (function_exists('register_shutdown_function')) {
         register_shutdown_function('moodle_request_shutdown');
     }
 
index fe86620497d8c1151cc1819d87ebe24094f6a442..219fb95817b4eeed6094149d3402dc31e95307bd 100644 (file)
@@ -2655,7 +2655,7 @@ function print_footer($course=NULL, $usercourse=NULL, $return=false) {
     $performanceinfo = '';
     if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
         $perf = get_performance_info();
-        if (defined('MDL_PERFTOLOG')) {
+        if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
             error_log("PERF: " . $perf['txt']);
         }
         if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
@@ -5469,7 +5469,7 @@ function redirect($url, $message='', $delay=-1) {
 
     $performanceinfo = '';
     if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
-        if (defined('MDL_PERFTOLOG')) {
+        if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) {
             $perf = get_performance_info();
             error_log("PERF: " . $perf['txt']);
         }