Skip to content

Instantly share code, notes, and snippets.

Last active November 28, 2022 12:26
What would you like to do?
Moodle plugin development > Debug to File
function debug_log($var, $label = '') {
$labelcontent = $label ? $label.' ' : '';
$content = PHP_EOL
.date('Y-m-d H:i:s').' '
.print_r($var, TRUE)
error_log($content, 3, dirname(__FILE__).'/debug.log');
Copy link

This will create a debug file on the root of the plugin.
This function does not comply with Moodle coding guidelines, so delete when publishing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment