Commit 61f8c1a5 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Only subject structlog data to key treatment.

parent 41112fe9
Pipeline #37463 passed with stages
in 6 minutes and 22 seconds
......@@ -77,20 +77,26 @@ class LogstashFormatter(logstash.formatter.LogstashFormatterBase):
'logger_name': record.name,
}
data_sets = [structlog, self.get_extra_fields(record), self.get_debug_fields(record)]
for data in data_sets:
if record.name.startswith('nomad'):
for key, value in data.items():
if key in ['event', 'stack_info']:
pass
elif key in LogstashFormatter.root_keys:
key = 'nomad.%s' % key
else:
key = '%s.%s' % (record.name, key)
message[key] = value
else:
message.update(data)
message.update(structlog)
if record.name.startswith('nomad'):
for key, value in structlog.items():
if key in ['event', 'stack_info']:
pass
elif key in LogstashFormatter.root_keys:
key = 'nomad.%s' % key
else:
key = '%s.%s' % (record.name, key)
message[key] = value
else:
message.update(structlog)
# Add extra fields
message.update(self.get_extra_fields(record))
# If exception, add debug info
if record.exc_info:
message.update(self.get_debug_fields(record))
return self.serialize(message)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment