JakeWharton / JakeWharton/timber
Lazy Logging with lambdas
- Dominant language
- Kotlin
- Stars
- 10.8k
- Forks
- 994
- Avg merge
- 17h 16m
- Merged PRs (30d)
- 17
Description
Given we have the need to write something like:
```
Timber.d("Something was done: " + foo + " and " + that + "with " + expensiveOperation());
```
It would be nice to avoid calls to `expensiveOperation()` when no logging is happening _(e.g. when "forest" is empty, etc.)_.
Since now [lambda expressions are supported in default toolchain](https://developer.android.com/studio/write/java8-support.html), the syntax could be like this:
```
Timber.d(() -> "Something was done: " + foo + " and " + that + "with " + expensiveOperation());
```
For example, it's implemented in [Log4j 2.4](https://logging.apache.org/log4j/2.0/manual/api.html).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing Timber's public logging API and how its current methods are invoked. Compare the proposed lambda form with the existing API and the linked Log4j example; done means expensiveOperation() is not evaluated when logging is inactive while the syntax remains compatible with the supported Android toolchain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, kotlin
- Domain
- mobile-dev, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100