GNU bug report logs -
#62169
[PATCH 0/3] services: mcron: Make log-file and date-format configurable.
Previous Next
Reported by: Bruno Victal <mirai <at> makinata.eu>
Date: Mon, 13 Mar 2023 19:20:02 UTC
Severity: normal
Tags: patch
Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62169 in the body.
You can then email your comments to 62169 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#62169
; Package
guix-patches
.
(Mon, 13 Mar 2023 19:20:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Bruno Victal <mirai <at> makinata.eu>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Mon, 13 Mar 2023 19:20:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Tested with 'make check-system TESTS=mcron'.
Bruno Victal (3):
services: mcron: Restyle mcron-configuration.
services: mcron: Use match-record.
services: mcron: Add log-file and date-format fields.
doc/guix.texi | 8 +++-
gnu/services/mcron.scm | 104 +++++++++++++++++++++++++----------------
2 files changed, 71 insertions(+), 41 deletions(-)
--
2.39.1
Information forwarded
to
guix-patches <at> gnu.org
:
bug#62169
; Package
guix-patches
.
(Mon, 13 Mar 2023 19:31:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 62169 <at> debbugs.gnu.org (full text, mbox):
* gnu/services/mcron.scm (mcron-shepherd-services): Use match-record.
---
gnu/services/mcron.scm | 68 ++++++++++++++++++++----------------------
1 file changed, 33 insertions(+), 35 deletions(-)
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 6ee333f253..9f3afecf62 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -143,41 +143,39 @@ (define (shepherd-schedule-action mcron files)
(display line)
(loop)))))))))
-(define mcron-shepherd-services
- (match-lambda
- (($ <mcron-configuration> mcron ()) ;nothing to do!
- '())
- (($ <mcron-configuration> mcron jobs log? log-format)
- (let ((files (job-files mcron jobs)))
- (list (shepherd-service
- (provision '(mcron))
- (requirement '(user-processes))
- (modules `((srfi srfi-1)
- (srfi srfi-26)
- (ice-9 popen) ;for the 'schedule' action
- (ice-9 rdelim)
- (ice-9 match)
- ,@%default-modules))
- (start #~(make-forkexec-constructor
- (list (string-append #$mcron "/bin/mcron")
- #$@(if log?
- #~("--log" "--log-format" #$log-format)
- #~())
- #$@files)
-
- ;; Disable auto-compilation of the job files and set a
- ;; sane value for 'PATH'.
- #:environment-variables
- (cons* "GUILE_AUTO_COMPILE=0"
- "PATH=/run/current-system/profile/bin"
- (remove (cut string-prefix? "PATH=" <>)
- (environ)))
-
- #:log-file "/var/log/mcron.log"))
- (stop #~(make-kill-destructor))
-
- (actions
- (list (shepherd-schedule-action mcron files)))))))))
+(define (mcron-shepherd-services config)
+ (match-record config <mcron-configuration> (mcron jobs log? log-format)
+ (if (eq? jobs '())
+ '() ; nothing to do
+ (let ((files (job-files mcron jobs)))
+ (list (shepherd-service
+ (provision '(mcron))
+ (requirement '(user-processes))
+ (modules `((srfi srfi-1)
+ (srfi srfi-26)
+ (ice-9 popen) ;for the 'schedule' action
+ (ice-9 rdelim)
+ (ice-9 match)
+ ,@%default-modules))
+ (start #~(make-forkexec-constructor
+ (list (string-append #$mcron "/bin/mcron")
+ #$@(if log?
+ #~("--log" "--log-format" #$log-format)
+ #~())
+ #$@files)
+
+ ;; Disable auto-compilation of the job files and
+ ;; set a sane value for 'PATH'.
+ #:environment-variables
+ (cons* "GUILE_AUTO_COMPILE=0"
+ "PATH=/run/current-system/profile/bin"
+ (remove (cut string-prefix? "PATH=" <>)
+ (environ)))
+
+ #:log-file "/var/log/mcron.log"))
+ (stop #~(make-kill-destructor))
+ (actions
+ (list (shepherd-schedule-action mcron files)))))))))
(define mcron-service-type
(service-type (name 'mcron)
--
2.39.1
Information forwarded
to
guix-patches <at> gnu.org
:
bug#62169
; Package
guix-patches
.
(Mon, 13 Mar 2023 19:31:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 62169 <at> debbugs.gnu.org (full text, mbox):
* doc/guix.texi (Scheduled Job Execution): Sync doc with source.
* gnu/services/mcron.scm (mcron-configuration): Restyle.
[log-format]: Fix incorrectly formatted text.
---
doc/guix.texi | 2 +-
gnu/services/mcron.scm | 15 +++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 39932d5aad..45d96b8fbb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -19349,7 +19349,7 @@ Scheduled Job Execution
@item @code{log-format} (default: @code{"~1@@*~a ~a: ~a~%"}) (type: string)
@code{(ice-9 format)} format string for log messages. The default value
-produces messages like "@samp{@var{pid} @var{name}: @var{message}"}
+produces messages like @samp{@var{pid} @var{name}: @var{message}}
(@pxref{Invoking mcron, Invoking,, mcron,GNU <at> tie{}mcron}). Each message
is also prefixed by a timestamp by GNU Shepherd.
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 52332d6123..6ee333f253 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -56,18 +56,25 @@ (define list-of-gexps?
(list-of gexp?))
(define-configuration/no-serialization mcron-configuration
- (mcron (file-like mcron) "The mcron package to use.")
+ (mcron
+ (file-like mcron)
+ "The mcron package to use.")
+
(jobs
(list-of-gexps '())
"This is a list of gexps (@pxref{G-Expressions}), where each gexp
corresponds to an mcron job specification (@pxref{Syntax, mcron job
specifications,, mcron, GNU <at> tie{}mcron}).")
- (log? (boolean #t) "Log messages to standard output.")
+
+ (log?
+ (boolean #t)
+ "Log messages to standard output.")
+
(log-format
(string "~1@*~a ~a: ~a~%")
"@code{(ice-9 format)} format string for log messages. The default value
-produces messages like \"@samp{@var{pid} @var{name}:
-@var{message}\"} (@pxref{Invoking mcron, Invoking,, mcron, GNU <at> tie{}mcron}).
+produces messages like @samp{@var{pid} @var{name}: @var{message}}
+(@pxref{Invoking mcron, Invoking,, mcron, GNU <at> tie{}mcron}).
Each message is also prefixed by a timestamp by GNU Shepherd."))
(define (job-files mcron jobs)
--
2.39.1
Information forwarded
to
guix-patches <at> gnu.org
:
bug#62169
; Package
guix-patches
.
(Mon, 13 Mar 2023 19:32:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 62169 <at> debbugs.gnu.org (full text, mbox):
* doc/guix.texi (Scheduled Job Execution): Document it.
* gnu/services/mcron.scm (mcron-configuration)[log-file, date-format]: New field.
(mcron-shepherd-services): Add log-file and date-format support.
Use file-append instead of string-append.
---
doc/guix.texi | 6 ++++++
gnu/services/mcron.scm | 31 +++++++++++++++++++++++++------
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 45d96b8fbb..6d47d36d22 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -19347,12 +19347,18 @@ Scheduled Job Execution
@item @code{log?} (default: @code{#t}) (type: boolean)
Log messages to standard output.
+@item @code{log-file} (default: @code{"/var/log/mcron.log"}) (type: string)
+Log file location.
+
@item @code{log-format} (default: @code{"~1@@*~a ~a: ~a~%"}) (type: string)
@code{(ice-9 format)} format string for log messages. The default value
produces messages like @samp{@var{pid} @var{name}: @var{message}}
(@pxref{Invoking mcron, Invoking,, mcron,GNU <at> tie{}mcron}). Each message
is also prefixed by a timestamp by GNU Shepherd.
+@item @code{date-format} (type: maybe-string)
+@code{(srfi srfi-19)} format string for date.
+
@end table
@end deftp
@c %end of fragment
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 9f3afecf62..dac213358c 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2023 Bruno Victal <mirai <at> makinata.eu>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -33,7 +34,9 @@ (define-module (gnu services mcron)
mcron-configuration-mcron
mcron-configuration-jobs
mcron-configuration-log?
+ mcron-configuration-log-file
mcron-configuration-log-format
+ mcron-configuration-date-format
mcron-service-type))
@@ -55,6 +58,8 @@ (define-module (gnu services mcron)
(define list-of-gexps?
(list-of gexp?))
+(define-maybe/no-serialization string)
+
(define-configuration/no-serialization mcron-configuration
(mcron
(file-like mcron)
@@ -70,12 +75,20 @@ (define-configuration/no-serialization mcron-configuration
(boolean #t)
"Log messages to standard output.")
+ (log-file
+ (string "/var/log/mcron.log")
+ "Log file location.")
+
(log-format
(string "~1@*~a ~a: ~a~%")
"@code{(ice-9 format)} format string for log messages. The default value
produces messages like @samp{@var{pid} @var{name}: @var{message}}
(@pxref{Invoking mcron, Invoking,, mcron, GNU <at> tie{}mcron}).
-Each message is also prefixed by a timestamp by GNU Shepherd."))
+Each message is also prefixed by a timestamp by GNU Shepherd.")
+
+ (date-format
+ maybe-string
+ "@code{(srfi srfi-19)} format string for date."))
(define (job-files mcron jobs)
"Return a list of file-like object for JOBS, a list of gexps."
@@ -144,7 +157,9 @@ (define (shepherd-schedule-action mcron files)
(loop)))))))))
(define (mcron-shepherd-services config)
- (match-record config <mcron-configuration> (mcron jobs log? log-format)
+ (match-record config <mcron-configuration> (mcron jobs
+ log? log-file log-format
+ date-format)
(if (eq? jobs '())
'() ; nothing to do
(let ((files (job-files mcron jobs)))
@@ -158,10 +173,14 @@ (define (mcron-shepherd-services config)
(ice-9 match)
,@%default-modules))
(start #~(make-forkexec-constructor
- (list (string-append #$mcron "/bin/mcron")
+ (list #$(file-append mcron "/bin/mcron")
#$@(if log?
- #~("--log" "--log-format" #$log-format)
- #~())
+ `("--log" "--log-format" ,log-format
+ ,@(if (maybe-value-set? date-format)
+ (list "--date-format"
+ date-format)
+ '()))
+ '())
#$@files)
;; Disable auto-compilation of the job files and
@@ -172,7 +191,7 @@ (define (mcron-shepherd-services config)
(remove (cut string-prefix? "PATH=" <>)
(environ)))
- #:log-file "/var/log/mcron.log"))
+ #:log-file #$log-file))
(stop #~(make-kill-destructor))
(actions
(list (shepherd-schedule-action mcron files)))))))))
--
2.39.1
Information forwarded
to
guix-patches <at> gnu.org
:
bug#62169
; Package
guix-patches
.
(Tue, 21 Mar 2023 18:46:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 62169 <at> debbugs.gnu.org (full text, mbox):
Hello,
Bruno Victal <mirai <at> makinata.eu> writes:
> * doc/guix.texi (Scheduled Job Execution): Document it.
> * gnu/services/mcron.scm (mcron-configuration)[log-file, date-format]: New field.
> (mcron-shepherd-services): Add log-file and date-format support.
> Use file-append instead of string-append.
I've installed the first 2 patches, but was wondering about the use case
for having a configurable log-file for mcron? It seems it'd be very
niche to me, so perhaps it's not necessary?
--
Thanks,
Maxim
Reply sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
You have taken responsibility.
(Tue, 21 Mar 2023 18:52:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Bruno Victal <mirai <at> makinata.eu>
:
bug acknowledged by developer.
(Tue, 21 Mar 2023 18:52:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 62169-done <at> debbugs.gnu.org (full text, mbox):
Hello,
Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:
> Hello,
>
> Bruno Victal <mirai <at> makinata.eu> writes:
>
>> * doc/guix.texi (Scheduled Job Execution): Document it.
>> * gnu/services/mcron.scm (mcron-configuration)[log-file, date-format]: New field.
>> (mcron-shepherd-services): Add log-file and date-format support.
>> Use file-append instead of string-append.
>
> I've installed the first 2 patches, but was wondering about the use case
> for having a configurable log-file for mcron? It seems it'd be very
> niche to me, so perhaps it's not necessary?
Thanks for confirming the use case on #guix (see:
https://logs.guix.gnu.org/guix/2023-03-21.log#194137).
Installed that one as well.
--
Thanks,
Maxim
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 19 Apr 2023 11:24:18 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 24 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.