Is there any Logging library which works for Kotli...
# android
i
Is there any Logging library which works for Kotlin modules and Android modules but I can change implementation to whenever/whatever I want (e.g. change implementation to Timber on Application onCreate).
g
Timber 5 (not released yet, but there are snapshots)
i
Where are these snapshots?
I see that: https://github.com/JakeWharton/timber/blob/five/common/src/main/kotlin/timber/log/Timber.kt I have some worries about working it within Java code. Is it working?
g
Yes, this branch
not sure that this version is published as snapshot, I just mean that there is this dev branch
i
ok, sure, thanks for information 🙂 it looks nice I'll watch this project, meantime I need something more stable (even 1 stable version would be great), if there are no others alternatives I'll write simple lib for it.
g
do you think sample lib would be more stable? 😁
i
Yeah, I think so, I don't want to worry that some snapshot disappear from maven repo or will change behaviour and I don't want include sources in my projects. So even my sample lib can be more stable than some unofficial snapshots.
g
Just publish it yourself
i
Can I do it without permission?
g
sure
it’s Apache 2.0
just not to public repo, or with different id
i
yeah I need public repo, but maybe with changed id
g
You also can use something like jitpack
i
I wonder about last thing, even if i publish my own snapshot version of Timber 5 there is possibility of package name conflicts. I develop library which can be used by many projects and I don't control dependencies of these projects. So I'm afraid of conflicts when they will have Timber 4 version and include my library with Timber 5.
g
with jitpack you can publish particular repo and particular commit
i
yes, but what happen if one project'll have Timber 4 and Timber 5?
g
it will not work of course
only if you repack one of them with different package name
Why would you use both?
but you right
you of course shouldn’t depend on such in a public library
I would just provide a way for user of your library to provide own logger instead
p
Isn't this just a general design principal question?. I.e. create a class that adhere's to an interface called something like Logger with functions Log. Have your app only be aware of said interface so that you can change the logger as an when required? Dependancy Inversion Principal?
i
@Phill @gildor Yeah, but writing own logger interface and mechanism for providing logger for each of my libraries seems like much copy&paste code and overkill for small libraries.
g
yes, so most libraries do not have logging
or you can provide very simple interface which is essentially println (which should be provided by user)
i
I would be happy to use Timber 5 inside my libraries but I'm worry about dependency conflicts. There should be some way to reuse one single logging library between many others libraries and avoiding any dependencies conflicts in final projects. Maybe should I repackage timber library for each of my libraries and put to jitpack?
g
I really wouldn’t like to have logging library in dependency of some small library
i
But all Android libraries have logging library - android.util.Log, why Kotlin couldn't have something similar or at least common Logger interface?
g
if it’s android library, just use android.util.Log which is part of Android Framework, no additional dependencies