aboutsummaryrefslogtreecommitdiff
path: root/rpki/log.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2014-06-05 04:28:06 +0000
committerRob Austein <sra@hactrn.net>2014-06-05 04:28:06 +0000
commit4b7fec44f0ce55256b3f8f1fde19f2b7ed6fe485 (patch)
tree04c43527c7b3e7c4d703d727acbe4ae6e02241d3 /rpki/log.py
parent682e2b1ea221bad77e1dc27325cd1232f07ee407 (diff)
First cut at fully configurable logging system. Still a bit raw, and
not yet documented, but allows detailed logging configuration down to the class level, and flexible enough to allow runtime configuration if we decide we need that. svn path=/trunk/; revision=5860
Diffstat (limited to 'rpki/log.py')
-rw-r--r--rpki/log.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/rpki/log.py b/rpki/log.py
index 32ded80f..2abb3b2c 100644
--- a/rpki/log.py
+++ b/rpki/log.py
@@ -219,6 +219,21 @@ def init(ident = None, args = None):
setproctitle.setproctitle(ident)
+def class_logger(module_logger, attribute = "logger"):
+ """
+ Class decorator to add a class-level Logger object as a class
+ attribute. This allows control of debugging messages at the class
+ level rather than just the module level.
+
+ This decorator takes the module logger as an argument.
+ """
+
+ def decorator(cls):
+ setattr(cls, attribute, module_logger.getChild(cls.__name__))
+ return cls
+ return decorator
+
+
def log_repr(obj, *tokens):
"""
Constructor for __repr__() strings, handles suppression of Python