https://kotlinlang.org logo
Title
i

ignus

07/23/2019, 7:27 AM
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

gildor

07/23/2019, 7:31 AM
Timber 5 (not released yet, but there are snapshots)
i

ignus

07/23/2019, 7:36 AM
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

gildor

07/23/2019, 7:43 AM
Yes, this branch
not sure that this version is published as snapshot, I just mean that there is this dev branch
i

ignus

07/23/2019, 7:46 AM
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

gildor

07/23/2019, 7:57 AM
do you think sample lib would be more stable? 😁
i

ignus

07/23/2019, 8:11 AM
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

gildor

07/23/2019, 8:13 AM
Just publish it yourself
i

ignus

07/23/2019, 8:14 AM
Can I do it without permission?
g

gildor

07/23/2019, 8:14 AM
sure
it’s Apache 2.0
just not to public repo, or with different id
i

ignus

07/23/2019, 8:15 AM
yeah I need public repo, but maybe with changed id
g

gildor

07/23/2019, 8:17 AM
You also can use something like jitpack
i

ignus

07/23/2019, 8:23 AM
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

gildor

07/23/2019, 8:25 AM
with jitpack you can publish particular repo and particular commit
i

ignus

07/23/2019, 8:26 AM
yes, but what happen if one project'll have Timber 4 and Timber 5?
g

gildor

07/23/2019, 8:27 AM
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

Phill

07/23/2019, 8:44 AM
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

ignus

07/23/2019, 8:45 AM
@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

gildor

07/23/2019, 8:46 AM
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

ignus

07/23/2019, 8:50 AM
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

gildor

07/23/2019, 9:26 AM
I really wouldn’t like to have logging library in dependency of some small library
i

ignus

07/23/2019, 9:33 AM
But all Android libraries have logging library - android.util.Log, why Kotlin couldn't have something similar or at least common Logger interface?
g

gildor

07/23/2019, 9:43 AM
if it’s android library, just use android.util.Log which is part of Android Framework, no additional dependencies