From 8a72a4d39d70d278c0be49620ac383c0f17ecef8 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Wed, 23 Jan 2019 09:48:51 -0500 Subject: [PATCH] Prune the python2 specific logic from log formatter --- awx/main/utils/formatters.py | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/awx/main/utils/formatters.py b/awx/main/utils/formatters.py index 3711cf33a8..9d1a431b0b 100644 --- a/awx/main/utils/formatters.py +++ b/awx/main/utils/formatters.py @@ -46,10 +46,7 @@ class LogstashFormatterBase(logging.Formatter): 'msecs', 'msecs', 'message', 'msg', 'name', 'pathname', 'process', 'processName', 'relativeCreated', 'thread', 'threadName', 'extra') - if sys.version_info < (3, 0): - easy_types = (basestring, bool, dict, float, int, long, list, type(None)) - else: - easy_types = (str, bool, dict, float, int, list, type(None)) + easy_types = (str, bool, dict, float, int, list, type(None)) fields = {} @@ -63,23 +60,15 @@ class LogstashFormatterBase(logging.Formatter): return fields def get_debug_fields(self, record): - fields = { + return { 'stack_trace': self.format_exception(record.exc_info), 'lineno': record.lineno, 'process': record.process, 'thread_name': record.threadName, + 'funcName': record.funcName, + 'processName': record.processName, } - # funcName was added in 2.5 - if not getattr(record, 'funcName', None): - fields['funcName'] = record.funcName - - # processName was added in 2.6 - if not getattr(record, 'processName', None): - fields['processName'] = record.processName - - return fields - @classmethod def format_timestamp(cls, time): tstamp = datetime.utcfromtimestamp(time) @@ -91,10 +80,7 @@ class LogstashFormatterBase(logging.Formatter): @classmethod def serialize(cls, message): - if sys.version_info < (3, 0): - return json.dumps(message) - else: - return bytes(json.dumps(message), 'utf-8') + return bytes(json.dumps(message), 'utf-8') class LogstashFormatter(LogstashFormatterBase):