JakeWharton / timber

A logger with a small, extensible API which provides utility on top of Android's normal Log class.
https://jakewharton.github.io/timber/docs/5.x/
Apache License 2.0
10.41k stars 959 forks source link

DebugTree doesn't fully remove anonymous class suffix when determining tag for Kotlin code #411

Closed equeim closed 3 years ago

equeim commented 3 years ago

If we have following class in Kotlin:

class Foo {
    fun bar() {
        object : Runnable {
            override fun run() {
                Timber.i("doit")
            }
        }.run()
    }
}

Then DebugTree will create tag "Foo$bar", while the same class written in Java will create tag "Foo". This is probably because Kotlin apparently compiler adds enclosing method name to anonymous class name, while Java compiler doesn't do it.

VincentJoshuaET commented 3 years ago

Same issue. I also cannot override tag. tag in CustomTree has no access to internal open val tag: String? defined in timber.log.Timber.Tree, so it cannot override it

JakeWharton commented 3 years ago

We have no way of differentiating this from a normal nested type with the name bar. So this is unfortunately going to be working as intended.