mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
fix some bugs with the logging reload approach
This commit is contained in:
@@ -174,7 +174,7 @@ class HTTPSHandler(object):
|
|||||||
return BaseHTTPSHandler.from_django_settings(settings_module, *args, **kwargs)
|
return BaseHTTPSHandler.from_django_settings(settings_module, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def add_or_remove_logger(address, instance, adding=True):
|
def add_or_remove_logger(address, instance):
|
||||||
specific_logger = logging.getLogger(address)
|
specific_logger = logging.getLogger(address)
|
||||||
i_occurance = None
|
i_occurance = None
|
||||||
for i in range(len(specific_logger.handlers)):
|
for i in range(len(specific_logger.handlers)):
|
||||||
@@ -182,12 +182,14 @@ def add_or_remove_logger(address, instance, adding=True):
|
|||||||
i_occurance = i
|
i_occurance = i
|
||||||
break
|
break
|
||||||
|
|
||||||
if i_occurance is None and not adding:
|
if i_occurance is None:
|
||||||
return
|
if instance is not None:
|
||||||
elif i_occurance is None:
|
specific_logger.handlers.append(instance)
|
||||||
specific_logger.handlers.append(instance)
|
|
||||||
else:
|
else:
|
||||||
specific_logger.handlers[i_occurance] = instance
|
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):
|
||||||
@@ -197,11 +199,13 @@ def configure_external_logger(settings_module, async_flag=True, is_startup=True)
|
|||||||
# Pass-through if external logging not being used
|
# Pass-through if external logging not being used
|
||||||
return
|
return
|
||||||
|
|
||||||
|
instance = None
|
||||||
if is_enabled:
|
if is_enabled:
|
||||||
instance = HTTPSHandler(settings_module, async=async_flag)
|
instance = HTTPSHandler(settings_module, async=async_flag)
|
||||||
instance.setFormatter(LogstashFormatter())
|
instance.setFormatter(LogstashFormatter())
|
||||||
else:
|
awx_logger_instance = instance
|
||||||
instance = HTTPSNullHandler()
|
if is_enabled and 'awx' not in settings_module.LOG_AGGREGATOR_LOGGERS:
|
||||||
|
awx_logger_instance = None
|
||||||
|
|
||||||
add_or_remove_logger('awx.analytics', instance, adding=is_enabled)
|
add_or_remove_logger('awx.analytics', instance)
|
||||||
add_or_remove_logger('awx', instance, adding=(is_enabled and 'awx' in settings_module.LOG_AGGREGATOR_LOGGERS))
|
add_or_remove_logger('awx', awx_logger_instance)
|
||||||
|
|||||||
Reference in New Issue
Block a user