summaryrefslogtreecommitdiffstats
path: root/lib/private/DB
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-10-28 11:29:38 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-11-02 20:30:36 +0100
commitcd13f50a3f1fbcae757672b4a471d8fbcf959b08 (patch)
treeb5761b34b9e1e7618e04a19c71549c20c1043ebd /lib/private/DB
parent2cd92d0abbeffd1817c87522f9b633b14e60181a (diff)
downloadnextcloud-server-cd13f50a3f1fbcae757672b4a471d8fbcf959b08.tar.gz
nextcloud-server-cd13f50a3f1fbcae757672b4a471d8fbcf959b08.zip
Log the queries of the QueryBuilder as well
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/DB')
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index eac77dd98fd..aefc84f9c9a 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -139,6 +139,29 @@ class QueryBuilder implements IQueryBuilder {
* @return \Doctrine\DBAL\Driver\Statement|int
*/
public function execute() {
+ if (\OC::$server->getConfig()->getSystemValue('log_query', false)) {
+ $params = [];
+ foreach ($this->getParameters() as $placeholder => $value) {
+ if (is_array($value)) {
+ $params[] = $placeholder . ' => (\'' . implode('\', \'', $value) . '\')';
+ } else {
+ $params[] = $placeholder . ' => \'' . $value . '\'';
+ }
+ }
+ if (empty($params)) {
+ \OC::$server->getLogger()->debug('DB QueryBuilder: \'{query}\'', [
+ 'query' => $this->getSQL(),
+ 'app' => 'core',
+ ]);
+ } else {
+ \OC::$server->getLogger()->debug('DB QueryBuilder: \'{query}\' with parameters: {params}', [
+ 'query' => $this->getSQL(),
+ 'params' => implode(', ', $params),
+ 'app' => 'core',
+ ]);
+ }
+ }
+
return $this->queryBuilder->execute();
}