guix-commits
[Top][All Lists]
Advanced

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

branch master updated: goggles-bot: Fix file switching for multiple chan


From: Ricardo Wurmus
Subject: branch master updated: goggles-bot: Fix file switching for multiple channels.
Date: Wed, 09 Nov 2022 05:37:50 -0500

This is an automated email from the git hooks/post-receive script.

rekado pushed a commit to branch master
in repository maintenance.

The following commit(s) were added to refs/heads/master by this push:
     new aa13fef  goggles-bot: Fix file switching for multiple channels.
aa13fef is described below

commit aa13fefc635302f48277cd1af41f2d0a8446a16c
Author: Ricardo Wurmus <rekado@elephly.net>
AuthorDate: Wed Nov 9 11:36:30 2022 +0100

    goggles-bot: Fix file switching for multiple channels.
    
    This was previously deployed but had not been committed.
    
    * hydra/goggles-bot.scm (log-to-file): Keep track of the last log day
    for each channel.
---
 hydra/goggles-bot.scm | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/hydra/goggles-bot.scm b/hydra/goggles-bot.scm
index 890df98..6973259 100755
--- a/hydra/goggles-bot.scm
+++ b/hydra/goggles-bot.scm
@@ -94,19 +94,24 @@ the current date as contained in TIME."
           (strftime "%F" (localtime (current-time)))))
 
 (define log-to-file
-  (let ((day #false)
+  (let ((days #false)
         (ports #false))
     (lambda (message)
       "Log MESSAGE to a file.  Create a new file for each day."
       (let ((channel (msg:parse-target message))
             (time (localtime (msg:time message)))
-            (port-for-channel (lambda (channel)
-                                (and ports (assoc-ref ports channel)))))
+            (day-for-channel
+             (lambda (channel)
+               (and days (assoc-ref days channel))))
+            (port-for-channel
+             (lambda (channel)
+               (and ports (assoc-ref ports channel)))))
         ;; Only log messages to known channels
         (when (member channel (%channels))
 
           ;; When the music's over turn out the lights
-          (let ((port (port-for-channel channel)))
+          (let ((port (port-for-channel channel))
+                (day (day-for-channel channel)))
             (when (or (not day)
                       (not port)
                       (< day (tm:mday time)))
@@ -118,7 +123,8 @@ the current date as contained in TIME."
               ;; channel->port alist.
               (let ((file (make-filename time channel)))
                 (mkdir-p (dirname file))
-                (set! day (tm:mday time))
+                (set! days
+                      (assoc-set! days channel (tm:mday time)))
                 (set! ports
                       (assoc-set! ports channel (open-file file "a"))))))
 



reply via email to

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