diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-02-03 20:02:44 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-02-03 20:02:44 +0000 |
commit | 1eef521147d2564d66519a832a7736d41cb74a88 (patch) | |
tree | a262deced260af7fd30d8d479e65f0d4e8164c4e /tracing.py | |
parent | bb2185cda758c4060c805971f5e5a7bff596da53 (diff) | |
download | python-tracing-1eef521147d2564d66519a832a7736d41cb74a88.tar.gz |
Speed optimization. Don't dig out tracebacks if there are no patterns.
Diffstat (limited to 'tracing.py')
-rw-r--r-- | tracing.py | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -59,10 +59,12 @@ def trace_clear_patterns(): def trace(msg): - frames = traceback.extract_stack(limit=2) - filename, lineno, funcname, text = frames[0] - for pattern in trace_patterns: - if pattern in filename: - logging.debug('%s:%s:%s: %s' % (filename, lineno, funcname, msg)) - break + if trace_patterns: + frames = traceback.extract_stack(limit=2) + filename, lineno, funcname, text = frames[0] + for pattern in trace_patterns: + if pattern in filename: + logging.debug('%s:%s:%s: %s' % + (filename, lineno, funcname, msg)) + break |