question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optional call stack depth parameter

See original GitHub issue

The 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:open
  • Created 7 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

1reaction
ammargithamcommented, Feb 6, 2022

Any chances the linked pull request will be merged? Seems to be open for 2 years now.

0reactions
TurKurT656commented, Feb 9, 2022

Actually I’ve added an ability to the DebugTree to support this feature. I’ll open a pull request

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found