-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from infinum/develop
Develop
- Loading branch information
Showing
42 changed files
with
335 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
-keep public class com.infinum.dbinspector.DbInspector { | ||
public protected *; | ||
} | ||
-keep public class com.infinum.dbinspector.data.models.memory.logger.Level { | ||
public protected *; | ||
} | ||
-keep public class com.infinum.dbinspector.data.sources.memory.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 { | ||
public protected *; | ||
} | ||
|
8 changes: 7 additions & 1 deletion
8
dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/DbInspector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
@file:Suppress("UNUSED_PARAMETER") | ||
|
||
package com.infinum.dbinspector | ||
|
||
import com.infinum.dbinspector.data.sources.memory.logger.EmptyLogger | ||
import com.infinum.dbinspector.data.sources.memory.logger.Logger | ||
|
||
@Suppress("UnusedPrivateMember") | ||
public object DbInspector { | ||
|
||
@JvmStatic | ||
public fun show(): Unit = Unit | ||
public fun show(logger: Logger = EmptyLogger()): Unit = Unit | ||
} |
8 changes: 8 additions & 0 deletions
8
dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/data/models/memory/logger/Level.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.infinum.dbinspector.data.models.memory.logger | ||
|
||
public enum class Level { | ||
DEBUG, | ||
INFO, | ||
ERROR, | ||
NONE | ||
} |
24 changes: 24 additions & 0 deletions
24
...no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/AndroidLogger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.infinum.dbinspector.data.sources.memory.logger | ||
|
||
import android.util.Log | ||
import com.infinum.dbinspector.data.models.memory.logger.Level | ||
|
||
public class AndroidLogger( | ||
level: Level = Level.INFO | ||
) : Logger(level) { | ||
|
||
override fun log(level: Level, message: String) { | ||
if (this.level <= level) { | ||
logOnLevel(message, level) | ||
} | ||
} | ||
|
||
private fun logOnLevel(message: String, level: Level) { | ||
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) | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...r-no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/EmptyLogger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.infinum.dbinspector.data.sources.memory.logger | ||
|
||
import com.infinum.dbinspector.data.models.memory.logger.Level | ||
|
||
internal class EmptyLogger : Logger(Level.NONE) { | ||
|
||
override fun log(level: Level, message: String) = Unit | ||
} |
39 changes: 39 additions & 0 deletions
39
...pector-no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/Logger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.infinum.dbinspector.data.sources.memory.logger | ||
|
||
import com.infinum.dbinspector.data.models.memory.logger.Level | ||
|
||
public abstract class Logger( | ||
public var level: Level = Level.INFO | ||
) { | ||
|
||
public companion object { | ||
internal const val DEFAULT_LOG_TAG = "[DbInspector]" | ||
} | ||
|
||
@Suppress("MemberVisibilityCanBePrivate") | ||
public var tag: String? = null | ||
|
||
public abstract fun log(level: Level, message: String) | ||
|
||
public fun debug(message: String) { | ||
doLog(Level.DEBUG, message) | ||
} | ||
|
||
public fun info(message: String) { | ||
doLog(Level.INFO, message) | ||
} | ||
|
||
public fun error(message: String) { | ||
doLog(Level.ERROR, message) | ||
} | ||
|
||
protected fun tag(): String = tag ?: DEFAULT_LOG_TAG | ||
|
||
private fun canLog(level: Level): Boolean = this.level <= level | ||
|
||
private fun doLog(level: Level, message: String) { | ||
if (canLog(level)) { | ||
log(level, message) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
dbinspector/src/main/kotlin/com/infinum/dbinspector/data/models/memory/logger/Level.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.infinum.dbinspector.data.models.memory.logger | ||
|
||
public enum class Level { | ||
DEBUG, | ||
INFO, | ||
ERROR, | ||
NONE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.