From 60128d03ef41cbc714b816948b9a89aa2cafa5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 20 Nov 2017 18:56:37 +0100 Subject: [PATCH] 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. --- benchmark.py | 5 +++-- config.example.yaml | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) mode change 100755 => 100644 benchmark.py diff --git a/benchmark.py b/benchmark.py old mode 100755 new mode 100644 index 0f571455e..e969c1f2e --- a/benchmark.py +++ b/benchmark.py @@ -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) diff --git a/config.example.yaml b/config.example.yaml index 8ca26eb32..14fadc4d3 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -14,6 +14,8 @@ storage: results: results config: config status: status + # the maximum size of the status log in lines + statusLogSize: 100 executables: timeout: