-
Notifications
You must be signed in to change notification settings - Fork 92
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 #109 from infinum/develop
Develop
- Loading branch information
Showing
35 changed files
with
466 additions
and
227 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
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: 0 additions & 8 deletions
8
dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/data/models/memory/logger/Level.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/AndroidLogger.kt
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...r-no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/EmptyLogger.kt
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
...pector-no-op/src/main/kotlin/com/infinum/dbinspector/data/sources/memory/logger/Logger.kt
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/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,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) | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/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,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 | ||
} |
51 changes: 51 additions & 0 deletions
51
dbinspector-no-op/src/main/kotlin/com/infinum/dbinspector/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,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) | ||
} |
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.