-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLoggingCountlyApplication.kt
More file actions
38 lines (31 loc) · 1.14 KB
/
LoggingCountlyApplication.kt
File metadata and controls
38 lines (31 loc) · 1.14 KB
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
package info.hannes.logging
import android.app.Application
import info.hannes.countly.Analytics
import info.hannes.timber.CountlyTree
import info.hannes.timber.DebugFormatTree
import timber.log.Timber
abstract class LoggingCountlyApplication(
private val countlyHost: String,
private val countlyKey: String,
private val debugBuildType: Boolean,
private val serverIgnoreToken: String? = null
) : Application() {
override fun onCreate() {
super.onCreate()
val oldHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { t, e ->
@Suppress("ControlFlowWithEmptyBody")
Timber.e(e.cause?.also { } ?: run { e })
oldHandler?.uncaughtException(t, e)
}
setupLogging(!debugBuildType)
}
@Suppress("MemberVisibilityCanBePrivate")
protected fun setupLogging(countlyLogging: Boolean) {
Timber.plant(DebugFormatTree())
if (countlyLogging) {
Analytics.initAnalytics(this, countlyLogging, countlyKey, countlyHost)
Timber.plant(CountlyTree(Analytics(), serverIgnoreToken))
}
}
}