Last active
April 2, 2024 16:55
-
-
Save mwender/6e9c5f33335da941f5bc6d480ae54ef2 to your computer and use it in GitHub Desktop.
uber_log() - Enhanced logging. Add this to your project and use `tail -f /path/to/your/log.txt` for debugging.
This file contains 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 | |
/** | |
* Enhanced logging. | |
* | |
* @param string $message The log message | |
*/ | |
if( ! function_exists( 'uber_log' ) ){ | |
function uber_log( $message = null ){ | |
static $counter = 1; | |
$bt = debug_backtrace(); | |
$caller = array_shift( $bt ); | |
if( 1 == $counter ) | |
error_log( "\n\n" . str_repeat('-', 25 ) . ' STARTING DEBUG [' . date('h:i:sa', current_time('timestamp') ) . '] ' . str_repeat('-', 25 ) . "\n\n" ); | |
error_log( "\n" . $counter . '. ' . basename( $caller['file'] ) . '::' . $caller['line'] . "\n" . $message . "\n---\n" ); | |
$counter++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment