mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 03:11:55 +02:00
Refactoring for better logging (#4444)
* Move colored_logging.py to log.py * Add atexit.register code to util * Add tests for atexit_register * Copy except_hook to log * Add pre_arg_setup * move setup_log_file_handler to log.py * Add post_arg_setup * move changes to main * Undo changes to MainTest * s/pre_arg_setup/pre_arg_parse_setup * s/post_arg_setup/post_arg_parse_setup
This commit is contained in:
@@ -3,7 +3,6 @@ from __future__ import print_function
|
||||
|
||||
import collections
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
@@ -16,11 +15,6 @@ from certbot import util
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Store the pid of the process that first imported this module so that
|
||||
# atexit_print_messages side-effects such as error reporting can be limited to
|
||||
# this process and not any fork()'d children.
|
||||
INITIAL_PID = os.getpid()
|
||||
|
||||
|
||||
@zope.interface.implementer(interfaces.IReporter)
|
||||
class Reporter(object):
|
||||
@@ -60,19 +54,6 @@ class Reporter(object):
|
||||
self.messages.put(self._msg_type(priority, msg, on_crash))
|
||||
logger.debug("Reporting to user: %s", msg)
|
||||
|
||||
def atexit_print_messages(self, pid=None):
|
||||
"""Function to be registered with atexit to print messages.
|
||||
|
||||
:param int pid: Process ID
|
||||
|
||||
"""
|
||||
if pid is None:
|
||||
pid = INITIAL_PID
|
||||
# This ensures that messages are only printed from the process that
|
||||
# created the Reporter.
|
||||
if pid == os.getpid():
|
||||
self.print_messages()
|
||||
|
||||
def print_messages(self):
|
||||
"""Prints messages to the user and clears the message queue.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user