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.46k stars 962 forks source link

Log only to a specific Timber Tree #378

Closed rupinderjeet closed 4 years ago

rupinderjeet commented 4 years ago

How do I target Timber logs to only a specific tree?

I created a tree from DebugTree, but I failed to tell Timber which tree to use or not use. https://gist.github.com/rupinderjeet/b6721743078cc8bc615c6e300d02ae90

Related StackOverflow question: https://stackoverflow.com/questions/59783153

I think this is only possibly if I could overtake Timber class. But, then, I will lose correct file TAG functionality. Please suggest me a solution.

JakeWharton commented 4 years ago

The whole point of the library is to multiplex to all trees so this is not really doable. If you want to target a single one I would access its instance directly through dependency injection or just storing it somewhere static. In the future we might allow passing metadata which would let you more easily filter messages which are not meant for your tree (#184), but I don't foresee ever being able to explicitly target a single tree.