Log posts

master
Bob Mottram 2019-08-21 21:23:20 +01:00
parent bb7b15f69f
commit 3e1eaf035b
1 changed files with 12 additions and 7 deletions

View File

@ -908,17 +908,21 @@ def threadSendPost(session,postJsonStr: str,federationList: [],\
if postResult: if postResult:
if debug: if debug:
print('DEBUG: json post to '+inboxUrl+' succeeded') print('DEBUG: json post to '+inboxUrl+' succeeded')
#if postJsonObject.get('published'): if tries==0:
# postLog.append(postJsonObject['published']+' '+postResult+'\n') logStr=postJsonStr
else:
logStr='Try '+str(tries)+': '+postJsonStr
postLog.append(logStr)
# keep the length of the log finite # keep the length of the log finite
# Don't accumulate massive files on systems with limited resources # Don't accumulate massive files on systems with limited resources
while len(postLog)>64: while len(postLog)>16:
postlog.pop(0) postlog.pop(0)
# save the log file # save the log file
filename=baseDir+'/post.log' postLogFilename=baseDir+'/post.log'
with open(filename, "w") as logFile: with open(postLogFilename, "a+") as logFile:
for line in postLog: logFile.write(logStr+'\n')
print(line, file=logFile) # for line in postLog:
# print(line, file=logFile)
# our work here is done # our work here is done
break break
if debug: if debug:
@ -927,6 +931,7 @@ def threadSendPost(session,postJsonStr: str,federationList: [],\
str(backoffTime)+' seconds.') str(backoffTime)+' seconds.')
time.sleep(backoffTime) time.sleep(backoffTime)
backoffTime *= 2 backoffTime *= 2
tries+=1
def sendPost(projectVersion: str, \ def sendPost(projectVersion: str, \
session,baseDir: str,nickname: str, domain: str, port: int, \ session,baseDir: str,nickname: str, domain: str, port: int, \