JakeWharton / JakeWharton/timber

isLoggable of individual Trees not entirely respected

Open
#324 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
10.8k
Forks
994
Avg merge
17h 16m
Merged PRs (30d)
17

Description

(master branch)

The extension `Timber.log(Int, Throwable, () -> String)` method calls `isLoggable()` which will be true when any of the installed Trees return true. It will then go on to call rawLog on all Trees, even those where `isLoggable()` returns true.

For example

```
class LogcatTree2 : Tree() {
override fun isLoggable(priority: Int, tag: String?): Boolean {
return priority >= Log.ERROR
}

override fun performLog(priority: Int, tag: String?, throwable: Throwable?, message: String?) {
Log.e("second tree", "don't call me")
}
}

Timber.plant(LogcatTree())
Timber.plant(LogcatTree2())
Timber.warn { "foo" }
```

prints

```
W/App: foo
E/second tree: don't call me
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Timber.log(Int, Throwable, () -> String) extension and trace how installed Tree instances are checked before rawLog or performLog is called. Reproduce the example with one Tree accepting warnings and another accepting only errors. Done means a warning is delivered only to Trees whose isLoggable result permits it, with coverage for the two-Tree case.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.