aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
blob: 16a3d2aec6ed5e6544bab4bd4a4421a0c2271763 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.pitchedapps.frost.utils

import android.util.Log
import ca.allanwang.kau.logging.TimberLogger
import com.crashlytics.android.Crashlytics
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") {

    /**
     * Helper function to separate private info
     */
    fun d(tag: String, personal: String?) {
        L.d(tag)
        L.i("-\t$personal")
    }
}

internal class CrashReportingTree : Timber.Tree() {
    override fun log(priority: Int, tag: String?, message: String?, t: Throwable?) {
        when (priority) {
            Log.VERBOSE, Log.INFO -> return
            Log.DEBUG -> if (!Prefs.verboseLogging) return
        }
        if (message != null)
            Crashlytics.log(priority, "Frost", message)
        if (t != null) Crashlytics.logException(t)
    }
}