From fb7ffa6b1b6621bb0d0bdf483812f0369e80a92c Mon Sep 17 00:00:00 2001 From: hawk__ Date: Thu, 7 Jan 2010 23:36:15 +0000 Subject: [PATCH] Added the possibility log only log errors git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@191303 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- pg4wp/db.php | 6 +++++- pg4wp/driver_pgsql.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pg4wp/db.php b/pg4wp/db.php index b028c83..3d01097 100644 --- a/pg4wp/db.php +++ b/pg4wp/db.php @@ -13,10 +13,14 @@ define( 'PG4WP_ROOT', dirname( __FILE__).'/plugins/pg4wp'); // Set this to 'true' and check that `pg4wp` is writable if you want debug logs to be written define( 'PG4WP_DEBUG', false); +// If you just want to log queries that generate errors, leave PG4WP_DEBUG to "false" +// and set this to true +define( 'PG4WP_LOG_ERRORS', false); + // Logs are put in the pg4wp directory define( 'PG4WP_LOG', PG4WP_ROOT.'/logs/'); // Check if the logs directory is needed and exists or create it if possible -if( PG4WP_DEBUG && +if( (PG4WP_DEBUG || PG4WP_LOG_ERRORS) && !file_exists( PG4WP_LOG) && is_writable(dirname( PG4WP_LOG))) mkdir( PG4WP_LOG); diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 6cdb02b..551272d 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -430,7 +430,7 @@ WHERE pg_class.relname='$table_name' AND pg_attribute.attnum>=1 AND NOT pg_attri error_log("$sql\n---------------------\n", 3, PG4WP_LOG.'pg4wp_unmodified.log'); } $GLOBALS['pg4wp_result'] = pg_query($sql); - if( PG4WP_DEBUG && $GLOBALS['pg4wp_result'] === false && $err = pg_last_error()) + if( (PG4WP_DEBUG || PG4WP_LOG_ERRORS) && $GLOBALS['pg4wp_result'] === false && $err = pg_last_error()) if( false === strpos($err, 'relation "'.$table_prefix.'options"')) error_log("Error running :\n$initial\n---- converted to ----\n$sql\n----\n$err\n---------------------\n", 3, PG4WP_LOG.'pg4wp_errors.log');