Skip to content

Instantly share code, notes, and snippets.

@Preciousomonze
Created March 21, 2023 14:37
Show Gist options
  • Save Preciousomonze/81c651d6b54aae878561f97674ae24e5 to your computer and use it in GitHub Desktop.
Save Preciousomonze/81c651d6b54aae878561f97674ae24e5 to your computer and use it in GitHub Desktop.
Snippet to log errors in wp functions, also valid for php
###
function pekky_var_error_log( $object=null ){
ob_start(); // start buffer capture
var_dump( $object ); // dump the values
$contents = ob_get_contents(); // put the buffer into a variable
ob_end_clean(); // end capture
error_log( $contents ); // log contents of the result of var_dump( $object )
}
############
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment