logging enabled/disabled thru config
This commit is contained in:
@@ -3120,9 +3120,7 @@ def df_from_summary(data):
|
|||||||
@app.task
|
@app.task
|
||||||
def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec, defaulttimezone, debug=False, **kwargs):
|
def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec, defaulttimezone, debug=False, **kwargs):
|
||||||
time.sleep(delaysec)
|
time.sleep(delaysec)
|
||||||
with open("c2_auto_import.log", "a") as errorlog:
|
dologging('c2_import.log',str(c2id)+' for userid '+str(userid))
|
||||||
timestr = time.strftime("%Y%m%d-%H%M%S")
|
|
||||||
errorlog.write(timestr+' '+str(c2id)+' for userid '+str(userid)+'\r\n')
|
|
||||||
data = alldata[c2id]
|
data = alldata[c2id]
|
||||||
splitdata = None
|
splitdata = None
|
||||||
|
|
||||||
@@ -3146,8 +3144,8 @@ def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec, defaulttim
|
|||||||
has_strokedata = True
|
has_strokedata = True
|
||||||
|
|
||||||
s = 'User {userid}, C2 ID {c2id}'.format(userid=userid, c2id=c2id)
|
s = 'User {userid}, C2 ID {c2id}'.format(userid=userid, c2id=c2id)
|
||||||
dologging('debuglog.log', s)
|
dologging('c2_import.log', s)
|
||||||
dologging('debuglog.log', json.dumps(data))
|
dologging('c2_import.log', json.dumps(data))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
title = data['name']
|
title = data['name']
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import iso8601
|
|||||||
from iso8601 import ParseError
|
from iso8601 import ParseError
|
||||||
import arrow
|
import arrow
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
lbstoN = 4.44822
|
lbstoN = 4.44822
|
||||||
|
|
||||||
landingpages = (
|
landingpages = (
|
||||||
@@ -120,6 +122,11 @@ info_calls = [
|
|||||||
|
|
||||||
|
|
||||||
def dologging(filename, s):
|
def dologging(filename, s):
|
||||||
|
do_logging = settings.MYLOGGING.get(filename,True)
|
||||||
|
|
||||||
|
if not do_logging:
|
||||||
|
return
|
||||||
|
|
||||||
tstamp = time.localtime()
|
tstamp = time.localtime()
|
||||||
timestamp = time.strftime('%b-%d-%Y %H:%M:%S', tstamp)
|
timestamp = time.strftime('%b-%d-%Y %H:%M:%S', tstamp)
|
||||||
with open(filename, 'a') as f:
|
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)
|
rower = getrequestrower(request, userid=userid)
|
||||||
if rower.user != request.user:
|
if rower.user != request.user:
|
||||||
messages.error(
|
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={
|
url = reverse('workout_c2import_view', kwargs={
|
||||||
'userid': request.user.id})
|
'userid': request.user.id})
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|||||||
@@ -589,3 +589,8 @@ except KeyError: # pragma: no cover
|
|||||||
GEOIP_PATH = STATIC_ROOT
|
GEOIP_PATH = STATIC_ROOT
|
||||||
|
|
||||||
TAGGIT_CASE_INSENSITIVE = True
|
TAGGIT_CASE_INSENSITIVE = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
MYLOGGING = CFG['logging']
|
||||||
|
except KeyError:
|
||||||
|
MYLOGGING = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user