hyperlog-android icon indicating copy to clipboard operation
hyperlog-android copied to clipboard

Create connector between Hyperlog and Timber

Open mariopce opened this issue 6 years ago • 2 comments

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.

mariopce avatar Dec 28 '17 17:12 mariopce

Agree, this is an obvious upgrade for this library

deano2390 avatar Sep 17 '18 10:09 deano2390

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))

brianjcoan avatar Oct 02 '23 19:10 brianjcoan