Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Function name stack #231

Closed
ptusch opened this issue Oct 15, 2015 · 1 comment
Closed

[Feature Request] Function name stack #231

ptusch opened this issue Oct 15, 2015 · 1 comment

Comments

@ptusch
Copy link

ptusch commented Oct 15, 2015

Hi,

I'd love to hear your thoughts about an optional function stack trace that simple tracks the names of a function and simply pops it when it finishes.

I think it's rather easy to add external functions functionPush (or fPush) / functionPop (or fPop) with fPush having the argument of a string (name of function).
Those names need to be stored in an array and should be added to the namespace* whenever a debug in that function is called.

To not break the current pattern, the functionname stack can be concatted with a simple -> so you still call you debug from the cli like DEBUG=test:run and have results like:
*test:run->funcA* Hello from funcA

Function a would look like this:

function funcA() {
  debug.fPush('funcA');

  debug('Hello from funcA');

  debug('fPop');
}

This allows a developer to see the live stacktrace if you want to.
The drawback is obvious though - you have to take care of the push and pop.
But the advantages might overweight.

If you like this idea, I'll add it and PR it to you.
Any thoughts?

  • Or simply added to the output when a debug is called. I don't think string operations left and right are a good way.
@thebigredgeek
Copy link
Contributor

middleware should help with this: #370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants