|
By skodak:
MDL-20693 new NO_DEBUG_DISPLAY define
|
| 3140 |
* trigger_error() or error_log(). Using echo or print will break XHTML |
* trigger_error() or error_log(). Using echo or print will break XHTML |
| 3141 |
* JS and HTTP headers. |
* JS and HTTP headers. |
| 3142 |
* |
* |
| 3143 |
|
* It is also possible to define NO_DEBUG_DISPLAY which redirects the message to error_log. |
| 3144 |
* |
* |
|
* @global object |
|
| 3145 |
* @uses DEBUG_NORMAL |
* @uses DEBUG_NORMAL |
| 3146 |
* @param string $message a message to print |
* @param string $message a message to print |
| 3147 |
* @param int $level the level at which this debugging statement should show |
* @param int $level the level at which this debugging statement should show |
| 3164 |
$backtrace = debug_backtrace(); |
$backtrace = debug_backtrace(); |
| 3165 |
} |
} |
| 3166 |
$from = format_backtrace($backtrace, CLI_SCRIPT); |
$from = format_backtrace($backtrace, CLI_SCRIPT); |
| 3167 |
if ($CFG->debugdisplay || isset($UNITTEST->running)) { |
if (!empty($UNITTEST->running)) { |
| 3168 |
// When the unit tests are running, any call to trigger_error |
// When the unit tests are running, any call to trigger_error |
| 3169 |
// is intercepted by the test framework and reported as an exception. |
// is intercepted by the test framework and reported as an exception. |
| 3170 |
// Therefore, we cannot use trigger_error during unit tests. |
// Therefore, we cannot use trigger_error during unit tests. |
| 3171 |
// At the same time I do not think we should just discard those messages, |
// At the same time I do not think we should just discard those messages, |
| 3172 |
// so displaying them on-screen seems like the only option. (MDL-20398) |
// so displaying them on-screen seems like the only option. (MDL-20398) |
| 3173 |
|
echo '<div class="notifytiny">' . $message . $from . '</div>'; |
| 3174 |
|
|
| 3175 |
|
} else if (NO_DEBUG_DISPLAY) { |
| 3176 |
|
// script does not want any errors or debugging in output, |
| 3177 |
|
// we send the info to error log instead |
| 3178 |
|
error_log('Debugging: ' . $message . $from); |
| 3179 |
|
|
| 3180 |
|
} else if ($CFG->debugdisplay) { |
| 3181 |
if (!defined('DEBUGGING_PRINTED')) { |
if (!defined('DEBUGGING_PRINTED')) { |
| 3182 |
define('DEBUGGING_PRINTED', 1); // indicates we have printed something |
define('DEBUGGING_PRINTED', 1); // indicates we have printed something |
| 3183 |
} |
} |
| 3184 |
echo '<div class="notifytiny">' . $message . $from . '</div>'; |
echo '<div class="notifytiny">' . $message . $from . '</div>'; |
| 3185 |
|
|
| 3186 |
} else { |
} else { |
| 3187 |
trigger_error($message . $from, E_USER_NOTICE); |
trigger_error($message . $from, E_USER_NOTICE); |
| 3188 |
} |
} |
| 3191 |
} |
} |
| 3192 |
|
|
| 3193 |
/** |
/** |
|
* Disable debug messages from debugging(), while keeping PHP error reporting level as is. |
|
|
* |
|
|
* @global object |
|
|
*/ |
|
|
function disable_debugging() { |
|
|
global $CFG; |
|
|
$CFG->debug = $CFG->debug | 0x80000000; // switch the sign bit in integer number ;-) |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
| 3194 |
* Returns string to add a frame attribute, if required |
* Returns string to add a frame attribute, if required |
| 3195 |
* |
* |
| 3196 |
* @global object |
* @global object |