1
0
Fork 0

Truncate status log after 100 lines

The Git history is sufficient for viewing past status messages.
Additionally, long status log files tend to take long to render. With
this commit, only the most recent 100 lines are kept, and this number
can be configured.
This commit is contained in:
Patrick Lühne 2017-11-20 18:56:37 +01:00
parent 1d27a3246c
commit 60128d03ef
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 5 additions and 2 deletions

5
benchmark.py Executable file → Normal file
View File

@ -151,12 +151,13 @@ def writeStatus(message, config):
if os.path.exists(statusFilename):
with open(statusFilename, "r") as statusFile:
content = statusFile.read()
# add the previous status messages, but trancate them
content = statusFile.readlines()[0:(config["storage"]["statusLogSize"] - 1)]
else:
content = ""
with open(statusFilename, "w") as statusFile:
print(time.strftime("%Y-%m-%d %H:%M:%S %z") + "\t" + message + "\n" + content, file = statusFile, end = "")
print(time.strftime("%Y-%m-%d %H:%M:%S %z") + "\t" + message + "\n" + "".join(content), file = statusFile, end = "")
git(["add", "status.log"], dataDir)
git(["commit", "-m Update status: " + message], dataDir)

View File

@ -14,6 +14,8 @@ storage:
results: results
config: config
status: status
# the maximum size of the status log in lines
statusLogSize: 100
executables:
timeout: