guix-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Ludovic Courtès
Date: Tue, 9 May 2023 10:28:17 -0400 (EDT)

branch: master
commit 830e2f29014604d1925bd4eb4be1660511081344
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue May 9 14:02:16 2023 +0200

    logging: Do not include a timestamp by default.
    
    The timestamp was redundant with that added by shepherd.
    
    * src/cuirass/logging.scm (current-logging-procedure): Change default
    value to not include a timestamp unless writing to a tty.
---
 src/cuirass/logging.scm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/cuirass/logging.scm b/src/cuirass/logging.scm
index f4425ed..b7ce322 100644
--- a/src/cuirass/logging.scm
+++ b/src/cuirass/logging.scm
@@ -1,5 +1,5 @@
 ;;; logging.scm -- Event logging.
-;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018, 2023 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of Cuirass.
 ;;;
@@ -48,8 +48,14 @@
 
 (define current-logging-procedure
   ;; The logging procedure.  This could be 'syslog', for instance.
-  (make-parameter (lambda (str)
-                    (log-to-port (current-logging-port) str))))
+  (make-parameter (if (isatty? (current-logging-port))
+                      (lambda (str)
+                        (log-to-port (current-logging-port) str))
+                      (lambda (str)
+                        ;; Most likely we're writing to some log file handled
+                        ;; by shepherd or similar, so no need to add a
+                        ;; timestamp.
+                        (format (current-logging-port) "~a~%" str)))))
 
 (define (log-message fmt level . args)
   "Log the given message as one line."



reply via email to

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