Timber + Logger Integration
Video Instructions: https://youtu.be/zoS_i8VshCk
class App : Application() {
override fun onCreate() {
super.onCreate()
val formatStrategy: FormatStrategy = PrettyFormatStrategy.newBuilder()
.showThreadInfo(true) // (Optional) Whether to show thread info or not. Default true
.methodCount(1) // (Optional) How many method line to show. Default 2
.methodOffset(5) // Set methodOffset to 5 in order to hide internal method calls
.tag("") // To replace the default PRETTY_LOGGER tag with a dash (-).
.build()
Logger.addLogAdapter(AndroidLogAdapter(formatStrategy))
Timber.plant(object : Timber.DebugTree() {
override fun log(
priority: Int, tag: String?, message: String, t: Throwable?
) {
Logger.log(priority, "-$tag", message, t)
}
})
// Usage
Timber.d("onCreate: Inside Application!")
}
}
// Dependencies needed in build.gradle (app) file - Remember to update version if required.
// implementation 'com.orhanobut:logger:2.2.0'
// implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.jakewharton.timber:timber:4.7.1'
// https://github.com/JakeWharton/timber
implementation 'com.orhanobut:logger:2.2.0'
// https://github.com/orhanobut/logger