aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-02-23 16:47:57 -0800
committerAllan Wang <me@allanwang.ca>2020-02-23 16:47:57 -0800
commit44de8239ec7d9e6b79194647829863d176123379 (patch)
treee480162a7efa66420fa1eebcada57d6eba769c44 /app/src/main
parent0dfc1b3e6542b9deca6c56236b46e71e4c6976f5 (diff)
downloadfrost-44de8239ec7d9e6b79194647829863d176123379.tar.gz
frost-44de8239ec7d9e6b79194647829863d176123379.tar.bz2
frost-44de8239ec7d9e6b79194647829863d176123379.zip
Remove pref component from logger
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt28
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt17
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt4
3 files changed, 26 insertions, 23 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index f7582f4f..e8cc2b35 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -19,6 +19,7 @@ package com.pitchedapps.frost
import android.app.Activity
import android.app.Application
import android.os.Bundle
+import android.util.Log
import ca.allanwang.kau.kpref.KPrefFactory
import ca.allanwang.kau.kpref.KPrefFactoryAndroid
import ca.allanwang.kau.logging.KL
@@ -34,7 +35,6 @@ import com.pitchedapps.frost.utils.FrostPglAdBlock
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.Showcase
-import java.util.Random
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.KoinComponent
@@ -42,6 +42,7 @@ import org.koin.core.context.startKoin
import org.koin.core.get
import org.koin.core.module.Module
import org.koin.dsl.module
+import java.util.Random
/**
* Created by Allan Wang on 2017-05-28.
@@ -57,13 +58,15 @@ class FrostApp : Application(), KoinComponent {
androidLogger()
}
androidContext(this@FrostApp)
- modules(listOf(
- FrostDatabase.module(),
- prefFactoryModule(),
- Prefs.module(),
- Showcase.module(),
- FbCookie.module()
- ))
+ modules(
+ listOf(
+ FrostDatabase.module(),
+ prefFactoryModule(),
+ Prefs.module(),
+ Showcase.module(),
+ FbCookie.module()
+ )
+ )
}
if (!buildIsLollipopAndUp) { // not supported
super.onCreate()
@@ -108,6 +111,13 @@ class FrostApp : Application(), KoinComponent {
prefs.deleteKeys("search_bar")
showcasePrefs.deleteKeys("shown_release", "experimental_by_default")
KL.shouldLog = { BuildConfig.DEBUG }
+ L.shouldLog = {
+ when (it) {
+ Log.VERBOSE -> BuildConfig.DEBUG
+ Log.INFO, Log.ERROR -> true
+ else -> BuildConfig.DEBUG || prefs.verboseLogging
+ }
+ }
prefs.verboseLogging = false
if (prefs.installDate == -1L) {
prefs.installDate = System.currentTimeMillis()
@@ -135,7 +145,7 @@ class FrostApp : Application(), KoinComponent {
enableExceptionHandler = prefs.analytics
}
Bugsnag.init(this, config)
- L.bugsnagInit = true
+ L.hasAnalytics = { prefs.analytics }
Bugsnag.setUserId(prefs.frostId)
Bugsnag.addToTab("Build", "Application", BuildConfig.APPLICATION_ID)
Bugsnag.addToTab("Build", "Version", BuildConfig.VERSION_NAME)
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 393df763..974047e8 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
@@ -16,28 +16,17 @@
*/
package com.pitchedapps.frost.utils
-import android.util.Log
import ca.allanwang.kau.logging.KauLogger
import ca.allanwang.kau.logging.KauLoggerExtension
import com.bugsnag.android.Bugsnag
import com.pitchedapps.frost.BuildConfig
-import org.koin.core.KoinComponent
-import org.koin.core.inject
/**
* Created by Allan Wang on 2017-05-28.
*
* Logging for frost
*/
-object L : KauLogger("Frost", {
- when (it) {
- Log.VERBOSE -> BuildConfig.DEBUG
- Log.INFO, Log.ERROR -> true
- else -> BuildConfig.DEBUG || L.prefs.verboseLogging
- }
-}), KoinComponent {
-
- private val prefs: Prefs by inject()
+object L : KauLogger("Frost") {
inline fun test(message: () -> Any?) {
_d {
@@ -63,7 +52,7 @@ object L : KauLogger("Frost", {
}
}
- var bugsnagInit = false
+ var hasAnalytics: () -> Boolean = { false }
override fun logImpl(priority: Int, message: String?, t: Throwable?) {
/*
@@ -71,7 +60,7 @@ object L : KauLogger("Frost", {
* bugsnagInit is changed per application and helps prevent crashes (if calling pre init)
* analytics is changed by the user, and may be toggled throughout the app
*/
- if (BuildConfig.DEBUG || !bugsnagInit || !prefs.analytics) {
+ if (BuildConfig.DEBUG || !hasAnalytics()) {
super.logImpl(priority, message, t)
} else {
if (message != null) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
index 3d394abe..8052533b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -158,6 +158,10 @@ class Prefs(factory: KPrefFactory) : KPref("${BuildConfig.APPLICATION_ID}.prefs"
var enablePip: Boolean by kpref("enable_pip", true)
+ /**
+ * Despite the naming, this toggle currently only enables debug logging.
+ * Verbose is never logged in release builds.
+ */
var verboseLogging: Boolean by kpref("verbose_logging", false)
var analytics: Boolean by kpref("analytics", false) {