[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 02/08: herd: Display service log file when it is known.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 02/08: herd: Display service log file when it is known. |
Date: |
Sat, 17 Feb 2024 13:07:18 -0500 (EST) |
civodul pushed a commit to branch devel
in repository shepherd.
commit 6bfb21ea999d1b9d448180f94769bd041e53609f
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Feb 17 15:08:39 2024 +0100
herd: Display service log file when it is known.
* modules/shepherd/scripts/herd.scm (<live-service>)[log-file]: New field.
(display-service-status): Print ‘live-service-log-file’ when it is true.
* tests/logging.sh: Test it.
---
modules/shepherd/scripts/herd.scm | 15 ++++++++++-----
tests/logging.sh | 5 ++++-
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/modules/shepherd/scripts/herd.scm
b/modules/shepherd/scripts/herd.scm
index 1c4df1f..1e3b8cc 100644
--- a/modules/shepherd/scripts/herd.scm
+++ b/modules/shepherd/scripts/herd.scm
@@ -1,5 +1,5 @@
;; herd.scm -- The program to herd the Shepherd.
-;; Copyright (C) 2013-2014, 2016, 2018-2019, 2021-2023 Ludovic Courtès
<ludo@gnu.org>
+;; Copyright (C) 2013-2014, 2016, 2018-2019, 2021-2024 Ludovic Courtès
<ludo@gnu.org>
;; Copyright (C) 2002, 2003 Wolfgang Jährling <wolfgang@pro-linux.de>
;;
;; This file is part of the GNU Shepherd.
@@ -39,7 +39,7 @@
(live-service provision requirement one-shot? transient? respawn?
enabled? status running
status-changes last-respawns startup-failures
- recent-messages)
+ recent-messages log-file)
live-service?
(provision live-service-provision) ;list of symbols
(requirement live-service-requirement) ;list of symbols
@@ -53,7 +53,8 @@
(status-changes live-service-status-changes) ;symbol/integer pairs
(last-respawns live-service-last-respawns) ;list of integers
(startup-failures live-service-startup-failures) ;list of integers
- (recent-messages live-service-recent-messages)) ;list of strings
+ (recent-messages live-service-recent-messages) ;list of strings
+ (log-file live-service-log-file)) ;#f | string
(define (live-service-canonical-name service)
"Return the 'canonical name' of @var{service}."
@@ -99,7 +100,7 @@ into a @code{live-service} record."
(('service ('version 0 _ ...) properties ...)
(alist-let* properties (provides requires status running respawn? enabled?
status-changes last-respawns startup-failures
- recent-messages
+ recent-messages log-file
one-shot? transient?)
(live-service provides requires one-shot?
transient? respawn?
@@ -110,7 +111,8 @@ into a @code{live-service} record."
(or status-changes '())
(or last-respawns '())
(or startup-failures '())
- (or recent-messages '()))))))
+ (or recent-messages '())
+ log-file)))))
(define (highlight-if-long-transient-status service)
"Return a procedure to highlight @var{service} if it's been stuck in a
@@ -327,6 +329,9 @@ relevant bits quoted according to POSIX shell rules."
(format #t (highlight/error (l10n " Failed to start at ~a.~%"))
(time->string time)))
(_ #t)))
+ (when (live-service-log-file service)
+ (format #t (l10n " Log file: ~a.~%")
+ (live-service-log-file service)))
(when show-recent-messages?
(match (live-service-recent-messages service)
diff --git a/tests/logging.sh b/tests/logging.sh
index 742bfa8..b900c30 100644
--- a/tests/logging.sh
+++ b/tests/logging.sh
@@ -1,5 +1,5 @@
# GNU Shepherd --- Test the logging capabilities of
'make-forkexec-constructor'.
-# Copyright © 2022, 2023 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2022-2024 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of the GNU Shepherd.
#
@@ -86,6 +86,8 @@ do
grep -E '^2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}
'"$message" "$service_log"
done
+$herd status test-file-logging | grep "Log file: $PWD/$service_log"
+
$herd status test-file-logging | \
grep -E '^ 2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}
STARTING'
$herd status test-file-logging | \
@@ -119,6 +121,7 @@ do
grep -E '^2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}
.*'"$message" "$log"
done
+$herd status test-builtin-logging | grep -v "Log file"
$herd status test-builtin-logging | \
grep -E '^ 2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}
STARTING'
$herd status test-builtin-logging | \
- [shepherd] branch devel updated (03e18f1 -> 5c87fef), Ludovic Courtès, 2024/02/17
- [shepherd] 01/08: service: Add ‘service-log-file’., Ludovic Courtès, 2024/02/17
- [shepherd] 02/08: herd: Display service log file when it is known.,
Ludovic Courtès <=
- [shepherd] 06/08: herd: Display information about inetd services., Ludovic Courtès, 2024/02/17
- [shepherd] 03/08: service: ‘make-inetd-forkexec-constructor’ returns a <process>., Ludovic Courtès, 2024/02/17
- [shepherd] 04/08: support: Add ‘socket-address->string’., Ludovic Courtès, 2024/02/17
- [shepherd] 05/08: service: Define <inetd-service> and serialize it., Ludovic Courtès, 2024/02/17
- [shepherd] 07/08: service: Define <systemd-service> and serialize it., Ludovic Courtès, 2024/02/17
- [shepherd] 08/08: herd: Display information about systemd services., Ludovic Courtès, 2024/02/17