From 243ad178cbaae9524a0c29672c285999db4e2c8b Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 24 Oct 2024 17:24:25 +0100 Subject: Add sanitizer for log-level configuration field. * genenetwork/services/genenetwork.scm: Import (guix diagnostics) and (guix i18n). (sanitize-log-level): New function. ()[log-level]: Use sanitize-log-level as the sanitizer. ()[log-level]: Use sanitize-log-level as the sanitizer. --- genenetwork/services/genenetwork.scm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/genenetwork/services/genenetwork.scm b/genenetwork/services/genenetwork.scm index ef59701..022eeda 100644 --- a/genenetwork/services/genenetwork.scm +++ b/genenetwork/services/genenetwork.scm @@ -30,7 +30,9 @@ #:use-module (gnu system file-systems) #:use-module (gnu system shadow) #:use-module (guix build python-build-system) + #:use-module (guix diagnostics) #:use-module (guix gexp) + #:use-module (guix i18n) #:use-module (guix packages) #:use-module (guix profiles) #:use-module (guix records) @@ -104,7 +106,8 @@ (gn-auth-secrets genenetwork-configuration-gn-auth-secrets (default "/etc/genenetwork")) (log-level genenetwork-configuration-log-level - (default 'warning))) + (default 'warning) + (sanitize sanitize-log-level))) (define-record-type* gn-uploader-configuration make-gn-uploader-configuration @@ -126,7 +129,15 @@ (gn2-server-url gn-uploader-configuration-gn2-server-url (default "https://genenetwork.org")) (log-level gn-uploader-configuration-log-level - (default 'warning))) + (default 'warning) + (sanitize sanitize-log-level))) + +(define (sanitize-log-level log-level) + (case log-level + ((fatal error warning info debug trace) log-level) + (else + (leave (G_ "Log level ~a is invalid. It must be one of the following symbols---fatal, error, warn, info, debug or trace.~%") + log-level)))) (define %genenetwork-accounts (list (user-group -- cgit v1.2.3