From e59c4ec1c7fc9a6ff207dbd71cdf3688df373e90 Mon Sep 17 00:00:00 2001 From: "Langhammer, Jens" Date: Fri, 4 Oct 2019 13:43:47 +0200 Subject: [PATCH] root(minor): cleanup, remove unused log --- passbook/core/auth/view.py | 3 +++ passbook/lib/log.py | 37 ------------------------------------- passbook/root/settings.py | 7 ------- 3 files changed, 3 insertions(+), 44 deletions(-) delete mode 100644 passbook/lib/log.py diff --git a/passbook/core/auth/view.py b/passbook/core/auth/view.py index 5446c1c02..5516380ae 100644 --- a/passbook/core/auth/view.py +++ b/passbook/core/auth/view.py @@ -61,10 +61,13 @@ class AuthenticationView(UserPassesTestMixin, View): _all_factors = Factor.objects.filter(enabled=True).order_by('order').select_subclasses() pending_factors = [] for factor in _all_factors: + LOGGER.debug("Checking if factor applies to user", + factor=factor, user=self.pending_user) policy_engine = PolicyEngine(factor.policies.all()) policy_engine.for_user(self.pending_user).with_request(self.request).build() if policy_engine.passing: pending_factors.append((factor.uuid.hex, factor.type)) + LOGGER.debug("Factor applies", factor=factor, user=self.pending_user) return pending_factors def dispatch(self, request, *args, **kwargs): diff --git a/passbook/lib/log.py b/passbook/lib/log.py deleted file mode 100644 index 4bf85d556..000000000 --- a/passbook/lib/log.py +++ /dev/null @@ -1,37 +0,0 @@ -"""QueueListener that can be configured from logging.dictConfig""" -from atexit import register -from logging.config import ConvertingList -from logging.handlers import QueueHandler, QueueListener -from queue import Queue - - -def _resolve_handlers(_list): - """Evaluates ConvertingList by iterating over it""" - if not isinstance(_list, ConvertingList): - return _list - - # Indexing the list performs the evaluation. - return [_list[i] for i in range(len(_list))] - - -class QueueListenerHandler(QueueHandler): - """QueueListener that can be configured from logging.dictConfig""" - - def __init__(self, handlers, auto_run=True, queue=Queue(-1)): - super().__init__(queue) - handlers = _resolve_handlers(handlers) - self._listener = QueueListener( - self.queue, - *handlers, - respect_handler_level=True) - if auto_run: - self.start() - register(self.stop) - - def start(self): - """start background thread""" - self._listener.start() - - def stop(self): - """stop background thread""" - self._listener.stop() diff --git a/passbook/root/settings.py b/passbook/root/settings.py index 843ee4b6e..9e44317eb 100644 --- a/passbook/root/settings.py +++ b/passbook/root/settings.py @@ -268,13 +268,6 @@ with CONFIG.cd('log'): 'class': 'logging.StreamHandler', 'formatter': "colored" if DEBUG else "plain", }, - 'queue': { - 'level': DEBUG, - 'class': 'passbook.lib.log.QueueListenerHandler', - 'handlers': [ - 'cfg://handlers.console', - ], - } }, 'loggers': { }