Skip to content

Instantly share code, notes, and snippets.

@badfun
Last active November 1, 2016 20:41
Show Gist options
  • Select an option

  • Save badfun/666cd22bd11e7d9dd88a9002d1b9ba08 to your computer and use it in GitHub Desktop.

Select an option

Save badfun/666cd22bd11e7d9dd88a9002d1b9ba08 to your computer and use it in GitHub Desktop.

Revisions

  1. badfun renamed this gist Nov 1, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt → debug_logger.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    /**
    * Simple debug logger
    *
  2. badfun created this gist Nov 1, 2016.
    21 changes: 21 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    /**
    * 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 );
    }