Added query tracing in Tinebase_Db_Table
authorFlávio Gomes da Silva Lisboa <flavio.lisboa@serpro.gov.br>
Wed, 15 Oct 2014 16:46:11 +0000 (18:46 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Oct 2014 08:14:50 +0000 (10:14 +0200)
Change-Id: I2801049864f61c66a7f5203c060c2de2a7d23bfe
Reviewed-on: https://gerrit.tine20.org/tine20/2916
Tested-by: jenkins user
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Db/Table.php

index 5ceeda1..2f22213 100644 (file)
@@ -39,6 +39,16 @@ class Tinebase_Db_Table extends Zend_Db_Table_Abstract
             $order = $_order . ' ' . $_dir;
         }
         
+        // possibility to tracing queries
+        if (Tinebase_Core::isLogLevel(Zend_Log::TRACE) && $config = Tinebase_Core::getConfig()->logger) {
+            if ($config->traceQueryOrigins) {
+                $e = new Exception();
+                Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . "\n" .
+                    "BACKTRACE: \n" . $e->getTraceAsString() . "\n" .
+                    "SQL QUERY: \n" . $this->select()->assemble());
+            }
+        }
+
         $rowSet = parent::fetchAll($_where, $order, $_count, $_offset);
         
         return $rowSet;