aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-30 10:36:38 -0700
committerAllan Wang <me@allanwang.ca>2017-06-30 10:36:38 -0700
commit7267064d8a007e49bf05c3fc68b6338209a7c784 (patch)
tree676f2ab385b975f6ffd9b534fc8bcc11ac542635 /app/src/main/kotlin/com/pitchedapps/frost/utils
parenta42519030892ede729fc37ce6cbc93bb1d80989c (diff)
downloadfrost-7267064d8a007e49bf05c3fc68b6338209a7c784.tar.gz
frost-7267064d8a007e49bf05c3fc68b6338209a7c784.tar.bz2
frost-7267064d8a007e49bf05c3fc68b6338209a7c784.zip
Remove user info in debug logs
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt30
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt12
4 files changed, 38 insertions, 13 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 d9ce828e..dcf97265 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
@@ -8,14 +8,36 @@ import timber.log.Timber
/**
* 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 : TimberLogger("Frost")
+object L : TimberLogger("Frost") {
+
+ /**
+ * Helper function to separate private info
+ */
+ fun d(tag: String, personal: String?) {
+ L.d(tag)
+ if (personal != null) L.i(personal)
+ }
+}
internal class CrashReportingTree : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String?, t: Throwable?) {
- if (priority == Log.VERBOSE || priority == Log.DEBUG)
- return
- if (message != null) Crashlytics.log(priority, tag ?: "Frost", message)
+ when (priority) {
+ Log.VERBOSE, Log.INFO -> return
+ Log.DEBUG -> if (!Prefs.verboseLogging) return
+ }
+ if (message != null)
+ if (priority == Log.ERROR)
+ Crashlytics.log(Log.ERROR, "Frost", message)
+ else
+ Crashlytics.log(message)
if (t != null) Crashlytics.logException(t)
}
} \ No newline at end of file
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 f73350f2..287e0d7d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -91,5 +91,9 @@ object Prefs : KPref() {
var debugPro: Boolean by kpref("debug_pro", false)
- var searchBar :Boolean by kpref("search_bar", false)
+ var searchBar: Boolean by kpref("search_bar", false)
+
+ var verboseLogging: Boolean by kpref("verbose_logging", false)
+
+ var analytics: Boolean by kpref("analytics", true)
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index eb346140..6a99021d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -140,8 +140,7 @@ fun Context.scheduleNotifications(minutes: Long): Boolean {
}
fun frostAnswers(action: Answers.() -> Unit) {
- if (BuildConfig.DEBUG) return
- //TODO add opt out toggle
+ if (BuildConfig.DEBUG || !Prefs.analytics) return
Answers.getInstance().action()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt
index 5d0cdfa2..19b9b6f7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt
@@ -38,7 +38,7 @@ val IS_FROST_PRO: Boolean
get() = (BuildConfig.DEBUG && Prefs.debugPro) || (IAB.helper?.queryInventory()?.getSkuDetails(FROST_PRO) != null)
private fun Context.checkFromPlay(): Boolean {
- val isPlay = isFromGooglePlay
+ val isPlay = isFromGooglePlay || BuildConfig.DEBUG
if (!isPlay) materialDialogThemed {
title(R.string.uh_oh)
content(R.string.play_store_not_found)
@@ -63,7 +63,7 @@ fun Activity.openPlayPurchase(key: String, code: Int) {
L.e("IAB error: ${res.message}")
playStoreErrorDialog()
} else if (inv == null) {
- playStoreErrorDialog()
+ playStoreErrorDialog("Empty inventory")
} else {
val donation = inv.getSkuDetails(key)
if (donation != null) {
@@ -73,23 +73,23 @@ fun Activity.openPlayPurchase(key: String, code: Int) {
title(R.string.play_thank_you)
content(R.string.play_purchased_pro)
positiveText(R.string.kau_ok)
- } else playStoreErrorDialog()
+ } else playStoreErrorDialog("Result: ${result.message}")
frostAnswers {
logPurchase(PurchaseEvent()
.putItemId(key)
.putSuccess(result.isSuccess))
}
- } ?: playStoreErrorDialog()
+ } ?: playStoreErrorDialog("Launch Purchase Flow")
}
}
}
}
-private fun Context.playStoreErrorDialog() {
+private fun Context.playStoreErrorDialog(s: String = "Play Store Error") {
materialDialogThemed {
title(R.string.uh_oh)
content(R.string.play_store_billing_error)
positiveText(R.string.kau_ok)
}
- L.eThrow("Play Store Error")
+ L.e(Throwable(s), "Play Store Error")
} \ No newline at end of file