Skip to content

Instantly share code, notes, and snippets.

@guillefd
Last active November 28, 2022 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillefd/eb9b99880d076dabb9090c4d3da12308 to your computer and use it in GitHub Desktop.
Save guillefd/eb9b99880d076dabb9090c4d3da12308 to your computer and use it in GitHub Desktop.
Moodle plugin development > Debug to File
<?php
function debug_log($var, $label = '') {
$labelcontent = $label ? $label.' ' : '';
$content = PHP_EOL
.date('Y-m-d H:i:s').' '
.$labelcontent
.print_r($var, TRUE)
.PHP_EOL;
error_log($content, 3, dirname(__FILE__).'/debug.log');
}
?>
@guillefd
Copy link
Author

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