diff options
author | Erik Johnston <erik@matrix.org> | 2019-10-09 16:52:21 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-10-09 16:52:21 +0100 |
commit | 5c1f886c75979b606c1e8bb45fcd8b7d26a71f39 (patch) | |
tree | ee651459cda811d4ac5d11f1e2fc4d9c06df037a /synapse/logging/utils.py | |
parent | Update (diff) | |
parent | Merge pull request #6185 from matrix-org/erikj/fix_censored_evnets (diff) | |
download | synapse-5c1f886c75979b606c1e8bb45fcd8b7d26a71f39.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/patch_inner
Diffstat (limited to 'synapse/logging/utils.py')
-rw-r--r-- | synapse/logging/utils.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/synapse/logging/utils.py b/synapse/logging/utils.py index 7df0fa6087..6073fc2725 100644 --- a/synapse/logging/utils.py +++ b/synapse/logging/utils.py @@ -119,7 +119,11 @@ def trace_function(f): logger = logging.getLogger(name) level = logging.DEBUG - s = inspect.currentframe().f_back + frame = inspect.currentframe() + if frame is None: + raise Exception("Can't get current frame!") + + s = frame.f_back to_print = [ "\t%s:%s %s. Args: args=%s, kwargs=%s" @@ -144,7 +148,7 @@ def trace_function(f): pathname=pathname, lineno=lineno, msg=msg, - args=None, + args=tuple(), exc_info=None, ) @@ -157,7 +161,12 @@ def trace_function(f): def get_previous_frames(): - s = inspect.currentframe().f_back.f_back + + frame = inspect.currentframe() + if frame is None: + raise Exception("Can't get current frame!") + + s = frame.f_back.f_back to_return = [] while s: if s.f_globals["__name__"].startswith("synapse"): @@ -174,7 +183,10 @@ def get_previous_frames(): def get_previous_frame(ignore=[]): - s = inspect.currentframe().f_back.f_back + frame = inspect.currentframe() + if frame is None: + raise Exception("Can't get current frame!") + s = frame.f_back.f_back while s: if s.f_globals["__name__"].startswith("synapse"): |