Debugging KittyORM

By design KittyORM able to log to logstream quite a lot of information in order to make it easier to implement KittyORM database in your application. Right now KittyORM has three types of logs: base log that logs main information such as errors and bootstrap messages, query log that logs queries sent to be executed by SQLite and dex utility log that logs what happens when KittyORM registry created from package.
Logging can be enabled via KITTY_DATABASE annotation. To do this, set up return values of isLoggingOn, isProductionOn, isKittyDexUtilLoggingEnabled and logTag of KITTY_DATABASE annotation that annotates your KittyORM implementation database class.

 1@KITTY_DATABASE(
 2        isLoggingOn = true, // Base logging flag
 3        isProductionOn = false, // Production logging flag
 4        isKittyDexUtilLoggingEnabled = false, // dex logging flag
 5        logTag = MigrationDBv3.LTAG, // log tag
 6        databaseName = "mig", // database name
 7        databaseVersion = 3, // database version
 8        ...
 9)
10
11public class MigrationDBv3 extends KittyDatabase {
12
13    public static final String LTAG = "MIGv3";
14    
15    ...
16}
Let’s take a closer look on base logging setting:

Also, you may make your query log more informative by overloading String toLogString() method of KittyModel.class implementation to log update and insert queries. Example:

 1@KITTY_TABLE
 2public class SimpleExampleModel extends KittyModel {
 3    public SimpleExampleModel() {
 4        super();
 5    }
 6
 7    @KITTY_COLUMN(
 8            isIPK = true,
 9            columnOrder = 0
10    )
11    public Long id;
12
13    @KITTY_COLUMN(columnOrder = 1)
14    public int randomInteger;
15
16    @KITTY_COLUMN(columnOrder = 2)
17    public String firstName;
18
19    @Override
20    public String toString() {
21        StringBuilder sb = new StringBuilder(64);
22        return sb.append("[ rowid = ")
23                    .append(getRowID())
24                    .append(" ; id = ")
25                    .append(id)
26                    .append(" ; randomInteger = ")
27                    .append(randomInteger)
28                    .append(" ; firstName = ")
29                    .append(firstName)
30                    .append(" ]")
31                    .toString();
32    }
33
34    public String toLogString() {
35        return toString();
36    }
37}