mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 21:07:39 -02:30
Prune the python2 specific logic from log formatter
This commit is contained in:
@@ -46,10 +46,7 @@ class LogstashFormatterBase(logging.Formatter):
|
|||||||
'msecs', 'msecs', 'message', 'msg', 'name', 'pathname', 'process',
|
'msecs', 'msecs', 'message', 'msg', 'name', 'pathname', 'process',
|
||||||
'processName', 'relativeCreated', 'thread', 'threadName', 'extra')
|
'processName', 'relativeCreated', 'thread', 'threadName', 'extra')
|
||||||
|
|
||||||
if sys.version_info < (3, 0):
|
easy_types = (str, bool, dict, float, int, list, type(None))
|
||||||
easy_types = (basestring, bool, dict, float, int, long, list, type(None))
|
|
||||||
else:
|
|
||||||
easy_types = (str, bool, dict, float, int, list, type(None))
|
|
||||||
|
|
||||||
fields = {}
|
fields = {}
|
||||||
|
|
||||||
@@ -63,23 +60,15 @@ class LogstashFormatterBase(logging.Formatter):
|
|||||||
return fields
|
return fields
|
||||||
|
|
||||||
def get_debug_fields(self, record):
|
def get_debug_fields(self, record):
|
||||||
fields = {
|
return {
|
||||||
'stack_trace': self.format_exception(record.exc_info),
|
'stack_trace': self.format_exception(record.exc_info),
|
||||||
'lineno': record.lineno,
|
'lineno': record.lineno,
|
||||||
'process': record.process,
|
'process': record.process,
|
||||||
'thread_name': record.threadName,
|
'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
|
@classmethod
|
||||||
def format_timestamp(cls, time):
|
def format_timestamp(cls, time):
|
||||||
tstamp = datetime.utcfromtimestamp(time)
|
tstamp = datetime.utcfromtimestamp(time)
|
||||||
@@ -91,10 +80,7 @@ class LogstashFormatterBase(logging.Formatter):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def serialize(cls, message):
|
def serialize(cls, message):
|
||||||
if sys.version_info < (3, 0):
|
return bytes(json.dumps(message), 'utf-8')
|
||||||
return json.dumps(message)
|
|
||||||
else:
|
|
||||||
return bytes(json.dumps(message), 'utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
class LogstashFormatter(LogstashFormatterBase):
|
class LogstashFormatter(LogstashFormatterBase):
|
||||||
|
|||||||
Reference in New Issue
Block a user