civodul pushed a commit to branch devel
in repository shepherd.
commit 6ad9aab13ab36d33624ec34b9952acadac19672e
Author: Ludovic Courtès <[email protected]>
AuthorDate: Sat Oct 12 14:41:07 2024 +0200
logger: Built-in logger no longer produces double timestamp.
Fixes a regression introduced in
a2825cf0d08e73a60bfdcca390118e205c3ff462 whereby the built-in logger
would introduce an additional timestamp in shepherd’s log file:
2024-10-12 12:25:49 2024-10-12 12:25:49 [sh] STARTING
* modules/shepherd/logger.scm (service-builtin-logger): Remove ‘prefix’
when writing to (log-output-port).
* tests/logging.sh: Look for exact matches in $log for
‘test-builtin-logging’.
---
modules/shepherd/logger.scm | 10 ++++------
tests/logging.sh | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/modules/shepherd/logger.scm b/modules/shepherd/logger.scm
index 3d15d62..39f05ae 100644
--- a/modules/shepherd/logger.scm
+++ b/modules/shepherd/logger.scm
@@ -296,14 +296,12 @@ to @var{history-size} lines in memory."
(process-id process))
(value
value)))))
- (now (current-time))
- (prefix (strftime (%current-logfile-date-format)
- (localtime now))))
+ (now (current-time)))
(if (integer? pid)
- (simple-format (log-output-port) "~a~a[~a] "
- prefix command pid)
(simple-format (log-output-port) "~a[~a] "
- prefix command))
+ command pid)
+ (simple-format (log-output-port) "[~a] "
+ command))
(put-string (log-output-port) line)
(newline (log-output-port))
(loop pid
diff --git a/tests/logging.sh b/tests/logging.sh
index 3057681..ca959b1 100644
--- a/tests/logging.sh
+++ b/tests/logging.sh
@@ -125,7 +125,7 @@ rm -f "$service_pid"
$herd start test-builtin-logging
for message in "STARTING" "STARTED" "café" "latin1 garbage: .* alors"
do
- grep -E '^2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}
.*'"$message" "$log"
+ grep -E '^2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}
\['"$(basename $SHELL)"'\] '"$message" "$log"
done
$herd status test-builtin-logging | grep -v "Log file"