aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt58
1 files changed, 16 insertions, 42 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
index b4bed5e1..a108745c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
@@ -1,6 +1,7 @@
package com.pitchedapps.frost.utils
import android.util.Log
+import ca.allanwang.kau.logging.KauLogger
import com.crashlytics.android.Crashlytics
import com.pitchedapps.frost.BuildConfig
@@ -9,61 +10,34 @@ import com.pitchedapps.frost.BuildConfig
* Created by Allan Wang on 2017-05-28.
*
* Logging for frost
- *
- * To ensure privacy, the following rules are set:
- *
- * Debug and Error logs must not reveal person info
- * Person info logs can be marked as info or verbose
*/
-object L {
-
- const val TAG = "Frost"
-
- inline fun v(message: () -> Any?) {
- if (BuildConfig.DEBUG)
- logImpl(Log.VERBOSE, message)
- }
-
- inline fun i(message: () -> Any?) {
- logImpl(Log.INFO, message)
+object L : KauLogger("Frost", {
+ when (it) {
+ Log.VERBOSE -> BuildConfig.DEBUG
+ Log.INFO, Log.ERROR -> true
+ else -> BuildConfig.DEBUG || Prefs.verboseLogging
}
+}) {
inline fun _i(message: () -> Any?) {
if (BuildConfig.DEBUG)
- logImpl(Log.INFO, message)
- }
-
- inline fun d(message: () -> Any?) {
- if (BuildConfig.DEBUG || Prefs.verboseLogging)
- logImpl(Log.DEBUG, message)
+ i(message)
}
inline fun _d(message: () -> Any?) {
if (BuildConfig.DEBUG)
- logImpl(Log.DEBUG, message)
- }
-
- inline fun e(t: Throwable? = null, message: () -> Any?) {
- logImpl(Log.ERROR, message, t)
- }
-
- fun eThrow(message: Any) {
- val msg = message.toString()
- logImpl(Log.ERROR, { msg }, Throwable(msg))
+ d(message)
}
- inline fun logImpl(priority: Int, message: () -> Any?, t: Throwable? = null) {
- val msg = message()?.toString()
- if (BuildConfig.DEBUG) {
- if (t != null)
- Log.e(TAG, msg, t)
- else
- Log.println(priority, TAG, msg ?: "null")
- } else {
- if (msg != null)
- Crashlytics.log(priority, TAG, msg)
+ override fun logImpl(priority: Int, message: String?, t: Throwable?) {
+ if (BuildConfig.DEBUG)
+ super.logImpl(priority, message, t)
+ else {
+ if (message != null)
+ Crashlytics.log(priority, tag, message)
if (t != null)
Crashlytics.logException(t)
}
}
+
} \ No newline at end of file