From 1107259dc258d0cfcb447519cc36e59e78facdef Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 2 Oct 2016 11:52:47 +0000 Subject: Errors: added time stamps in UTC --- wqflask/utility/logger.py | 6 +++++- wqflask/wqflask/views.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py index ddc0ea82..b873e16f 100644 --- a/wqflask/utility/logger.py +++ b/wqflask/utility/logger.py @@ -31,6 +31,7 @@ import string from inspect import isfunction from pprint import pformat as pf from inspect import stack +import datetime from utility.tools import LOG_LEVEL, LOG_LEVEL_DEBUG, LOG_SQL, LOG_FORMAT @@ -66,7 +67,10 @@ LOG_LEVEL_DEBUG (NYI). def error(self,*args): """Call logging.error for multiple args""" - self.collect(self.logger.error,*args) + now = datetime.datetime.utcnow() + time_str = now.strftime('%H:%M:%S UTC %Y%m%d') + l = [time_str]+list(args) + self.collect(self.logger.error,*l) def infof(self,*args): """Call logging.info for multiple args lazily""" diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 12d43052..7abcc17d 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -7,6 +7,8 @@ from __future__ import absolute_import, division, print_function import traceback # for error page import os # for error gifs import random # for random error gif +import datetime # for errors +import time # for errors import sys import csv import xlsxwriter @@ -95,7 +97,9 @@ def handle_bad_request(e): # get the stack trace and send it to the logger exc_type, exc_value, exc_traceback = sys.exc_info() logger.error(traceback.format_exc()) - formatted_lines = [request.url]+traceback.format_exc().splitlines() + now = datetime.datetime.utcnow() + time_str = now.strftime('%l:%M%p UTC %b %d, %Y') + formatted_lines = [request.url + " ("+time_str+")"]+traceback.format_exc().splitlines() # Handle random animations # Use a cookie to have one animation on refresh -- cgit v1.2.3