[rygel] db: Add possibility to dump the used SQL



commit 6f1f2aa82a65a50722066ac5b43dd3b3d0e2b32d
Author: Jens Georg <mail jensge org>
Date:   Tue Feb 16 19:41:45 2016 +0100

    db: Add possibility to dump the used SQL
    
    Signed-off-by: Jens Georg <mail jensge org>

 doc/man/rygel.conf.xml        |   16 +++++++++++++++-
 doc/man/rygel.xml             |    8 ++++++++
 src/librygel-db/database.vala |   13 +++++++++++++
 3 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/doc/man/rygel.conf.xml b/doc/man/rygel.conf.xml
index 1ed2f70..46ffe70 100644
--- a/doc/man/rygel.conf.xml
+++ b/doc/man/rygel.conf.xml
@@ -221,8 +221,22 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
     </variablelist>
   </refsect1>
   <refsect1>
+    <title>Database settings</title>
+    <para>The settings in the <code>[Database]</code>section are for the database support library. </para>
+    <para><variablelist>
+        <varlistentry>
+          <term>
+            <option>debug</option>
+          </term>
+          <listitem>
+            <para>Set to <option>true</option> to show the SQL statements used.</para>
+          </listitem>
+        </varlistentry>
+      </variablelist></para>
+  </refsect1>
+  <refsect1>
     <title>GStreamer Media Engine settings</title>
-    <para>The settings in the <code>[GstMediaEngine]</code> section are specific to the Gstreamer media 
engine, which is the default media engine. See the media-engine setting. These following options are 
available for the <ulink url="http://gstreamer.freedesktop.org";>GStreamer</ulink> media engine.</para>
+    <para>The settings in the <code>[GstMediaEngine]</code> section are specific to the GStreamer media 
engine, which is the default media engine. See the media-engine setting. These following options are 
available for the <ulink url="http://gstreamer.freedesktop.org";>GStreamer</ulink> media engine.</para>
     <variablelist>
       <varlistentry>
         <term>
diff --git a/doc/man/rygel.xml b/doc/man/rygel.xml
index 65c294a..ea98bf8 100644
--- a/doc/man/rygel.xml
+++ b/doc/man/rygel.xml
@@ -427,6 +427,14 @@ handling.</para>
           <para>Set the time-out for finding the plugins. Useful to increase when running inside 
valgrind.</para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term>
+          <envar>RYGEL_DATABASE_DEBUG</envar>
+        </term>
+        <listitem>
+          <para>If set to 1, the database library will print the used SQL statements.</para>
+        </listitem>
+      </varlistentry>
     </variablelist>
     <para>Also for every plugin you can set the following environment variables:</para>
     <para><variablelist>
diff --git a/src/librygel-db/database.vala b/src/librygel-db/database.vala
index fd6610b..936fe12 100644
--- a/src/librygel-db/database.vala
+++ b/src/librygel-db/database.vala
@@ -199,9 +199,22 @@ public class Rygel.Database.Database : Object, Initable {
                                   Sqlite.UTF8,
                                   Database.utf8_collate);
 
+        try {
+            var config = MetaConfig.get_default ();
+            if (config.get_bool ("Database", "Debug")) {
+                this.db.trace (this.on_trace);
+            }
+        } catch (Error error) {
+            debug ("Not setting up SQL tracing");
+        }
+
         return true;
     }
 
+    private void on_trace (string message) {
+        debug ("SQLITE: %s", message);
+    }
+
     /**
      * SQL query function.
      *


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