core: Add compile time option for SQL debugging
authorJens Georg <mail@jensge.org>
Thu, 1 Oct 2009 16:32:42 +0000 (18:32 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sat, 24 Oct 2009 14:03:29 +0000 (17:03 +0300)
configure.ac
src/rygel/rygel-database.vala

index 0276dd6..6912cf1 100644 (file)
@@ -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}
index a53ece8..b1b9a66 100644 (file)
@@ -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;
     }