Private
Public Access
1
0

logging enabled/disabled thru config

This commit is contained in:
Sander Roosendaal
2022-04-07 08:43:43 +02:00
parent f49ba3b36a
commit 3c2813c3e3
4 changed files with 16 additions and 6 deletions

View File

@@ -3120,9 +3120,7 @@ def df_from_summary(data):
@app.task
def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec, defaulttimezone, debug=False, **kwargs):
time.sleep(delaysec)
with open("c2_auto_import.log", "a") as errorlog:
timestr = time.strftime("%Y%m%d-%H%M%S")
errorlog.write(timestr+' '+str(c2id)+' for userid '+str(userid)+'\r\n')
dologging('c2_import.log',str(c2id)+' for userid '+str(userid))
data = alldata[c2id]
splitdata = None
@@ -3146,8 +3144,8 @@ def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec, defaulttim
has_strokedata = True
s = 'User {userid}, C2 ID {c2id}'.format(userid=userid, c2id=c2id)
dologging('debuglog.log', s)
dologging('debuglog.log', json.dumps(data))
dologging('c2_import.log', s)
dologging('c2_import.log', json.dumps(data))
try:
title = data['name']

View File

@@ -28,6 +28,8 @@ import iso8601
from iso8601 import ParseError
import arrow
from django.conf import settings
lbstoN = 4.44822
landingpages = (
@@ -120,6 +122,11 @@ info_calls = [
def dologging(filename, s):
do_logging = settings.MYLOGGING.get(filename,True)
if not do_logging:
return
tstamp = time.localtime()
timestamp = time.strftime('%b-%d-%Y %H:%M:%S', tstamp)
with open(filename, 'a') as f:

View File

@@ -1576,7 +1576,7 @@ def workout_c2import_view(request, page=1, userid=0, message=""):
rower = getrequestrower(request, userid=userid)
if rower.user != request.user:
messages.error(
request, 'You can only access your own workouts on the NK Logbook, not those of your athletes')
request, 'You can only access your own workouts on the Concept2 Logbook, not those of your athletes')
url = reverse('workout_c2import_view', kwargs={
'userid': request.user.id})
return HttpResponseRedirect(url)

View File

@@ -589,3 +589,8 @@ except KeyError: # pragma: no cover
GEOIP_PATH = STATIC_ROOT
TAGGIT_CASE_INSENSITIVE = True
try:
MYLOGGING = CFG['logging']
except KeyError:
MYLOGGING = {}