hyperlog-android
hyperlog-android copied to clipboard
Create connector between Hyperlog and Timber
Because in a project I'm using timber - and I don't want change all methods call, my proposition creates a small library which will connect hyperlog and timber. I just implement Timber.Tree.
Agree, this is an obvious upgrade for this library
I have the following class in my app:
import android.content.Context
import android.util.Log
import com.hypertrack.hyperlog.HyperLog
import timber.log.Timber.DebugTree
class HyperLogTree(
context: Context,
logLevel: Int = Log.DEBUG
) : DebugTree() {
init {
HyperLog.initialize(context)
HyperLog.setLogLevel(logLevel)
}
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
when (priority) {
Log.VERBOSE -> HyperLog.v(tag, message, t)
Log.DEBUG -> HyperLog.d(tag, message, t)
Log.INFO -> HyperLog.i(tag, message, t)
Log.WARN -> HyperLog.w(tag, message, t)
Log.ERROR -> HyperLog.e(tag, message, t)
}
}
}
and call it from the Application class:
Timber.plant(CrashlyticsTree(), HyperLogTree(this, Log.INFO))