logging enabled/disabled thru config
This commit is contained in:
@@ -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']
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -589,3 +589,8 @@ except KeyError: # pragma: no cover
|
||||
GEOIP_PATH = STATIC_ROOT
|
||||
|
||||
TAGGIT_CASE_INSENSITIVE = True
|
||||
|
||||
try:
|
||||
MYLOGGING = CFG['logging']
|
||||
except KeyError:
|
||||
MYLOGGING = {}
|
||||
|
||||
Reference in New Issue
Block a user