From 4b7fec44f0ce55256b3f8f1fde19f2b7ed6fe485 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Thu, 5 Jun 2014 04:28:06 +0000 Subject: 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 --- rpki/log.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'rpki/log.py') 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 -- cgit v1.2.3