Permalink
Browse files

PERF logging - move handling to moodle_request_shutdown()

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...
  • Loading branch information...
1 parent 1ba840f commit 08c28a96f7216b8a03168e9d5c3eff40a229c525 martinlanghoff committed Sep 12, 2007
Showing with 9 additions and 3 deletions.
  1. +6 −0 lib/moodlelib.php
  2. +1 −1 lib/setup.php
  3. +2 −2 lib/weblib.php
View
@@ -6574,6 +6574,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']);
+ }
+ }
}
/**
View
@@ -225,7 +225,7 @@
/// 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');
}
View
@@ -2446,7 +2446,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) {
@@ -5153,7 +5153,7 @@ function redirect($url, $message='', $delay=-1, $adminroot = '') {
$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']);
}

0 comments on commit 08c28a9

Please sign in to comment.