From 0211db1e0875957fe2290048df8caa34d138af75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Zolt=C3=A1n?= Date: Sun, 15 Jun 2025 12:39:42 +0200 Subject: [PATCH] 110-startlogs.sh: better continuation of existing log file (even if empty). --- .metadata | Bin 15730 -> 15730 bytes tools/startup.d/110-startlogs.sh | 7 +++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.metadata b/.metadata index ef2f238b264c51058d4a699ae8d619bd2f154b6f..620bc318ce52cae5dc82f2e32ea4bd525363284c 100644 GIT binary patch delta 59 zcmexV^{Hw@GaJv>7LyDHAh;jCOnLG|G11BU`NbyNNw80zz{0WlB- # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # +# 2025-06-01 v0.4 +# fix: better continuation of existing log file (even if empty). # 2025-03-29 v0.3 # mod: no longer repeats existing log lines. # 2025-02-26 v0.2 @@ -103,10 +105,11 @@ else [[ -n "$logline" ]] \ && timestamp="$(echo "$logline" | "$CUT" -d' ' -f1 2>/dev/null)" \ || timestamp="invalid" - # Checks the validity. + # If the log does not contain a valid last timestamp, we write log lines + # created since the last time the container was started. [[ $("$DATE" -d "$timestamp" >/dev/null 2>&1; echo $?) -eq 0 ]] \ && since="$timestamp" \ - || since="1970-01-01T00:00Z" + || since="$("$DOCKER" inspect -f '{{ .State.StartedAt }}' $container)" # Only logs the new lines (actually repeats the last one - TODO!). "$DOCKER" logs -t --since "$since" -f $container >> "$BASE_DIR/$LOGDIR/$service.log" 2>&1 & fi