Skip to content

Commit

Permalink
subtle magic
Browse files Browse the repository at this point in the history
Signed-off-by: Jesse Bowling <[email protected]>
  • Loading branch information
Jesse Bowling committed Apr 1, 2020
1 parent e01e1bb commit d51ec18
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions hpfeeds-logger/hpfeedslogger/formatters/splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
import datetime
import time


def format(message):
outmsg = dict()

timestamp = datetime.datetime.isoformat(datetime.datetime.utcnow())
if time.tzname[0] == 'UTC':
timestamp += 'Z'
outmsg['timestamp'] = timestamp

outmsg = dict(message)
for k, v in dict(message).items():
outmsg[k] = v

if 'src_ip' in outmsg:
outmsg['src'] = outmsg['src_ip']
Expand All @@ -15,11 +23,6 @@ def format(message):
outmsg['dest'] = outmsg['dest_ip']
del outmsg['dest_ip']

timestamp = datetime.datetime.isoformat(datetime.datetime.utcnow())
if time.tzname[0] == 'UTC':
timestamp += 'Z'
outmsg['timestamp'] = timestamp

d = [u'{}="{}"'.format(name, str(value).replace('"', '\\"')) for name, value in outmsg.items() if value]
msg = ', '.join(d)

Expand Down

0 comments on commit d51ec18

Please sign in to comment.