mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 22:14:55 -04:00
Fix up logcontexts
This commit is contained in:
parent
13e6262659
commit
2c1fbea531
31 changed files with 356 additions and 229 deletions
|
@ -168,3 +168,38 @@ def trace_function(f):
|
|||
|
||||
wrapped.__name__ = func_name
|
||||
return wrapped
|
||||
|
||||
|
||||
def get_previous_frames():
|
||||
s = inspect.currentframe().f_back.f_back
|
||||
to_return = []
|
||||
while s:
|
||||
if s.f_globals["__name__"].startswith("synapse"):
|
||||
filename, lineno, function, _, _ = inspect.getframeinfo(s)
|
||||
args_string = inspect.formatargvalues(*inspect.getargvalues(s))
|
||||
|
||||
to_return.append("{{ %s:%d %s - Args: %s }}" % (
|
||||
filename, lineno, function, args_string
|
||||
))
|
||||
|
||||
s = s.f_back
|
||||
|
||||
return ", ". join(to_return)
|
||||
|
||||
|
||||
def get_previous_frame(ignore=[]):
|
||||
s = inspect.currentframe().f_back.f_back
|
||||
|
||||
while s:
|
||||
if s.f_globals["__name__"].startswith("synapse"):
|
||||
if not any(s.f_globals["__name__"].startswith(ig) for ig in ignore):
|
||||
filename, lineno, function, _, _ = inspect.getframeinfo(s)
|
||||
args_string = inspect.formatargvalues(*inspect.getargvalues(s))
|
||||
|
||||
return "{{ %s:%d %s - Args: %s }}" % (
|
||||
filename, lineno, function, args_string
|
||||
)
|
||||
|
||||
s = s.f_back
|
||||
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue