aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt43
1 files changed, 29 insertions, 14 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 799d32f..d01859f 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
@file:Suppress("NOTHING_TO_INLINE")
package ca.allanwang.kau.logging
@@ -25,15 +40,15 @@ import android.util.Log
* for production builds
*/
open class KauLogger(
- /**
- * Tag to be used for each log
- */
- val tag: String,
- /**
- * Toggle to dictate whether a message should be logged
- */
- var shouldLog: (priority: Int) -> Boolean = { true }) {
-
+ /**
+ * Tag to be used for each log
+ */
+ val tag: String,
+ /**
+ * Toggle to dictate whether a message should be logged
+ */
+ var shouldLog: (priority: Int) -> Boolean = { true }
+) {
inline fun v(message: () -> Any?) = log(Log.VERBOSE, message)
@@ -96,11 +111,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"
- }, t)
+ logger.log(priority, {
+ val msg = message()?.toString()
+ if (msg == null) null
+ else "$tag: $msg"
+ }, t)
inline fun checkThread(id: Int) {
d {