From d06acdbc9068ec5ff060cc9f941d5f348e36ed8c Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 11 Jan 2012 09:43:09 -0500 Subject: Remove buffer log handling. This is properly handled by the new logging subsystem. --- ipaserver/install/installutils.py | 64 --------------------------------------- 1 file changed, 64 deletions(-) (limited to 'ipaserver') diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index f82d2ebc..817308f1 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -314,70 +314,6 @@ def port_available(port): return rv -class BufferingHandler(logging.Handler): - log_queue = [] - - def __init__(self): - logging.Handler.__init__(self) - self.level = logging.DEBUG - - def emit(self, record): - self.log_queue.append(record) - - def flush(self): - pass - -def bootstrap_logging(): - """ - Bootstrap logging and create special handler which will buffer any log - emitted before standard_logging_setup is called. These will be later - processed when the logging is set up. - """ - root_logger = logging.getLogger() - root_logger.setLevel(logging.DEBUG) - root_logger.addHandler(BufferingHandler()) - -def standard_logging_setup(log_filename, debug=False, filemode='w'): - """ - Set up logging. bootstrap_logging() should be called earlier if there - is a chance that a log is emitted before this setup. - """ - root_logger = logging.getLogger() - log_queue = [] - - if root_logger.handlers: - # Remove any handlers that may have been set and which may cause - # problems with logging in install utils - handler_list = list(logging.getLogger().handlers) - - for handler in handler_list: - if isinstance(handler, BufferingHandler): - log_queue.extend(handler.log_queue) - root_logger.removeHandler(handler) - - old_umask = os.umask(077) - # Always log everything (i.e., DEBUG) to the log - # file. - logging.basicConfig(level=logging.DEBUG, - format='%(asctime)s %(levelname)s %(message)s', - filename=log_filename, - filemode=filemode) - os.umask(old_umask) - - console = logging.StreamHandler() - # If the debug option is set, also log debug messages to the console - if debug: - console.setLevel(logging.DEBUG) - else: - # Otherwise, log critical and error messages - console.setLevel(logging.ERROR) - formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') - console.setFormatter(formatter) - logging.getLogger('').addHandler(console) - - for log_record in log_queue: - root_logger.handle(log_record) - def get_password(prompt): if os.isatty(sys.stdin.fileno()): return getpass.getpass(prompt) -- cgit