Skip to content

Instantly share code, notes, and snippets.

@badfun
Last active November 1, 2016 20:41
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 badfun/666cd22bd11e7d9dd88a9002d1b9ba08 to your computer and use it in GitHub Desktop.
Save badfun/666cd22bd11e7d9dd88a9002d1b9ba08 to your computer and use it in GitHub Desktop.
Simple debug logger
<?php
/**
* Simple debug logger
*
* @param $data
*/
function ctrial_write_debug_log( $data ) {
$debug_file = 'debug.txt';
// if file already exists append data
if ( is_writeable( $debug_file ) ) {
$handle = fopen( $debug_file, 'a' );
$new_data = "\n" . implode( " ", $data );
fwrite( $handle, $new_data );
} else {
$handle = fopen( $debug_file, 'w' );
fwrite( $handle, implode( " ", $data ) );
}
fclose( $handle );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment