Subject: bug#63082: [PATCH 08/17] services: mpd: Only rotate log when a log file is specified.

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 28 Apr 2023 10:27:01 -0400

This is to avoid adding a bogus log rotation job when syslog is used (which
already has its own log rotation job).

* gnu/services/audio.scm (mpd-log-rotation): Add conditional to avoid
producing a log-rotation object when no log-file was provided.
(mpd-shepherd-service): Do not manage log file parent directory creation.
Assume it already exists.  Adjust the rottlog-service-type extension.
---
 gnu/services/audio.scm | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index a1d1a3d2fe..cccf5c2693 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -554,12 +554,15 @@ (define (mpd-serialize-configuration configuration)
    (serialize-configuration configuration mpd-configuration-fields)))
 
 (define (mpd-log-rotation config)
-  (match-record config <mpd-configuration> (log-file)
-    (log-rotation
-     (files (list log-file))
-     (post-rotate #~(begin
-                      (use-modules (gnu services herd))
-                      (with-shepherd-action 'mpd ('reopen) #f))))))
+  (match-record config <mpd-configuration>
+    (log-file)
+    (if (maybe-value log-file)
+        (list (log-rotation
+               (files (list log-file))
+               (post-rotate #~(begin
+                                (use-modules (gnu services herd))
+                                (with-shepherd-action 'mpd ('reopen) #f)))))
+        '())))
 
 (define (mpd-shepherd-service config)
   (match-record config <mpd-configuration> (user package shepherd-requirement
@@ -635,7 +638,7 @@ (define mpd-service-type
           (service-extension account-service-type
                              mpd-accounts)
           (service-extension rottlog-service-type
-                             (compose list mpd-log-rotation))))
+                             mpd-log-rotation)))
    (default-value (mpd-configuration))))
 
 
-- 
2.39.2