[rygel] core: Add compile time option for SQL debugging



commit 3f19d682aa4b3cab692854732f0363870bcbf530
Author: Jens Georg <mail jensge org>
Date:   Thu Oct 1 18:32:42 2009 +0200

    core: Add compile time option for SQL debugging

 configure.ac                  |   10 ++++++++++
 src/rygel/rygel-database.vala |    4 ++++
 2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0276dd6..6912cf1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,6 +53,13 @@ AC_SUBST(GLIB_GENMARSHAL)
 AC_ARG_ENABLE(vala,
 	[  --enable-vala          enable checks for vala],,
         enable_vala=no)
+AC_ARG_ENABLE(sql-debugging,
+              [  --enable-sql-debugging         enable SQL statement debugging],,
+                 enable_sql_debugging=no)
+
+if test x$enable_sql_debugging = xyes ; then
+    VALAFLAGS="$VALAFLAGS -D RYGEL_DEBUG_SQL"
+fi
 
 # Vala
 if test x$enable_vala = xyes ; then
@@ -234,6 +241,8 @@ ALL_LINGUAS=""
 AM_GLIB_GNU_GETTEXT
 AM_GLIB_DEFINE_LOCALEDIR([LOCALEDIR])
 
+AC_SUBST(VALAFLAGS)
+
 dnl Shave the output
 AM_SILENT_RULES([yes])
 
@@ -268,6 +277,7 @@ echo "
         uninstalled:            ${enable_uninstalled}
         maemo support:          ${enable_maemo}
         preferences ui          ${BUILD_UI}
+        SQL debugging:          ${enable_sql_debugging}
     Plugins:
         test:                   ${enable_test_plugin}
         tracker:                ${enable_tracker_plugin}
diff --git a/src/rygel/rygel-database.vala b/src/rygel/rygel-database.vala
index a53ece8..b1b9a66 100644
--- a/src/rygel/rygel-database.vala
+++ b/src/rygel/rygel-database.vala
@@ -53,7 +53,9 @@ internal class Rygel.Database : Object {
     public int exec (string        sql,
                      GLib.Value[]? values   = null,
                      RowCallback?  callback = null) throws DatabaseError {
+        #if RYGEL_DEBUG_SQL
         var t = new Timer ();
+        #endif
         int rc;
 
         if (values == null && callback == null) {
@@ -73,7 +75,9 @@ internal class Rygel.Database : Object {
         if (rc != Sqlite.DONE && rc != Sqlite.OK) {
             throw new DatabaseError.SQLITE_ERROR (db.errmsg ());
         }
+        #if RYGEL_DEBUG_SQL
         debug ("Query: %s, Time: %f", sql, t.elapsed ());
+        #endif
 
         return rc;
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]