From 1eaabd49a83d58ee750c2c0246107e1c60673f8d Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 20 May 2021 20:03:04 +0200 Subject: [PATCH] switching back to own loggn --- rowers/c2stuff.py | 8 -------- rowers/tasks.py | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 4c7c4263..66b62aeb 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -3,14 +3,6 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -import logging -logging.basicConfig( - filename='debuglog.log', - level=logging.DEBUG, - format='%(asctime)s %(message)s', - datefmt='%m/%d/%Y %I:%M:%S %p' -) - # The interactions with the Concept2 logbook API # All C2 related functions should be defined here # (There is still some stuff defined directly in views.py. Need to diff --git a/rowers/tasks.py b/rowers/tasks.py index bbb9c8bf..2f12617a 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -36,13 +36,6 @@ from iso8601 import ParseError from json.decoder import JSONDecodeError -import logging -logging.basicConfig( - filename='debuglog.log', - level=logging.CRITICAL, - format='%(asctime)s %(message)s', - datefmt='%m/%d/%Y %I:%M:%S %p' -) from matplotlib.backends.backend_agg import FigureCanvas #from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvas @@ -132,6 +125,14 @@ from rowers.courseutils import ( InvalidTrajectoryError ) +def dologging(s): + tstamp = time.localtime() + timestamp = time.strftime('%b-%d-%Y %H:%M:%S', tstamp) + with open('debuglog.log','a') as f: + f.write('\n') + f.write(timestamp) + f.write(' ') + f.write(s) # Concept2 logbook sends over split data for each interval # We use it here to generate a custom summary @@ -3006,8 +3007,8 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone weightclass = data['weight_class'] s = 'User {userid}, C2 ID {c2id}'.format(userid=userid,c2id=c2id) - logging.critical(s) - logging.critical(data) + dologging(s) + dologging(json.dumps(data)) try: title = data['name'] @@ -3037,7 +3038,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone s = 'Time zone {timezone}, stardatetime {startdatetime}, duration {duration}'.format( timezone=timezone,startdatetime=startdatetime, duration=duration) - logging.critical(s) + dologging(s)