laravel-debugbar icon indicating copy to clipboard operation
laravel-debugbar copied to clipboard

[feature request] debug/log/info/warning calls to show file and line

Open matijakovacevic opened this issue 3 years ago • 12 comments

Would be great if all the debugging functions would also display the filename:line where they were called from.

Is there a possibility of that happening? Thanks

matijakovacevic avatar Jul 16 '21 20:07 matijakovacevic

I'd really like this too and came here to see if it was possible.

I'd actually like to be able to also define what the filename and line number are, as my use case is that I wrap my debugging things in a function, and so want the script that called my debugging function to be displayed, not the function itself. Currently I am outputting this as part of the log message, but it is cluttering it up.

semyl avatar Jul 20 '21 17:07 semyl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Sep 19 '21 19:09 stale[bot]

Is there any chance that something like this would be picked up?

semyl avatar Sep 19 '21 22:09 semyl

Would a PR be accepted?

C'mon, throw us a bone over here :sweat_smile:

matijakovacevic avatar Sep 20 '21 19:09 matijakovacevic

Hmm, I guess that could work. Run a backtrace on it or something.

barryvdh avatar Sep 22 '21 11:09 barryvdh

So for me, I would like the option of passing in what I would like displayed as the file and line number, as I have wrapped the log function in another function - so would want it to display the calling location of my function.

I'm using this as a fallback if $log_script isn't filled in the function call:

    if (empty($log_script)) {
      $back_trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
      $calling_script = array_shift($back_trace);
      $file_parts = explode("/", str_replace('\\', '/', $calling_script['file']));
      $script_name = array_pop($file_parts);
      $log_script = $script_name . ": " . $calling_script['line'];
    }

Currently I have mimicked the behaviour I want by extending the MessagesCollector to receive the $log_script, and putting this string in the 'collector' key for the message, but it is a bit hacky. It does show up on individual collectors, but in the aggregated one still shows the collector name - probably there is something else I'd need to extend to do that.

image

Ideally, I would like a simpler way to just push custom text to the right hand side of the output. Potentially being able to 'stack' (vertically or horizontally) those "right hand side messages" so it could display both the collector name, location info, and/or anything else I wanted to add there.

semyl avatar Sep 22 '21 13:09 semyl

A bonus would be if those "right hand side messages" would be filterable ;)

semyl avatar Sep 22 '21 13:09 semyl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jan 09 '22 00:01 stale[bot]

Looks like there was a start at a PR for this. Would like to see it kept open.

semyl avatar Jan 09 '22 00:01 semyl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Apr 16 '22 07:04 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jul 10 '22 10:07 stale[bot]

Keep open

semyl avatar Jul 21 '22 02:07 semyl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Nov 02 '22 03:11 stale[bot]

keep open

semyl avatar Nov 02 '22 22:11 semyl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jun 18 '23 15:06 stale[bot]

keep open

semyl avatar Jun 19 '23 22:06 semyl