diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-12 10:09:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-12 10:09:01 -0700 |
commit | 10617f02a95b162695ea068c0be6acceda74cf35 (patch) | |
tree | 06943d13034cbcf0e7bdd01960162e62952bb51c /core/src/main/kotlin/ca/allanwang/kau/logging | |
parent | 02e1dbc84425b0ac7f771c82f70444f742397452 (diff) | |
download | kau-10617f02a95b162695ea068c0be6acceda74cf35.tar.gz kau-10617f02a95b162695ea068c0be6acceda74cf35.tar.bz2 kau-10617f02a95b162695ea068c0be6acceda74cf35.zip |
Release 3.3.1 (#36)3.3.1
* Add open message joiner function
* Update text extraction
* Fix background tint
* Rename logger file
* Test codecov
* Remove coverage
* Enhancement/swipe (#35)
* Merge swipe onPostCreate with swipe onCreate
* Update samples and docs
* Add deprecated method to maintain compatibility
* Replace exception with illegal argument
* Check if parent exists before configurations in searchview
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/logging')
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt (renamed from core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt) | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt index 2fbecf5..14655f0 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt @@ -16,6 +16,7 @@ open class KauLogger(val tag: String) { open var enabled = true open var showPrivateText = false + open var messageJoiner: (msg: String, privMsg: String) -> String = { msg, privMsg -> "$msg: $privMsg" } /** * Filter pass-through to decide what we wish to log @@ -43,11 +44,14 @@ open class KauLogger(val tag: String) { = enabled && filter(priority) protected open fun logImpl(priority: Int, message: String?, privateMessage: String?, t: Throwable?) { - var text = message ?: "" - if (showPrivateText && privateMessage != null) - text += "\n-\t$privateMessage" - if (t != null) Log.e(tag, text, t) - else if (text.isNotBlank()) Log.println(priority, tag, text) + val text = if (showPrivateText) { + if (message == null) privateMessage + else if (privateMessage == null) message + else messageJoiner(message, privateMessage) + } else message + + if (t != null) Log.e(tag, text ?: "Error", t) + else if (!text.isNullOrBlank()) Log.println(priority, tag, text) } open fun v(text: String?, privateText: String? = null) = log(Log.VERBOSE, text, privateText) |