Skip to content

Commit

Permalink
dt log upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChasm committed Jan 3, 2023
1 parent 5bedef9 commit 6d411b0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions disciple-tools-network-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,28 @@ function dt_network_dashboard_no_disciple_tools_theme_found() {
* $an_object = new An_Object
* write_log($an_object);
*/
if ( !function_exists( 'dt_write_log' ) ) {
if ( ! function_exists( 'dt_write_log' ) ) {
/**
* A function to assist development only.
* This function allows you to post a string, array, or object to the WP_DEBUG log.
* It also prints elapsed time since the last call.
*
* @param $log
*/
function dt_write_log( $log ) {
if ( true === WP_DEBUG ) {
global $dt_write_log_microtime;
$now = microtime( true );
if ( $dt_write_log_microtime > 0 ) {
$elapsed_log = sprintf( '[elapsed:%5dms]', ( $now - $dt_write_log_microtime ) * 1000 );
} else {
$elapsed_log = '[elapsed:-------]';
}
$dt_write_log_microtime = $now;
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
error_log( $elapsed_log . ' ' . print_r( $log, true ) );
} else {
error_log( $log );
error_log( "$elapsed_log $log" );
}
}
}
Expand Down

0 comments on commit 6d411b0

Please sign in to comment.