diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-30 18:58:23 -0700 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-30 18:58:23 -0700 |
commit | 0b39a143e538bc085094a67217afdf550e046066 (patch) | |
tree | 3a6e49bdc20ef26cbeeb09fd66c88858e612f2f5 | |
parent | ab40634f336a1f74305b9419859b2d9989459434 (diff) | |
parent | 63804f415328e76d1474fb5373134124c8caf029 (diff) | |
download | nextcloud-server-0b39a143e538bc085094a67217afdf550e046066.tar.gz nextcloud-server-0b39a143e538bc085094a67217afdf550e046066.zip |
Merge pull request #2620 from eMerzh/add_query_logs
Log DB Queries
-rw-r--r-- | config/config.sample.php | 4 | ||||
-rw-r--r-- | lib/db.php | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/config/config.sample.php b/config/config.sample.php index 995a02f6d94..95be5a9f012 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/db.php b/lib/db.php index 5a91421f7ab..f28ed24df41 100644 --- a/lib/db.php +++ b/lib/db.php @@ -367,7 +367,9 @@ class OC_DB { // Optimize the query $query = self::processQuery( $query ); - + if(OC_Config::getValue( "log_query", false)) { + OC_Log::write('core', 'DB prepare : '.$query, OC_Log::DEBUG); + } self::connect(); // return the result if(self::$backend==self::BACKEND_MDB2) { @@ -952,6 +954,10 @@ class PDOStatementWrapper{ * make execute return the result instead of a bool */ public function execute($input=array()) { + 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); + } $this->lastArguments = $input; if (count($input) > 0) { |