Open AlexTrotsenko opened 7 years ago
@JakeWharton just in case: if you also think, that adding such API is a good idea - I am volunteering to implement the changes in pull request.
The argument I've made against this in the past is that you're always going to be logging to at least one place. In production it's a ring buffer of events that get included in crash reports and in development it's that plus the actual Android log (if not more places).
Also your first example should be:
Timber.d("Something was done: %s and %s with %s", foo, that, expensiveOperation())
It doesn't change the behavior, but it at least doesn't waste time doing string formatting when there are no loggers.
This is related to #230 somewhat.
Given we have the need to write something like:
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, the syntax could be like this:
For example, it's implemented in Log4j 2.4.