Last active
November 1, 2016 20:41
-
-
Save badfun/666cd22bd11e7d9dd88a9002d1b9ba08 to your computer and use it in GitHub Desktop.
Simple debug logger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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