aboutsummaryrefslogtreecommitdiff
path: root/rpki/log.py
diff options
context:
space:
mode:
Diffstat (limited to 'rpki/log.py')
-rw-r--r--rpki/log.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/rpki/log.py b/rpki/log.py
index 2abb3b2c..43561463 100644
--- a/rpki/log.py
+++ b/rpki/log.py
@@ -48,7 +48,7 @@ show_python_ids = False
# Whether tracebacks are enabled globally. Individual classes and
# modules may choose to override this.
-enable_tracebacks = False
+enable_tracebacks = True
## @var use_setproctitle
# Whether to use setproctitle (if available) to change name shown for
@@ -96,7 +96,10 @@ class Formatter(object):
yield time.strftime("%Y-%m-%d %H:%M:%S ", time.gmtime(record.created))
yield "%s[%d]: " % (self.ident, record.process)
try:
- yield repr(record.context) + " "
+ if isinstance(record.context, (str, unicode)):
+ yield record.context + " "
+ else:
+ yield repr(record.context) + " "
except AttributeError:
pass
yield record.getMessage()
@@ -262,3 +265,17 @@ def log_repr(obj, *tokens):
words.append(" at %#x" % id(obj))
return "<" + " ".join(words) + ">"
+
+
+def show_stack(stack_logger = None):
+ """
+ Log a stack trace.
+ """
+
+ if stack_logger is None:
+ stack_logger = logger
+
+ for frame in tb.format_stack():
+ for line in frame.split("\n"):
+ if line:
+ stack_logger.debug("%s", line.rstrip())