mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 14:36:00 -03:30
refactor adding logger loop from PR review
This commit is contained in:
@@ -170,20 +170,13 @@ class BaseHTTPSHandler(logging.Handler):
|
|||||||
|
|
||||||
def add_or_remove_logger(address, instance):
|
def add_or_remove_logger(address, instance):
|
||||||
specific_logger = logging.getLogger(address)
|
specific_logger = logging.getLogger(address)
|
||||||
i_occurance = None
|
for i, handler in enumerate(specific_logger.handlers):
|
||||||
for i, _ in enumerate(specific_logger.handlers):
|
if isinstance(handler, (HTTPSNullHandler, BaseHTTPSHandler)):
|
||||||
if isinstance(specific_logger.handlers[i], (HTTPSNullHandler, BaseHTTPSHandler)):
|
specific_logger.handlers[i] = instance or HTTPSNullHandler()
|
||||||
i_occurance = i
|
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
if i_occurance is None:
|
|
||||||
if instance is not None:
|
if instance is not None:
|
||||||
specific_logger.handlers.append(instance)
|
specific_logger.handlers.append(instance)
|
||||||
else:
|
|
||||||
if instance is None:
|
|
||||||
specific_logger.handlers[i_occurance] = HTTPSNullHandler()
|
|
||||||
else:
|
|
||||||
specific_logger.handlers[i_occurance] = instance
|
|
||||||
|
|
||||||
|
|
||||||
def configure_external_logger(settings_module, async_flag=True, is_startup=True):
|
def configure_external_logger(settings_module, async_flag=True, is_startup=True):
|
||||||
|
|||||||
Reference in New Issue
Block a user