diff --git a/.dir-locals.el b/.dir-locals.el index 3f1d292a199..022a338217e 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -606,7 +606,6 @@ (eval . (put 'restic-backup-job 'scheme-indent-function 0)) (eval . (put 'rngd-configuration 'scheme-indent-function 0)) (eval . (put 'rootless-podman-configuration 'scheme-indent-function 0)) - (eval . (put 'rottlog-configuration 'scheme-indent-function 0)) (eval . (put 'rpcbind-configuration 'scheme-indent-function 0)) (eval . (put 'rshiny-configuration 'scheme-indent-function 0)) (eval . (put 'rspamd-configuration 'scheme-indent-function 0)) diff --git a/doc/guix.texi b/doc/guix.texi index 86b6aec2bbf..3fd2a139685 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -21476,7 +21476,6 @@ is also prefixed by a timestamp by GNU Shepherd. @node Log Rotation @subsection Log Rotation -@cindex rottlog @cindex log rotation @cindex logging Log files such as those found in @file{/var/log} tend to grow endlessly, @@ -21557,119 +21556,6 @@ Size in bytes below which a log file is @emph{not} rotated. @c %end of fragment -@subheading Rottlog - -An alternative log rotation service relying on GNU@tie{}Rot[t]log, a log -rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}), is also -provided. - -@quotation Warning -The Rottlog service presented here is deprecated in favor of -@code{log-rotation-service-type} (see above). The -@code{rottlog-service-type} variable and related tools will be removed -after 2025-06-15. -@end quotation - -The example below shows how to extend it with an additional -@dfn{rotation}, should you need to do that (usually, services that -produce log files already take care of that): - -@lisp -(use-modules (guix) (gnu)) -(use-service-modules admin) - -(define my-log-files - ;; Log files that I want to rotate. - '("/var/log/something.log" "/var/log/another.log")) - -(operating-system - ;; @dots{} - (services (cons (simple-service 'rotate-my-stuff - rottlog-service-type - (list (log-rotation - (frequency 'daily) - (files my-log-files)))) - %base-services))) -@end lisp - -@defvar rottlog-service-type -This is the type of the Rottlog service, whose value is a -@code{rottlog-configuration} object. - -Other services can extend this one with new @code{log-rotation} objects -(see below), thereby augmenting the set of files to be rotated. - -This service type can define mcron jobs (@pxref{Scheduled Job -Execution}) to run the rottlog service. -@end defvar - -@deftp {Data Type} rottlog-configuration -Data type representing the configuration of rottlog. - -@table @asis -@item @code{rottlog} (default: @code{rottlog}) -The Rottlog package to use. - -@item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")}) -The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,, -rottlog, GNU Rot[t]log Manual}). - -@item @code{rotations} (default: @code{%default-rotations}) -A list of @code{log-rotation} objects as defined below. - -@item @code{jobs} -This is a list of gexps where each gexp corresponds to an mcron job -specification (@pxref{Scheduled Job Execution}). -@end table -@end deftp - -@deftp {Data Type} log-rotation -Data type representing the rotation of a group of log files. - -Taking an example from the Rottlog manual (@pxref{Period Related File -Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be -defined like this: - -@lisp -(log-rotation - (frequency 'daily) - (files '("/var/log/apache/*")) - (options '("storedir apache-archives" - "rotate 6" - "notifempty" - "nocompress"))) -@end lisp - -The list of fields is as follows: - -@table @asis -@item @code{frequency} (default: @code{'weekly}) -The log rotation frequency, a symbol. - -@item @code{files} -The list of files or file glob patterns to rotate. - -@vindex %default-log-rotation-options -@item @code{options} (default: @code{%default-log-rotation-options}) -The list of rottlog options for this rotation (@pxref{Configuration -parameters,,, rottlog, GNU Rot[t]log Manual}). - -@item @code{post-rotate} (default: @code{#f}) -Either @code{#f} or a gexp to execute once the rotation has completed. -@end table -@end deftp - -@defvar %default-rotations -Specifies weekly rotation of @code{%rotated-files} and of -@file{/var/log/guix-daemon.log}. -@end defvar - -@defvar %rotated-files -The list of syslog-controlled files to be rotated. By default it is: -@code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \ -"/var/log/maillog")}. -@end defvar - Some log files just need to be deleted periodically once they are old, without any other criterion and without any archival step. This is the case of build logs stored by @command{guix-daemon} under diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm index 8f24950752f..20e4517c667 100644 --- a/gnu/services/admin.scm +++ b/gnu/services/admin.scm @@ -57,26 +57,6 @@ log-rotation-configuration-size-threshold log-rotation-service-type - %default-rotations - %rotated-files - - log-rotation - log-rotation? - log-rotation-frequency - log-rotation-files - log-rotation-options - log-rotation-post-rotate - %default-log-rotation-options - - rottlog-configuration - rottlog-configuration? - rottlog-configuration-rottlog - rottlog-configuration-rc-file - rottlog-configuration-rotations - rottlog-configuration-jobs - rottlog-service - rottlog-service-type - log-cleanup-service-type log-cleanup-configuration log-cleanup-configuration? @@ -218,149 +198,6 @@ log-rotation} to list files subject to log rotation.") log-files))))) (default-value (log-rotation-configuration)))) - -;;; -;;; Rottlog + mcron. -;;; - -(define-record-type* log-rotation make-log-rotation - log-rotation? - (files log-rotation-files) ;list of strings - (frequency log-rotation-frequency ;symbol - (default 'weekly)) - (post-rotate log-rotation-post-rotate ;#f | gexp - (default #f)) - (options log-rotation-options ;list of strings - (default %default-log-rotation-options))) - -(define %default-log-rotation-options - ;; Default log rotation options: append ".gz" to file names. - '("storefile @FILENAME.@COMP_EXT" - "notifempty")) - -(define %rotated-files - ;; Syslog files subject to rotation. - '("/var/log/messages" "/var/log/secure" "/var/log/debug" - "/var/log/maillog" "/var/log/mcron.log")) - -(define %default-rotations - (list (log-rotation ;syslog files - (files %rotated-files) - - (frequency 'weekly) - (options `(;; These files are worth keeping for a few weeks. - "rotate 16" - ;; Run post-rotate once per rotation - "sharedscripts" - - ,@%default-log-rotation-options)) - ;; Restart syslogd after rotation. - (post-rotate #~(let ((pid (call-with-input-file "/var/run/syslog.pid" - read))) - (kill pid SIGHUP)))) - (log-rotation - (files '("/var/log/guix-daemon.log")) - (options `("rotate 4" ;don't keep too many of them - ,@%default-log-rotation-options))))) - -(define (log-rotation->config rotation) - "Return a string-valued gexp representing the rottlog configuration snippet -for ROTATION." - (define post-rotate - (let ((post (log-rotation-post-rotate rotation))) - (and post - (program-file "rottlog-post-rotate.scm" post)))) - - #~(let ((post #$post-rotate)) - (string-append (string-join '#$(log-rotation-files rotation) ",") - " {" - #$(string-join (log-rotation-options rotation) - "\n " 'prefix) - (if post - (string-append "\n postrotate\n " post - "\n endscript\n") - "") - "\n}\n"))) - -(define (log-rotations->/etc-entries rotations) - "Return the list of /etc entries for ROTATIONS, a list of ." - (define (frequency-file frequency rotations) - (computed-file (string-append "rottlog." (symbol->string frequency)) - #~(call-with-output-file #$output - (lambda (port) - (for-each (lambda (str) - (display str port)) - (list #$@(map log-rotation->config - rotations))))))) - - (let* ((frequencies (delete-duplicates - (map log-rotation-frequency rotations))) - (table (fold (lambda (rotation table) - (vhash-consq (log-rotation-frequency rotation) - rotation table)) - vlist-null - rotations))) - (map (lambda (frequency) - `(,(symbol->string frequency) - ,(frequency-file frequency - (vhash-foldq* cons '() frequency table)))) - frequencies))) - -(define (default-jobs rottlog) - (list #~(job '(next-hour '(0)) ;midnight - #$(file-append rottlog "/sbin/rottlog")) - #~(job '(next-hour '(12)) ;noon - #$(file-append rottlog "/sbin/rottlog")))) - -(define-record-type* - rottlog-configuration make-rottlog-configuration - rottlog-configuration? - (rottlog rottlog-configuration-rottlog ;file-like - (default rottlog)) - (rc-file rottlog-configuration-rc-file ;file-like - (default (file-append rottlog "/etc/rc"))) - (rotations rottlog-configuration-rotations ;list of - (default %default-rotations)) - (jobs rottlog-configuration-jobs ;list of - (default #f))) - -(define (rottlog-etc config) - `(("rottlog" - ,(file-union "rottlog" - (cons `("rc" ,(rottlog-configuration-rc-file config)) - (log-rotations->/etc-entries - (rottlog-configuration-rotations config))))))) - -(define (rottlog-jobs-or-default config) - (or (rottlog-configuration-jobs config) - (default-jobs (rottlog-configuration-rottlog config)))) - -;; TODO: Deprecated; remove sometime after 2025-06-15. -(define-deprecated rottlog-service-type - log-rotation-service-type - (service-type - (name 'rottlog) - (description - "Periodically rotate log files using GNU@tie{}Rottlog and GNU@tie{}mcron. -Old log files are removed or compressed according to the configuration. - -This service is deprecated and slated for removal after 2025-06-15.") - (extensions (list (service-extension etc-service-type rottlog-etc) - (service-extension mcron-service-type - rottlog-jobs-or-default) - - ;; Add Rottlog to the global profile so users can access - ;; the documentation. - (service-extension profile-service-type - (compose list rottlog-configuration-rottlog)))) - (compose concatenate) - (extend (lambda (config rotations) - (rottlog-configuration - (inherit config) - (rotations (append (rottlog-configuration-rotations config) - rotations))))) - (default-value (rottlog-configuration)))) - ;;; ;;; Build log removal.