loguru icon indicating copy to clipboard operation
loguru copied to clipboard

Add ability to hide framework frames

Open jonashaag opened this issue 10 months ago • 3 comments

Some frameworks/libraries produce very long stacks. Loguru already highlights the user frames using colors. I'd like to be able to hide framework frames altogether.

I'd be happy to implement this using a custom ExceptionFormatter. I think the right place would be to extend _extract_frames().is_valid(). Would you be open for a PR that makes it possible to overwrite this function without copying all of the code?

If we wanted to go a step further we could even make this an official feature: Given a list of files or modules, Loguru skips those when printing exceptions.

jonashaag avatar Dec 26 '24 19:12 jonashaag

Hey. Thank you for your suggestion.

The problem is that currently, ExceptionFormatter isn't publicly available. The class can surely be extended, but you would still need to import it from a private Loguru's module. :/

However, as there have been several features requests to improve exception formatting, I'm considering making it more easily configurable. Then, we could seamlessly add the ability to skip frames. I've not yet defined the final API, though.

Delgan avatar Dec 30 '24 19:12 Delgan

Sounds great!

In the meantime, are you interested in a tiny PR to make overwriting frame selection possible? Even if it's using internal modules, better than nothing.

jonashaag avatar Dec 30 '24 21:12 jonashaag

In the meantime, are you interested in a tiny PR to make overwriting frame selection possible? Even if it's using internal modules, better than nothing.

Sure, if it's of any use to you why not. :+1:

Delgan avatar Dec 31 '24 13:12 Delgan