Created
September 19, 2016 23:04
-
-
Save yratof/d5edb37996572bdb4d959d156754c9cc to your computer and use it in GitHub Desktop.
query logging
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
<?php | |
/* SQL LOGGING FOR PAGES */ | |
add_action( 'shutdown', 'sql_logger' ); | |
function sql_logger() { | |
global $wpdb; | |
$log_file = fopen( ABSPATH.'/sql_log.txt', 'a' ); | |
fwrite( $log_file, "//////////////////////////////////////////\n\n" . date( 'F j, Y, g:i:s a' )."\n" ); | |
foreach ( $wpdb->queries as $q ) { | |
fwrite( $log_file, $q[0] . " - ( $q[1] s )" . "\n\n" ); | |
} | |
fclose( $log_file ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment