Skip to content

Commit ec4fc74

Browse files
author
Bojan
committed
* Update Kotlin to 1.7.20.
* Update dependencies to stable version. * Implement Android 13 compatibility and changes. * Refactor logger interface and classes. * Add KDoc on all public classes.
1 parent 8a84ab5 commit ec4fc74

File tree

29 files changed

+393
-209
lines changed

29 files changed

+393
-209
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ Changelog
33

44
## Version 5.4.9
55

6-
_2022-MM-DD_
6+
_2022-10-21_
77

8+
* Update Kotlin to 1.7.20.
9+
* Update dependencies to stable version.
810
* Implement Android 13 compatibility and changes.
11+
* Refactor logger interface and classes.
12+
* Add KDoc on all public classes.
913

1014
## Version 5.4.8
1115

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
_DbInspector_ provides a simple way to view the contents of the in-app database for debugging purposes.
99
There is no need to pull the database from a connected device.
10-
This library supports inspecting of the SQLite databases created by CouchBase Lite out of the box.
10+
This library also supports inspecting of the SQLite databases created by CouchBase Lite out of the box.
1111
With this library you can:
1212
* preview all application sandbox databases
1313
* import single or multiple databases at once
@@ -44,13 +44,13 @@ Then add the following dependencies in your app `build.gradle` or `build.gradle.
4444

4545
**Groovy**
4646
```groovy
47-
debugImplementation "com.infinum.dbinspector:dbinspector:5.4.8"
48-
releaseImplementation "com.infinum.dbinspector:dbinspector-no-op:5.4.8"
47+
debugImplementation "com.infinum.dbinspector:dbinspector:5.4.9"
48+
releaseImplementation "com.infinum.dbinspector:dbinspector-no-op:5.4.9"
4949
```
5050
**KotlinDSL**
5151
```kotlin
52-
debugImplementation("com.infinum.dbinspector:dbinspector:5.4.8")
53-
releaseImplementation("com.infinum.dbinspector:dbinspector-no-op:5.4.8")
52+
debugImplementation("com.infinum.dbinspector:dbinspector:5.4.9")
53+
releaseImplementation("com.infinum.dbinspector:dbinspector-no-op:5.4.9")
5454
```
5555

5656
### Usage
@@ -86,7 +86,7 @@ Further modification can be done according to rules of [manifest merging](https:
8686
_DbInspector_ has a build in editor scoped per database connection currently used.
8787
It offers autocomplete of SQLite3 keywords and functions, current table and column names.
8888
Built in editor also provides a history of executed statements, not matter if they were successful or not.
89-
Hisotry of statements is persisted between sessions and can be cleared on demand at any point.
89+
History of statements is persisted between sessions and can be cleared on demand at any point.
9090
Panes between editors' input and result are scalable and can be adjusted by dragging the splitter between them.
9191
Landscape mode is supported too for better result preview of large datasets.
9292

dbinspector-no-op/proguard-rules.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
-keep public class com.infinum.dbinspector.DbInspector {
33
public protected *;
44
}
5-
-keep public class com.infinum.dbinspector.data.models.memory.logger.Level {
5+
-keep public class com.infinum.dbinspector.logger.Level {
66
public protected *;
77
}
8-
-keep public class com.infinum.dbinspector.data.sources.memory.logger.Logger {
8+
-keep public class com.infinum.dbinspector.logger.Logger {
99
public protected *;
1010
}
11-
-keep public class com.infinum.dbinspector.data.sources.memory.logger.EmptyLogger {
12-
public protected *;
13-
}
14-
-keep public class com.infinum.dbinspector.data.sources.memory.logger.AndroidLogger {
11+
-keep public class com.infinum.dbinspector.logger.AndroidLogger {
1512
public protected *;
1613
}
1714

dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/DbInspector.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,32 @@
22

33
package com.infinum.dbinspector
44

5-
import com.infinum.dbinspector.data.sources.memory.logger.Logger
5+
import com.infinum.dbinspector.logger.Logger
66

7+
/**
8+
* _DbInspector_ provides a simple way to view the contents of the in-app database for debugging purposes.
9+
* There is no need to pull the database from a connected device.
10+
* This library also supports inspecting of the SQLite databases created by CouchBase Lite out of the box.
11+
* With this library you can:
12+
* - preview all application sandbox databases
13+
* - import single or multiple databases at once
14+
* - search, delete, rename, copy, share a database
15+
* - preview tables, views and triggers
16+
* - preview table or view pragma
17+
* - delete table contents
18+
* - drop view or trigger
19+
* - search table, view or trigger
20+
* - sort table, view or trigger per column
21+
* - execute any valid SQL command in editor per database connection
22+
*/
723
@Suppress("UnusedPrivateMember")
824
public object DbInspector {
925

26+
/**
27+
* Show a list of databases.
28+
*
29+
* @param[logger] Optional logger implementation of [Logger][com.infinum.dbinspector.logger.Logger] interface.
30+
*/
1031
@JvmStatic
1132
@JvmOverloads
1233
public fun show(logger: Logger? = null): Unit = Unit

dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/data/models/memory/logger/Level.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.

dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/AndroidLogger.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.

dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/EmptyLogger.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.

dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/Logger.kt

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.infinum.dbinspector.logger
2+
3+
import android.util.Log
4+
5+
/**
6+
* Android specific logger implementation.
7+
*
8+
* @constructor Create an Android logger instance without any parameters.
9+
*/
10+
public class AndroidLogger : Logger {
11+
12+
internal companion object {
13+
internal const val DEFAULT_LOG_TAG = "[DbInspector]"
14+
}
15+
16+
private var logTag: String? = null
17+
18+
private var logLevel: Level = Level.INFO
19+
20+
override fun log(level: Level, message: String) {
21+
if (canLog(level)) {
22+
doLog(level, message)
23+
}
24+
}
25+
26+
override fun debug(message: String): Unit = doLog(Level.DEBUG, message)
27+
28+
override fun info(message: String): Unit = doLog(Level.INFO, message)
29+
30+
override fun error(message: String): Unit = doLog(Level.ERROR, message)
31+
32+
override fun setTag(tag: String) {
33+
this.logTag = tag
34+
}
35+
36+
override fun setLevel(level: Level) {
37+
this.logLevel = level
38+
}
39+
40+
private fun tag(): String = logTag ?: DEFAULT_LOG_TAG
41+
42+
private fun canLog(level: Level): Boolean = this.logLevel <= level
43+
44+
private fun doLog(level: Level, message: String) {
45+
when (level) {
46+
Level.DEBUG -> Log.d(tag(), message)
47+
Level.INFO -> Log.i(tag(), message)
48+
Level.ERROR -> Log.e(tag(), message)
49+
else -> Log.e(tag(), message)
50+
}
51+
}
52+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.infinum.dbinspector.logger
2+
3+
/**
4+
* Level of a log message.
5+
*/
6+
public enum class Level {
7+
/**
8+
* Debug log level.
9+
*/
10+
DEBUG,
11+
12+
/**
13+
* Info log level.
14+
*/
15+
INFO,
16+
17+
/**
18+
* Error log level.
19+
*/
20+
ERROR,
21+
22+
/**
23+
* No log level.
24+
*/
25+
NONE
26+
}

0 commit comments

Comments
 (0)