I am using timber to log logs in my project. I have planted a DebugTree
for my application in Application
class. I am able to use timber to log my errors and exceptions.
I, also, have a library module to be used in this project. In the library module, I add Timber as a gradle dependancy same as my :app
project. I want to be able to set a flag on library module to enable/disable its logging so that I can separate library logs from main :app
project. Something like:
LibraryModule().setDeveloperMode(true)
As of now, all of my logs are being printed. If I plant a new tree in library, this will print logs two times for all library logs.
I have looked at this answer too: How to tell Timber which log call is for which Tree? But, this is not what I want, I don't want to reserve a logging priority for a library-module.
I wish I could do something like this, but unless the tree is planted, it won't print anything. right? But, if I plant it, logs will be repeated due to multiple trees.
val libraryTree: Timber.Tree = Timber.DebugTree()
libraryTree.d("library-logs")
How can I enable/disable Timber logs for my library?