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

Import Timber.d as log #442

Closed naveensingh closed 3 years ago

naveensingh commented 3 years ago

Hi, Previously, I could do the following:

import timber.log.Timber.d as log

and it used to work with no fuss. I'm not sure if it's a bad thing to do.

After updating to version 5.0.1, the same import statement doesn't work and method d() is not resolved in the import statement. Timber.d works as usual.

What changed?

JakeWharton commented 3 years ago

The library was rewritten in Kotlin.

JakeWharton commented 3 years ago

Probably have to do timber.log.Timber.Companion.d as log?

naveensingh commented 3 years ago

I think not. Companion only works for stuff defined in the companion object {}. Just had a quick look at the source and found that the logging methods (d etc.) are now only defined in the abstract Tree class. I tried import timber.log.Timber.Tree.d as log and it turns out the problem isn't with the import alias but:

Cannot import d, functions and properties can only be imported from packages or objects.

Guess I'll just use Timber.d. Thanks, Jake

JakeWharton commented 3 years ago

I forgot our companion is named. Try import timber.log.Timber.Forest.d as log.

naveensingh commented 3 years ago

I tried that and it worked! Thanks