Skip to content

Commit ba9dda3

Browse files
committed
Update rawjson formatter to build the correct output. Closes #127
1 parent a73a492 commit ba9dda3

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

beaver/transports/base_transport.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ def null_formatter(data):
3737

3838
def rawjson_formatter(data):
3939
json_data = json.loads(data['@message'])
40-
for field in ['@source', '@type', '@tags', '@source_host', '@source_path']:
41-
if field in data:
42-
json_data[field] = data[field]
43-
return json.dumps(json_data)
40+
del data['@message']
41+
42+
for field in json_data:
43+
data[field] = json_data[field]
44+
45+
for field in ['@message', '@source', '@source_host', '@source_path', '@tags', '@timestamp', '@type']:
46+
if field not in data:
47+
data[field] = ''
48+
49+
return json.dumps(data)
4450

4551
def string_formatter(data):
4652
return '[{0}] [{1}] {2}'.format(data['@source_host'], data['@timestamp'], data['@message'])

0 commit comments

Comments
 (0)