Skip to content

Commit

Permalink
Merge pull request #109 from infinum/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bojankoma authored Oct 21, 2022
2 parents 0255901 + ec4fc74 commit 10b9ac5
Show file tree
Hide file tree
Showing 35 changed files with 466 additions and 227 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

## Version 5.4.9

_2022-10-21_

* 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.

## Version 5.4.8

_2022-08-05_
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

**Groovy**
```groovy
debugImplementation "com.infinum.dbinspector:dbinspector:5.4.8"
releaseImplementation "com.infinum.dbinspector:dbinspector-no-op:5.4.8"
debugImplementation "com.infinum.dbinspector:dbinspector:5.4.9"
releaseImplementation "com.infinum.dbinspector:dbinspector-no-op:5.4.9"
```
**KotlinDSL**
```kotlin
debugImplementation("com.infinum.dbinspector:dbinspector:5.4.8")
releaseImplementation("com.infinum.dbinspector:dbinspector-no-op:5.4.8")
debugImplementation("com.infinum.dbinspector:dbinspector:5.4.9")
releaseImplementation("com.infinum.dbinspector:dbinspector-no-op:5.4.9")
```

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

Expand Down
8 changes: 4 additions & 4 deletions config.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ext {
def major = 5
def minor = 4
def patch = 8
def patch = 9

buildConfig = [
"minSdk" : 21,
"compileSdk": 32,
"targetSdk" : 32,
"buildTools": "32.0.0"
"compileSdk": 33,
"targetSdk" : 33,
"buildTools": "33.0.0"
]
releaseConfig = [
"group" : "com.infinum.dbinspector",
Expand Down
9 changes: 3 additions & 6 deletions dbinspector-no-op/proguard-rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
-keep public class com.infinum.dbinspector.DbInspector {
public protected *;
}
-keep public class com.infinum.dbinspector.data.models.memory.logger.Level {
-keep public class com.infinum.dbinspector.logger.Level {
public protected *;
}
-keep public class com.infinum.dbinspector.data.sources.memory.logger.Logger {
-keep public class com.infinum.dbinspector.logger.Logger {
public protected *;
}
-keep public class com.infinum.dbinspector.data.sources.memory.logger.EmptyLogger {
public protected *;
}
-keep public class com.infinum.dbinspector.data.sources.memory.logger.AndroidLogger {
-keep public class com.infinum.dbinspector.logger.AndroidLogger {
public protected *;
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@

package com.infinum.dbinspector

import com.infinum.dbinspector.data.sources.memory.logger.Logger
import com.infinum.dbinspector.logger.Logger

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

/**
* Show a list of databases.
*
* @param[logger] Optional logger implementation of [Logger][com.infinum.dbinspector.logger.Logger] interface.
*/
@JvmStatic
@JvmOverloads
public fun show(logger: Logger? = null): Unit = Unit
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.infinum.dbinspector.logger

import android.util.Log

/**
* Android specific logger implementation.
*
* @constructor Create an Android logger instance without any parameters.
*/
public class AndroidLogger : Logger {

internal companion object {
internal const val DEFAULT_LOG_TAG = "[DbInspector]"
}

private var logTag: String? = null

private var logLevel: Level = Level.INFO

override fun log(level: Level, message: String) {
if (canLog(level)) {
doLog(level, message)
}
}

override fun debug(message: String): Unit = doLog(Level.DEBUG, message)

override fun info(message: String): Unit = doLog(Level.INFO, message)

override fun error(message: String): Unit = doLog(Level.ERROR, message)

override fun setTag(tag: String) {
this.logTag = tag
}

override fun setLevel(level: Level) {
this.logLevel = level
}

private fun tag(): String = logTag ?: DEFAULT_LOG_TAG

private fun canLog(level: Level): Boolean = this.logLevel <= level

private fun doLog(level: Level, message: String) {
when (level) {
Level.DEBUG -> Log.d(tag(), message)
Level.INFO -> Log.i(tag(), message)
Level.ERROR -> Log.e(tag(), message)
else -> Log.e(tag(), message)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.infinum.dbinspector.logger

/**
* Level of a log message.
*/
public enum class Level {
/**
* Debug log level.
*/
DEBUG,

/**
* Info log level.
*/
INFO,

/**
* Error log level.
*/
ERROR,

/**
* No log level.
*/
NONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.infinum.dbinspector.logger

/**
* Logger interface exposing logging messages by level, or using direct overloads for debug, info and error messages.
* Implementation class also must support setting a tag and level.
*/
public interface Logger {

/**
* Log a message with an explicit level.
*
* @param level Level for any output in terminal.
* @param message Text output in terminal.
*/
public fun log(level: Level, message: String)

/**
* Log a debug message.
*
* @param message Text output in terminal.
*/
public fun debug(message: String)

/**
* Log an info message.
*
* @param message Text output in terminal.
*/
public fun info(message: String)

/**
* Log an error message.
*
* @param message Text output in terminal.
*/
public fun error(message: String)

/**
* Set a tag for a logger instance.
*
* @param tag Textual tag for any output in terminal.
*/
public fun setTag(tag: String)

/**
* Set a default level for a logger instance.
*
* @param level Level for any output in terminal.
*/
public fun setLevel(level: Level)
}
1 change: 0 additions & 1 deletion dbinspector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ protobuf {
}

kover {
disabled = false
coverageEngine.set(kotlinx.kover.api.CoverageEngine.INTELLIJ)
intellijEngineVersion.set(libs.versions.intellij.get())
jacocoEngineVersion.set(libs.versions.jacoco.get())
Expand Down
11 changes: 3 additions & 8 deletions dbinspector/proguard-rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
-keep public class com.infinum.dbinspector.DbInspector {
public protected *;
}
-keep public class com.infinum.dbinspector.data.models.memory.logger.Level {
-keep public class com.infinum.dbinspector.logger.Level {
public protected *;
}

-keep public class com.infinum.dbinspector.data.sources.memory.logger.Logger {
-keep public class com.infinum.dbinspector.logger.Logger {
public protected *;
}

-keep public class com.infinum.dbinspector.data.sources.memory.logger.EmptyLogger {
public protected *;
}
-keep public class com.infinum.dbinspector.data.sources.memory.logger.AndroidLogger {
-keep public class com.infinum.dbinspector.logger.AndroidLogger {
public protected *;
}
-keep class androidx.datastore.*.* {*;}
Expand Down
Loading

0 comments on commit 10b9ac5

Please sign in to comment.