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:
parent
1d27a3246c
commit
60128d03ef
5
benchmark.py
Executable file → Normal file
5
benchmark.py
Executable file → Normal file
@ -151,12 +151,13 @@ def writeStatus(message, config):
|
|||||||
|
|
||||||
if os.path.exists(statusFilename):
|
if os.path.exists(statusFilename):
|
||||||
with open(statusFilename, "r") as statusFile:
|
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:
|
else:
|
||||||
content = ""
|
content = ""
|
||||||
|
|
||||||
with open(statusFilename, "w") as statusFile:
|
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(["add", "status.log"], dataDir)
|
||||||
git(["commit", "-m Update status: " + message], dataDir)
|
git(["commit", "-m Update status: " + message], dataDir)
|
||||||
|
@ -14,6 +14,8 @@ storage:
|
|||||||
results: results
|
results: results
|
||||||
config: config
|
config: config
|
||||||
status: status
|
status: status
|
||||||
|
# the maximum size of the status log in lines
|
||||||
|
statusLogSize: 100
|
||||||
|
|
||||||
executables:
|
executables:
|
||||||
timeout:
|
timeout:
|
||||||
|
Loading…
Reference in New Issue
Block a user