Optional call stack depth parameter
See original GitHub issueThe logging interface looks like following:
log(int priority, String tag, String message, Throwable t)
Why not add an additional call stack adjustment value?
Use cases
Maybe someone wants to write reuseable logging functions, that should log their calling functions parameters. Seems like a common use case for me.
Example - simple transformer for logging observables execution time
public static <T> Observable.Transformer<T, T> applyMeasurement(Class clazz, String tag, boolean enabled)
{
return observable -> measure(observable, clazz, tag, enabled);
}
private static <T> Observable<T> measure(Observable<T> observable, Class clazz, String tag, boolean enabled)
{
if (!mEnabled || !enabled)
return observable;
LongHolder start = new LongHolder(0);
return observable
.doOnSubscribe(() -> start.set(System.currentTimeMillis()))
.doOnTerminate(() -> Timber.d("[%s | %s] Duration: %dms", clazz, tag, System.currentTimeMillis() - start.get()));
}
Here the log would print the line and class of my logger utility class, which is not perfect…
Wouldn’t it make sense to extend the log interface for such use cases?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Depth of the call-stack - node.js - Stack Overflow
The error object has a getter named 'stack' which returns a String containing the stack trace. Example from the REPL:
Read more >Optional JVM command line settings: stack size - IBM
The method call depth is very deep (for example, in the Create Wave agent, the wave optimizer call depth is roughly equal to...
Read more >Maximum depth of the java call stack | Edureka Community
Your answer Well, there is no definite depth. It just depends on the amount of virtual memory that has been allocated to the...
Read more >debug_get_callstack
The function allows for an optional argument to be passed in, which is the maximum depth of the returned callstack. This value is...
Read more >Maximum Call Stack Depth - Rhai - Embedded Scripting for Rust
In Rhai, it is trivial for a function call to perform infinite recursion such that all stack space is exhausted. ... Rhai, by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Any chances the linked pull request will be merged? Seems to be open for 2 years now.
Actually I’ve added an ability to the DebugTree to support this feature. I’ll open a pull request