From 5def73177edd0ad70e678be6ad661d09c4ad3971 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 21 Aug 2019 22:05:37 +0100 Subject: [PATCH] Logging of posts --- posts.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/posts.py b/posts.py index 0aee15312..3f320db83 100644 --- a/posts.py +++ b/posts.py @@ -905,24 +905,23 @@ def threadSendPost(session,postJsonStr: str,federationList: [],\ postJsonString(session,postJsonStr,federationList, \ inboxUrl,signatureHeaderJson, \ "inbox:write",debug) + if postResult: + logStr='Success on try '+str(tries)+': '+postJsonStr + else: + logStr='Retry '+str(tries)+': '+postJsonStr + postLog.append(logStr) + # keep the length of the log finite + # Don't accumulate massive files on systems with limited resources + while len(postLog)>16: + postlog.pop(0) + # save the log file + postLogFilename=baseDir+'/post.log' + with open(postLogFilename, "a+") as logFile: + logFile.write(logStr+'\n') + if postResult: if debug: print('DEBUG: json post to '+inboxUrl+' succeeded') - if tries==0: - logStr=postJsonStr - else: - logStr='Try '+str(tries)+': '+postJsonStr - postLog.append(logStr) - # keep the length of the log finite - # Don't accumulate massive files on systems with limited resources - while len(postLog)>16: - postlog.pop(0) - # save the log file - postLogFilename=baseDir+'/post.log' - with open(postLogFilename, "a+") as logFile: - logFile.write(logStr+'\n') - # for line in postLog: - # print(line, file=logFile) # our work here is done break if debug: