Skip to content
Permalink
Browse files

Added clientIp and userAgent to logs

  • Loading branch information...
rgfoley committed Dec 6, 2016
1 parent 24eba9e commit 528d6fb86ed8af0375a41f87cb8ebfc93da708a2
Showing with 5 additions and 3 deletions.
  1. +5 −3 demo/dashboard/files/twisted_app.py
@@ -167,7 +167,9 @@ def get_allow_origin(request):
else:
return settings['allow_origin']

def log_json(data):
def log_json(request, data):
data['clientIp'] = request.getClientIP()
data['userAgent'] = request.getHeader('User-Agent')
if ('useraleVersion' in data) and (data ['useraleVersion'].split('.')[0] == '4'):
logger_js.info(simplejson.dumps(data))
elif ('useraleVersion' in data) and (data['useraleVersion'].split('.')[0] == '3'):
@@ -194,9 +196,9 @@ def render_POST(self, request):
try:
if isinstance(data, list):
for datum in data:
log_json(datum)
log_json(request, datum)
else:
log_json(data)
log_json(request, data)
except Exception as e:
logger_err.error(e)

0 comments on commit 528d6fb

Please sign in to comment.
You can’t perform that action at this time.