more notifier magic

This commit is contained in:
Ville Rantanen
2018-07-01 16:20:09 +03:00
parent d074932259
commit 42ad2da90a
2 changed files with 50 additions and 7 deletions

View File

@@ -1,12 +1,15 @@
import sys
import time
import json
from datetime import datetime
class Notifier:
def __init__(self):
self.output = open('notifier.log','at')
pass
def notify(self, msg):
self.output.write(str(time.time())+"\n")
self.output.write(str(msg)+"\n")
self.output.flush()
self.output = open('/code/data/notifier.log','at')
msg['address'] = msg['environment']['HTTP_X_FORWARDED_FOR']
msg['date'] = datetime.now().isoformat()
del msg['environment']
self.output.write(json.dumps(msg, sort_keys = True)+"\n")
self.output.close()