andy-landy / traceback_with_variables

Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
MIT License
682 stars 27 forks source link

Add ignore_files and ignore_brief_files Format #30

Open shaoerkuai opened 1 week ago

shaoerkuai commented 1 week ago

Now it supports filter the specific files to be printed, but sometimes I just want to remove unnecessary frames likely from my global catch decorator rather than only shows fixed packages, so I think it's good to filter this..

Example:

Traceback with variables (most recent call last):
~~  File "D:\Program Files\Python38\lib\site-packages\THIS_FRAME_I_WANT_TO_REMOVE.py", line 69, in wrapper~~
~~  . try:~~
~~  >     return func(*args, **kwargs)~~
~~      args = ('a', 'b', 'c')~~
~~      kwargs = {}~~
~~      e = RuntimeError()~~
~~      catch_traceback = True~~
~~      func = <function test_exception at 0x000001C3944AC430>~~
~~      print_in_env = True~~
~~      print_signature = True~~
~~      re_raise = True~~
  File "D:\xxx\xxx\library\common\test.py", line 18, in test_exception
  . print("the function raises error")
  > raise RuntimeError
      d = 'xxx'
      e = 'xxx'
      f = 'xxx'
builtins.RuntimeError: 
andy-landy commented 19 hours ago

Hi, thanks for a use case.

Does brief_files_except='D:\xxx\' do the job? or skip_files_except