Simple Debug Log for WP
The snippet can be accessed without any authentication.
Authored by
Rolf Forst
debug_log (mixed $message) : bool
Utility function to write the debug log to the PHP's system logger file.
The constant WP_DEBUG must be true in order to write to the log file.
If the WP_DEBUG_LOG constant is also set to true, the log is saved to wp-content/debug.log
Use 'tail' to view the log in realtime in the terminal e.g. 'tail -f wp-content/debug.log'
debug-log.php 433 B
<?php
if (!function_exists('debug_log')) {
/**
* Write the debug log to the error log file.
* @param mixed $message Debug log.
* @return bool
*/
function debug_log($message) {
if (true === WP_DEBUG) {
if (is_scalar($message)) {
return error_log($message);
} else {
return error_log(print_r($message, true));
}
}
}
}
Please register or sign in to comment