Skip to content

Instantly share code, notes, and snippets.

@mwender
Last active June 28, 2022 17:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Enhanced logging. Add this to your project and use `tail -f /path/to/your/log.txt` for debugging.
<?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