guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 01/02: timer: Add custom printer for the <timer> type.


From: Ludovic Courtès
Subject: [shepherd] 01/02: timer: Add custom printer for the <timer> type.
Date: Sat, 30 Mar 2024 17:56:57 -0400 (EDT)

civodul pushed a commit to branch devel
in repository shepherd.

commit cf48120c0ed3156236311c63a1b45a3e3c7148c8
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Mar 30 19:00:28 2024 +0100

    timer: Add custom printer for the <timer> type.
    
    Since this value is printed in the shepherd log, use a custom printer to
    avoid printing the Fibers channel.
    
    * modules/shepherd/service/timer.scm (print-timer): New procedure.
    <top level>: Call ‘set-record-type-printer!’.
---
 modules/shepherd/service/timer.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/shepherd/service/timer.scm 
b/modules/shepherd/service/timer.scm
index fa2e079..9abcebb 100644
--- a/modules/shepherd/service/timer.scm
+++ b/modules/shepherd/service/timer.scm
@@ -389,6 +389,15 @@ five minutes after midnight, every day;
   (event   timer-event)                           ;<calendar-event>
   (action  timer-action))                         ;<command> | procedure
 
+(define (print-timer timer port)
+  "Print @var{timer} to @var{port}, omitting its @code{channel} field for
+conciseness."
+  (format port "#<timer ~s ~s ~a>"
+          (timer-event timer) (timer-action timer)
+          (number->string (object-address timer) 16)))
+
+(set-record-type-printer! <timer> print-timer)
+
 ;; Command to be executed by a timer.
 (define-record-type <command>
   (%command arguments user group environment-variables directory



reply via email to

[Prev in Thread] Current Thread [Next in Thread]