From 63804f415328e76d1474fb5373134124c8caf029 Mon Sep 17 00:00:00 2001
From: Brice Maron <brice@bmaron.net>
Date: Sat, 30 Mar 2013 22:36:55 +0100
Subject: [PATCH] Change logQuery from define() to OC::Config

---
 config/config.sample.php | 4 ++++
 lib/config.php           | 3 ---
 lib/db.php               | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/config/config.sample.php b/config/config.sample.php
index 995a02f6d9..95be5a9f01 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -135,6 +135,10 @@ $CONFIG = array(
 /* Loglevel to start logging at. 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR (default is WARN) */
 "loglevel" => "",
 
+/* Append All database query and parameters to the log file.
+ (whatch out, this option can increase the size of your log file)*/
+"log_query" => false,
+
 /* Lifetime of the remember login cookie, default is 15 days */
 "remember_login_cookie_lifetime" => 60*60*24*15,
 
diff --git a/lib/config.php b/lib/config.php
index e04e96bc27..c94eb27815 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -159,9 +159,6 @@ class OC_Config{
 		if (defined('DEBUG') && DEBUG) {
 			$content .= "define('DEBUG',true);\n";
 		}
-		if (defined('LOG_QUERIES') && LOG_QUERIES) {
-			$content .= "define('LOG_QUERIES',true);\n";
-		}
 		$content .= "\$CONFIG = ";
 		$content .= var_export(self::$cache, true);
 		$content .= ";\n";
diff --git a/lib/db.php b/lib/db.php
index 6bf8c74fce..f28ed24df4 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -367,7 +367,7 @@ class OC_DB {
 
 		// Optimize the query
 		$query = self::processQuery( $query );
-		if(defined('LOG_QUERIES') && LOG_QUERIES === true) {
+		if(OC_Config::getValue( "log_query", false)) {
 			OC_Log::write('core', 'DB prepare : '.$query, OC_Log::DEBUG);
 		}
 		self::connect();
@@ -954,7 +954,7 @@ class PDOStatementWrapper{
 	 * make execute return the result instead of a bool
 	 */
 	public function execute($input=array()) {
-		if(defined('LOG_QUERIES') && LOG_QUERIES === true) {
+		if(OC_Config::getValue( "log_query", false)) {
 			$params_str = str_replace("\n"," ",var_export($input,true));
 			OC_Log::write('core', 'DB execute with arguments : '.$params_str, OC_Log::DEBUG);
 		}
-- 
GitLab