aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/logging
diff options
context:
space:
mode:
authorAllan Wang <allanwang@google.com>2019-07-27 20:14:05 -0700
committerAllan Wang <allanwang@google.com>2019-07-27 20:14:05 -0700
commitd6f213563be35b183f81e20e95d925dbd65e4694 (patch)
tree7fd886e82f5e4797727e75858e7ca66d8ad181d4 /core/src/main/kotlin/ca/allanwang/kau/logging
parenta99e5885a8e67c2609b3c23dff069189c2e62dab (diff)
downloadkau-d6f213563be35b183f81e20e95d925dbd65e4694.tar.gz
kau-d6f213563be35b183f81e20e95d925dbd65e4694.tar.bz2
kau-d6f213563be35b183f81e20e95d925dbd65e4694.zip
Add braces to non assignment if statements
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/logging')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
index 4562b00..9410c4c 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
@@ -64,16 +64,18 @@ open class KauLogger(
}
inline fun log(priority: Int, message: () -> Any?, t: Throwable? = null) {
- if (shouldLog(priority))
+ if (shouldLog(priority)) {
logImpl(priority, message()?.toString(), t)
+ }
}
open fun logImpl(priority: Int, message: String?, t: Throwable?) {
val msg = message ?: "null"
- if (t != null)
+ if (t != null) {
Log.e(tag, msg, t)
- else
+ } else {
Log.println(priority, tag, msg)
+ }
}
/**
@@ -113,8 +115,11 @@ class KauLoggerExtension(val tag: String, val logger: KauLogger) {
inline fun log(priority: Int, message: () -> Any?, t: Throwable? = null) =
logger.log(priority, {
val msg = message()?.toString()
- if (msg == null) null
- else "$tag: $msg"
+ if (msg == null) {
+ null
+ } else {
+ "$tag: $msg"
+ }
}, t)
inline fun checkThread(id: Int) {