]> git.ktnx.net Git - mobile-ledger.git/commitdiff
debug: print SQL params in DbOpRunner
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 1 Aug 2020 13:15:25 +0000 (16:15 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 1 Aug 2020 13:15:25 +0000 (16:15 +0300)
app/src/main/java/net/ktnx/mobileledger/async/DbOpRunner.java

index 2944efedeea536762b54e79e0ec8cd3fe1d2ca1d..67d8a0b1b868b6b7b8e6c4963c010c55ff834f8f 100644 (file)
@@ -20,6 +20,7 @@ package net.ktnx.mobileledger.async;
 import android.database.sqlite.SQLiteDatabase;
 
 import net.ktnx.mobileledger.App;
+import net.ktnx.mobileledger.BuildConfig;
 
 import java.util.concurrent.BlockingQueue;
 
@@ -38,7 +39,23 @@ class DbOpRunner extends Thread {
                 debug("opQrunner", "Got " + item.sql);
                 {
                     SQLiteDatabase db = App.getDatabase();
-                    debug("opQrunner", "Executing " + item.sql);
+                    if (BuildConfig.DEBUG) {
+                        StringBuilder b = new StringBuilder("Executing ");
+                        b.append(item.sql);
+                        if (item.params.length > 0) {
+                            boolean first = true;
+                            b.append(" [");
+                            for (Object p : item.params) {
+                                if (first)
+                                    first = false;
+                                else
+                                    b.append(", ");
+                                b.append(p.toString());
+                            }
+                            b.append("]");
+                        }
+                        debug("opQrunner", b.toString());
+                    }
                     db.execSQL(item.sql, item.params);
                 }
                 if (item.onReady != null)