Created
April 11, 2016 21:40
-
-
Save mintplugins/eb3819a5f9940decc4f9345f82c829db to your computer and use it in GitHub Desktop.
Write debugging text to a txt file
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
function pj_debug_to_txt_file( $debug_value, $filename, $append = true ){ | |
$upload_dir = wp_upload_dir(); | |
$filename = trailingslashit( $upload_dir['basedir'] ) . $filename . '.txt'; | |
if ( false === $append ) { | |
// Blank out the log file if needed | |
@file_put_contents( $filename, '' ); | |
@chmod( $filename, 0664 ); | |
} | |
if ( true === $append ) { | |
$log_file = fopen( $filename, 'a' ); | |
} | |
fwrite( $log_file, $debug_value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment