Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple Timber from Android.Log #63

Closed
wants to merge 1 commit into from

Conversation

saguinav
Copy link

Hi Jake!

Few days ago I opened issue #62 asking about the possibility of removing android.Log from Timber class so it can be a pure Java logger. You closed it as a dupe of #29, which asks for making Timber dependent of slf4j-api. I'm not sure these two are asking for the same.

In order to make my issue more clear I have created this PR as an "illustrative" solution. I know it may not be the best, mainly because it breaks the chain of compatibility for older versions because in favor of a new namespace for DebugTree (timber.log.android.DebugTree). But, at least, I hope that you can get a better picture of the goal that I want to achieve.

Look forward to your feedback.

Thanks!

@ZakTaccardi
Copy link

Would be awesome if The timber class was pure java, and you could "plant" an android tree in it.

@jaredsburrows
Copy link

@JakeWharton Can you take a look at this? This would be a nice option to have.

@JakeWharton
Copy link
Owner

I don't like the idea of using slf4j as an abstraction.

@saguinav
Copy link
Author

@JakeWharton there is no slf4j on my PR. What do you mean with that?

@ZakTaccardi
Copy link

The Timber.Tree class is the abstraction.

You would need a pure java :timber module and a :timber-android that contains the DebugTree which prints the logging calls to LogCat.

@saguinav
Copy link
Author

saguinav commented May 8, 2017

@ZakTaccardi take a look at the diff in this PR. A pure java :timber and a :timber-android is exactly what I propose.

@wrajaka
Copy link

wrajaka commented Nov 12, 2017

Check this

@salamanders
Copy link

I was so sad about "no Timber when not on Android" that I asked in the Kotlin discussion forum. Cross-linking in case anyone comes here from there, or in case anyone watching this FR has a solution. Thanks again for Timber in the Android world!

@JakeWharton
Copy link
Owner

JakeWharton commented Oct 1, 2018 via email

@salamanders
Copy link

For what it's worth

No but wait... that's actually worth quite a bit. Fantastic, going to try it now, thank you!

@salamanders
Copy link

Yaaaa... I dunno, I've got something twisted wrong.

pom.xml

....
<kotlin.version>1.3.0-rc-116</kotlin.version>
<kotlin_coroutine_core.version>0.26.1-eap13</kotlin_coroutine_core.version>
<kotlin.compiler.languageVersion>1.3</kotlin.compiler.languageVersion>
....
<repository>
    <id>oss-sonatype</id>
    <name>oss-sonatype</name>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
</repository>
....
<!-- Nice to transfer to a release when non-Android is supported -->
<dependency>
    <groupId>com.jakewharton.timber</groupId>
    <artifactId>timber</artifactId>
    <version>4.7.2-SNAPSHOT</version>
</dependency>
<!-- Kotlin shortcuts -->
<dependency>
    <groupId>com.github.ajalt</groupId>
    <artifactId>timberkt</artifactId>
    <version>1.5.1</version>
</dependency>

Which results in

Warning:Kotlin: Classpath entry points to a non-existent location: /Users/me/.m2/repository/com/jakewharton/timber/timber/4.7.2-SNAPSHOT/timber-4.7.2-SNAPSHOT.jar
Warning:Kotlin: Classpath entry points to a non-existent location: /Users/me/.m2/repository/com/github/ajalt/timberkt/1.5.1/timberkt-1.5.1.jar

which then goes to..

import com.github.ajalt.timberkt.Timber
Error:(3, 12) Kotlin: Unresolved reference: github

@gabrielittner
Copy link

@salamanders You want to use this:

<dependency>
    <groupId>com.jakewharton.timber</groupId>
    <artifactId>timber-jdk</artifactId>
    <version>5.0.0-SNAPSHOT</version>
</dependency>

@salamanders
Copy link

Nice!
...But then DebugTree() seems missing.

@gabrielittner
Copy link

That's in a separate artifact:

<dependency>
    <groupId>com.jakewharton.timber</groupId>
    <artifactId>timber-android</artifactId>
    <version>5.0.0-SNAPSHOT</version>
</dependency>

It also has been renamed to LogcatTree.

@salamanders
Copy link

What should the hello-world jvm debug logger use case use? (Answer might be "that one" but I wanted to ask, because I'm not on android for this)

@martinbonnin
Copy link

If anyone's coming here looking for multiplatform support, it looks like this has been reverted from master: 72efb7c.

The code is in the five branch: https://github.com/JakeWharton/timber/commits/five

The Android Tree is LogcatTree, js is ConsoleTree. Haven't found a JDK default logger using System.out but shouldn't be that hard to make one.

@ben-xD ben-xD mentioned this pull request Feb 4, 2021
@p-fischer
Copy link

The sonatype snapshots for Timber 5.0.0 are still working and are used by SdkSearch.
The dependencies are introduced in this commit.
The current list of all Timber 5 dependencies can be looked up here.

However, the new LogcatTree does not (yet) have an implementation to infer an automatic tag from the call stack, which DebugTree used to have.

I'm wondering if there are plans to release Timber 5 with JDK or Kotlin Multiplatform support any time soon and if the automatic tag inference will be re-implemented. #338 might be the issue tracking this progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants