Move dynamic log level logic to filter

This commit is contained in:
AlanCoding
2019-05-22 09:46:19 -04:00
parent dc1bf3ef07
commit d3f047d731
3 changed files with 49 additions and 44 deletions

View File

@@ -19,12 +19,11 @@ from django.conf import settings
from requests_futures.sessions import FuturesSession
# AWX
from awx.main.constants import LOGGER_BLACKLIST
from awx.main.utils.formatters import LogstashFormatter
__all__ = ['BaseHTTPSHandler', 'TCPHandler', 'UDPHandler',
'AWXProxyHandler', 'RotatingProductionLogHandler']
'AWXProxyHandler']
logger = logging.getLogger('awx.main.utils.handlers')
@@ -92,28 +91,6 @@ class SocketResult:
return self
class DynamicLevelMixin(object):
@property
def level(self):
from django.conf import settings
for logger_name in LOGGER_BLACKLIST:
if self.name.startswith(logger_name):
return 30 # WARNING
try:
return logging._nameToLevel[settings.LOG_AGGREGATOR_LEVEL]
except Exception:
return 30 # WARNING
@level.setter
def level(self, level):
pass # no-op, this value comes from the database
class RotatingProductionLogHandler(logging.handlers.RotatingFileHandler, DynamicLevelMixin):
pass
class BaseHandler(logging.Handler):
def __init__(self, host=None, port=None, indv_facts=None, **kwargs):
super(BaseHandler, self).__init__()
@@ -295,7 +272,7 @@ HANDLER_MAPPING = {
}
class AWXProxyHandler(logging.Handler, DynamicLevelMixin):
class AWXProxyHandler(logging.Handler):
'''
Handler specific to the AWX external logging feature