Advertisement
borlabs

WordPress logging of errors and amount of queries

Jan 4th, 2019
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. // WordPress logging of errors and amount of queries
  2. ini_set('log_errors',TRUE);
  3. ini_set('display_errors', FALSE);
  4. ini_set('error_reporting', E_ALL);
  5. ini_set('error_log', dirname(__FILE__) . '/error-logs/php.log');
  6.  
  7. if (!file_exists(dirname(__FILE__) . '/error-logs') && is_writable(dirname(__FILE__))) {
  8.     mkdir(dirname(__FILE__) . '/error-logs');
  9. }
  10.  
  11. if (file_exists(dirname(__FILE__) . '/error-logs') && !file_exists(dirname(__FILE__) . '/error-logs/.htaccess')) {
  12.     file_put_contents(dirname(__FILE__) . '/error-logs/.htaccess', "AuthType Basic\nAuthName \"Restricted Access\"\nAuthUserFile .htnopasswd\nAuthGroupFile /dev/null\nRequire valid-user");
  13. }
  14.  
  15. define('SAVEQUERIES', true);
  16.  
  17. function debugShutdown()
  18. {
  19.     global $wpdb;
  20.  
  21.     error_log('DB Queries: '.count($wpdb->queries));
  22. }
  23.  
  24. register_shutdown_function('debugShutdown');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement