From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 27 14:51:20 2023 Received: (at submit) by debbugs.gnu.org; 27 Mar 2023 18:51:20 +0000 Received: from localhost ([127.0.0.1]:48455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgrw7-00085c-SY for submit@debbugs.gnu.org; Mon, 27 Mar 2023 14:51:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:37438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgrw6-00085V-Jl for submit@debbugs.gnu.org; Mon, 27 Mar 2023 14:51:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgrw6-0000kG-8x for guix-patches@gnu.org; Mon, 27 Mar 2023 14:51:18 -0400 Received: from smtpmciv3.myservices.hosting ([185.26.107.239]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgrw2-0004Gb-RY for guix-patches@gnu.org; Mon, 27 Mar 2023 14:51:17 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv3.myservices.hosting (Postfix) with ESMTP id AC39120524 for ; Mon, 27 Mar 2023 20:51:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 6172280097; Mon, 27 Mar 2023 20:51:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id bKrElYoFxH99; Mon, 27 Mar 2023 20:51:11 +0200 (CEST) Received: from guix-nuc.home.arpa (bl9-119-177.dsl.telepac.pt [85.242.119.177]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id D5E8680079; Mon, 27 Mar 2023 20:51:10 +0200 (CEST) From: Bruno Victal To: guix-patches@gnu.org Subject: [PATCH] services: nginx: Make logging level configurable. Date: Mon, 27 Mar 2023 19:51:04 +0100 Message-Id: X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Debbugs-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, mail@cbaines.net Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.26.107.239; envelope-from=mirai@makinata.eu; helo=smtpmciv3.myservices.hosting X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Bruno Victal X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * gnu/services/web.scm ()[log-level]: New field. (assert-valid-log-level): New procedure. (default-nginx-config): Make log-level configurable. * doc/guix.texi (Web Services): Document it. --- Note: Hardcoding this value to 'info is extremely bad for flash endurance, and results in very large logs. doc/guix.texi | 5 +++++ gnu/services/web.scm | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index c49e51b72e..8df3c285ad 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -29838,6 +29838,11 @@ Web Services @item @code{log-directory} (default: @code{"/var/log/nginx"}) The directory to which NGinx will write log files. +@item @code{log-level} (default: @code{'error}) (type: symbol) +Logging level, which can be any of the following values: @code{'debug}, +@code{'info}, @code{'notice}, @code{'warn}, @code{'error}, @code{'crit}, +@code{'alert}, or @code{'emerg}. + @item @code{run-directory} (default: @code{"/var/run/nginx"}) The directory in which NGinx will create a pid file, and write temporary files. diff --git a/gnu/services/web.scm b/gnu/services/web.scm index d56e893527..aef694e145 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -51,6 +51,9 @@ (define-module (gnu services web) #:use-module (gnu packages logging) #:use-module (gnu packages mail) #:use-module (gnu packages rust-apps) + #:autoload (guix i18n) (G_) + #:use-module (guix combinators) + #:use-module (guix diagnostics) #:use-module (guix packages) #:use-module (guix records) #:use-module (guix modules) @@ -61,6 +64,8 @@ (define-module (gnu services web) #:use-module ((guix packages) #:select (package-version)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-34) + #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (httpd-configuration @@ -96,6 +101,7 @@ (define-module (gnu services web) nginx-configuration-nginx nginx-configuration-shepherd-requirement nginx-configuration-log-directory + nginx-configuration-log-level nginx-configuration-run-directory nginx-configuration-server-blocks nginx-configuration-upstream-blocks @@ -562,6 +568,9 @@ (define-record-type* (default '())) ;list of symbols (log-directory nginx-configuration-log-directory ;string (default "/var/log/nginx")) + (log-level nginx-configuration-log-level + (sanitize assert-valid-log-level) + (default 'error)) (run-directory nginx-configuration-run-directory ;string (default "/var/run/nginx")) (server-blocks nginx-configuration-server-blocks @@ -584,6 +593,18 @@ (define-record-type* (file nginx-configuration-file ;#f | string | file-like (default #f))) +(define-compile-time-procedure (assert-valid-log-level (level symbol?)) + "Ensure @var{level} is one of @code{'debug}, @code{'info}, @code{'notice}, +@code{'warn}, @code{'error}, @code{'crit}, @code{'alert}, or @code{'emerg}." + (unless (memq level '(debug info notice warn error crit alert emerg)) + (raise + (make-compound-condition + (formatted-message (G_ "unknown log level '~a'") level) + (condition (&error-location + (location + (source-properties->location procedure-call-location))))))) + level) + (define (config-domain-strings names) "Return a string denoting the nginx config representation of NAMES, a list of domain names." @@ -692,6 +713,7 @@ (define (default-nginx-config config) (match-record config (nginx log-directory run-directory + log-level server-blocks upstream-blocks server-names-hash-bucket-size server-names-hash-bucket-max-size @@ -704,7 +726,7 @@ (define (default-nginx-config config) (flatten "user nginx nginx;\n" "pid " run-directory "/pid;\n" - "error_log " log-directory "/error.log info;\n" + "error_log " log-directory "/error.log " (symbol->string log-level) ";\n" (map emit-load-module modules) (map emit-global-directive global-directives) "http {\n" -- 2.39.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 28 10:12:40 2023 Received: (at 62490) by debbugs.gnu.org; 28 Mar 2023 14:12:40 +0000 Received: from localhost ([127.0.0.1]:50352 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phA40-00026A-5F for submit@debbugs.gnu.org; Tue, 28 Mar 2023 10:12:40 -0400 Received: from mail-qv1-f49.google.com ([209.85.219.49]:40847) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phA3x-00025w-RJ for 62490@debbugs.gnu.org; Tue, 28 Mar 2023 10:12:38 -0400 Received: by mail-qv1-f49.google.com with SMTP id qh28so9193454qvb.7 for <62490@debbugs.gnu.org>; Tue, 28 Mar 2023 07:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680012752; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=gHmilTmVT2IKiXv6bcUI5zZ1iz5ZhXijQuUA2bnjZo4=; b=gx+Z3F+lqYT1XajgFLJVAlpzr1mVmXQz/9uVWbTEC2NqhJdcBLvmleS2bM2caZYSWs Z6IKpgqvjgPtSTZmWmkVILpLrdB4tg6gw/wMX6Yufyoekgd0qVkEHoc/e/BZU2UJeBF3 LmnvLDSnV9DBE4qCkxh6rXP/EKDcfFUJxqJKRc1Y0NGQ6NeE9Hz/eFRNsdKfMgzWdILl UmnoZYTbTyAmJXrWMP3IT5nagQpKguuNTznA7i1IG1AZRswc/WuR4BDayouYri8L1INI TxqQt5oWcjmxli5RQo5i/Gm3jrAYOMFTi+tuBKvP7dB+p4asJgrodbIQRVDes66+jbqj kfGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680012752; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gHmilTmVT2IKiXv6bcUI5zZ1iz5ZhXijQuUA2bnjZo4=; b=VOuc9Rc5Z5qPL65upt1UNdeoUaCYe/xcZtxgSz9mPCm4C3nJpDbEhwXOlVWGazsCjJ c9uEoddBxunzEP6WA8eKNPU3bUlotBrWNDQ0HPR4aIt7glnLwrYjgzoAoy9QakB8YLJ1 BMTJq+7EQ7RyIc/EbPng0td4orr+7QvgN9TqOdJThNnhlhaItf2CTehqfifc3Q51nwhT roEF/OLBHgiKPckhSOf96JK4zDmDg9ceXTm5e9HUjWVYodEdeek/rrU9oJHFO928o7p0 qzZj97eGfHyIWoXpOhLYVuFvmoiIoTzDgz5VcnJNUsQY9HeimwBbhTFvEt/SNpVE/ZbT LXmw== X-Gm-Message-State: AAQBX9ceH0sIXw2R1qGvSZ5PjupezgtsOytuUiN97QsDERMjNwcPAuq/ dQFYyjgpyn2vQtlJssmXN7qkWUBskKI= X-Google-Smtp-Source: AKy350aB97BOJckjWHuQVMor9IdwyTVJoEYc+7K/7S0M6D0Z452v9aU/IkQziPZzvEEewM39N2uqaw== X-Received: by 2002:a05:6214:2604:b0:5ab:e259:b2a9 with SMTP id gu4-20020a056214260400b005abe259b2a9mr29488085qvb.14.1680012752297; Tue, 28 Mar 2023 07:12:32 -0700 (PDT) Received: from hurd (dsl-205-151-56-156.b2b2c.ca. [205.151.56.156]) by smtp.gmail.com with ESMTPSA id d12-20020a0cea8c000000b005dd8b9345c4sm3816900qvp.92.2023.03.28.07.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 07:12:32 -0700 (PDT) From: Maxim Cournoyer To: Bruno Victal Subject: Re: [bug#62490] [PATCH] services: nginx: Make logging level configurable. References: Date: Tue, 28 Mar 2023 10:12:30 -0400 In-Reply-To: (Bruno Victal's message of "Mon, 27 Mar 2023 19:51:04 +0100") Message-ID: <87r0t9newh.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62490 Cc: 62490@debbugs.gnu.org, ludo@gnu.org, mail@cbaines.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Bruno Victal writes: > * gnu/services/web.scm ()[log-level]: New field. > (assert-valid-log-level): New procedure. > (default-nginx-config): Make log-level configurable. > * doc/guix.texi (Web Services): Document it. Thanks! > --- > > Note: Hardcoding this value to 'info is extremely bad for > flash endurance, and results in very large logs. > > doc/guix.texi | 5 +++++ > gnu/services/web.scm | 24 +++++++++++++++++++++++- > 2 files changed, 28 insertions(+), 1 deletion(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index c49e51b72e..8df3c285ad 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -29838,6 +29838,11 @@ Web Services > @item @code{log-directory} (default: @code{"/var/log/nginx"}) > The directory to which NGinx will write log files. > > +@item @code{log-level} (default: @code{'error}) (type: symbol) > +Logging level, which can be any of the following values: @code{'debug}, > +@code{'info}, @code{'notice}, @code{'warn}, @code{'error}, @code{'crit}, > +@code{'alert}, or @code{'emerg}. > + > @item @code{run-directory} (default: @code{"/var/run/nginx"}) > The directory in which NGinx will create a pid file, and write temporary > files. > diff --git a/gnu/services/web.scm b/gnu/services/web.scm > index d56e893527..aef694e145 100644 > --- a/gnu/services/web.scm > +++ b/gnu/services/web.scm > @@ -51,6 +51,9 @@ (define-module (gnu services web) > #:use-module (gnu packages logging) > #:use-module (gnu packages mail) > #:use-module (gnu packages rust-apps) > + #:autoload (guix i18n) (G_) > + #:use-module (guix combinators) > + #:use-module (guix diagnostics) > #:use-module (guix packages) > #:use-module (guix records) > #:use-module (guix modules) > @@ -61,6 +64,8 @@ (define-module (gnu services web) > #:use-module ((guix packages) #:select (package-version)) > #:use-module (srfi srfi-1) > #:use-module (srfi srfi-9) > + #:use-module (srfi srfi-34) > + #:use-module (srfi srfi-35) > #:use-module (ice-9 match) > #:use-module (ice-9 format) > #:export (httpd-configuration > @@ -96,6 +101,7 @@ (define-module (gnu services web) > nginx-configuration-nginx > nginx-configuration-shepherd-requirement > nginx-configuration-log-directory > + nginx-configuration-log-level > nginx-configuration-run-directory > nginx-configuration-server-blocks > nginx-configuration-upstream-blocks > @@ -562,6 +568,9 @@ (define-record-type* > (default '())) ;list of symbols > (log-directory nginx-configuration-log-directory ;string > (default "/var/log/nginx")) > + (log-level nginx-configuration-log-level > + (sanitize assert-valid-log-level) > + (default 'error)) > (run-directory nginx-configuration-run-directory ;string > (default "/var/run/nginx")) > (server-blocks nginx-configuration-server-blocks > @@ -584,6 +593,18 @@ (define-record-type* > (file nginx-configuration-file ;#f | string | file-like > (default #f))) > > +(define-compile-time-procedure (assert-valid-log-level (level symbol?)) > + "Ensure @var{level} is one of @code{'debug}, @code{'info}, @code{'notice}, > +@code{'warn}, @code{'error}, @code{'crit}, @code{'alert}, or @code{'emerg}." > + (unless (memq level '(debug info notice warn error crit alert emerg)) > + (raise > + (make-compound-condition > + (formatted-message (G_ "unknown log level '~a'") level) > + (condition (&error-location > + (location > + (source-properties->location procedure-call-location))))))) > + level) It's the first time I've seen define-compile-time-procedure in actual use. Is it really necessary? What happens if you omit wrapping assert-valid-log-level with it? > (define (config-domain-strings names) > "Return a string denoting the nginx config representation of NAMES, a list > of domain names." > @@ -692,6 +713,7 @@ (define (default-nginx-config config) > (match-record config > > (nginx log-directory run-directory > + log-level > server-blocks upstream-blocks > server-names-hash-bucket-size > server-names-hash-bucket-max-size > @@ -704,7 +726,7 @@ (define (default-nginx-config config) > (flatten > "user nginx nginx;\n" > "pid " run-directory "/pid;\n" > - "error_log " log-directory "/error.log info;\n" > + "error_log " log-directory "/error.log " (symbol->string log-level) ";\n" > (map emit-load-module modules) > (map emit-global-directive global-directives) > "http {\n" The rest LGTM. -- Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 28 10:33:13 2023 Received: (at 62490) by debbugs.gnu.org; 28 Mar 2023 14:33:13 +0000 Received: from localhost ([127.0.0.1]:50479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phANt-0002j0-0R for submit@debbugs.gnu.org; Tue, 28 Mar 2023 10:33:13 -0400 Received: from smtpmciv3.myservices.hosting ([185.26.107.239]:57674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phANr-0002is-5o for 62490@debbugs.gnu.org; Tue, 28 Mar 2023 10:33:11 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv3.myservices.hosting (Postfix) with ESMTP id 9EF992041D; Tue, 28 Mar 2023 16:33:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 51CDA800A7; Tue, 28 Mar 2023 16:33:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wDyrpzZLTDjT; Tue, 28 Mar 2023 16:33:07 +0200 (CEST) Received: from [192.168.1.239] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id D4435800A3; Tue, 28 Mar 2023 16:33:06 +0200 (CEST) Message-ID: <156c2153-cca0-2f59-6ca8-edad4fb7e919@makinata.eu> Date: Tue, 28 Mar 2023 15:32:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [bug#62490] [PATCH] services: nginx: Make logging level configurable. Content-Language: en-US To: Maxim Cournoyer References: <87r0t9newh.fsf@gmail.com> From: Bruno Victal In-Reply-To: <87r0t9newh.fsf@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 62490 Cc: 62490@debbugs.gnu.org, ludo@gnu.org, mail@cbaines.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Hi Maxim, On 2023-03-28 15:12, Maxim Cournoyer wrote: > Bruno Victal writes: >> >> +(define-compile-time-procedure (assert-valid-log-level (level symbol?)) >> + "Ensure @var{level} is one of @code{'debug}, @code{'info}, @code{'notice}, >> +@code{'warn}, @code{'error}, @code{'crit}, @code{'alert}, or @code{'emerg}." >> + (unless (memq level '(debug info notice warn error crit alert emerg)) >> + (raise >> + (make-compound-condition >> + (formatted-message (G_ "unknown log level '~a'") level) >> + (condition (&error-location >> + (location >> + (source-properties->location procedure-call-location))))))) >> + level) > > It's the first time I've seen define-compile-time-procedure in actual > use. Is it really necessary? What happens if you omit wrapping > assert-valid-log-level with it? It will still work, provided the declaration is adjusted accordingly. As for the reasons and benefits of using define-compile-time-procedure, it's best explained at . Cheers, Bruno From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 28 11:03:57 2023 Received: (at 62490) by debbugs.gnu.org; 28 Mar 2023 15:03:57 +0000 Received: from localhost ([127.0.0.1]:50511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phArc-0003aK-UJ for submit@debbugs.gnu.org; Tue, 28 Mar 2023 11:03:57 -0400 Received: from mail-qt1-f175.google.com ([209.85.160.175]:33385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phAra-0003a4-Mh for 62490@debbugs.gnu.org; Tue, 28 Mar 2023 11:03:55 -0400 Received: by mail-qt1-f175.google.com with SMTP id cr18so8328437qtb.0 for <62490@debbugs.gnu.org>; Tue, 28 Mar 2023 08:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680015829; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Tx9hGVWPNEeoKPrwapQ7knw4rZ1OGKazOI5PvCgBdOk=; b=UY2IrKys7JBf+W5a7pptB4K7HfTipQT6xVwqxqfTs03khbAU7D7aOR0QpqsVPN/mx1 vuguWIDwBHr/+d5TsQG6OrEvCc5IIjlrwbm3/BAJQBACBuZOsRUh+calKx0KUpkHNK5B sfJZp/fRcqStdfJ17lsZdgK3czfhE76uo52HcU/wjHtiBK7suDeAPOKAzjFZgjnpLegQ f7Il8o8SFGfQabXxxF64NPX776N4LjdqiK4LcdeRo9LVHk29TbaoMGr2ASNb5be5xUE3 DIomC16lpP9DdBuulBGKQryRrW+ofbt3n1RipyQC56ETuoP0TjUGoOJG+QNGDCjH4ars Vb8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680015829; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Tx9hGVWPNEeoKPrwapQ7knw4rZ1OGKazOI5PvCgBdOk=; b=wByjYyGG/rkfwVmcX4WRIGhM2ms0nC2Y8wdBtAD1P51N9+YQbX+x91lYH01hgruLOG TNjai+D4i8pMQTeQETB+rHSZbGt3RF/bPBAhC9uYmvEVW4DQmM8aJzownsEf7Z5B/sga Ouh26VBb1928qkGTQgW3qGSdUUxJ7vYnfij6/8zjjptXktKb1n133+owvp4zPwtq4eVg Ald/fuTkZvALmrDOHJJV6wSe2ckqOr6r6DCsWCYH/fNzS9VxvYc3x+/cxcgeCIKNlySj tK7cwAZ3raCfx5xQuqOld/MCCDR3tGdcV2rBc7ETiTmSoAEbgW4Ew58xQ9/MWRAoCzG1 hJKw== X-Gm-Message-State: AO0yUKVNzMicOnh3LxvHJm26Z6/I8fwqTVCpqI1PSwgv2R6/LvK7dUXs acEhadYRPiATffPYqY9dSXU= X-Google-Smtp-Source: AK7set+VCM3arj9tEdzS8p/capRwr1mv62oPoUVCqvP4hx1jhu8uyazYI4pURRHx0W13yod1vkHUag== X-Received: by 2002:ac8:5905:0:b0:3b9:a372:e456 with SMTP id 5-20020ac85905000000b003b9a372e456mr24766233qty.57.1680015829047; Tue, 28 Mar 2023 08:03:49 -0700 (PDT) Received: from hurd (dsl-205-151-56-156.b2b2c.ca. [205.151.56.156]) by smtp.gmail.com with ESMTPSA id s13-20020ac8758d000000b003e4e1ea3cb5sm2376260qtq.51.2023.03.28.08.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 08:03:48 -0700 (PDT) From: Maxim Cournoyer To: Bruno Victal Subject: Re: [bug#62490] [PATCH] services: nginx: Make logging level configurable. References: <87r0t9newh.fsf@gmail.com> <156c2153-cca0-2f59-6ca8-edad4fb7e919@makinata.eu> Date: Tue, 28 Mar 2023 11:03:45 -0400 In-Reply-To: <156c2153-cca0-2f59-6ca8-edad4fb7e919@makinata.eu> (Bruno Victal's message of "Tue, 28 Mar 2023 15:32:56 +0100") Message-ID: <87ilekor3i.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62490 Cc: 62490@debbugs.gnu.org, ludo@gnu.org, mail@cbaines.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) OK, Bruno Victal writes: > Hi Maxim, > > On 2023-03-28 15:12, Maxim Cournoyer wrote: >> Bruno Victal writes: >>> >>> +(define-compile-time-procedure (assert-valid-log-level (level symbol?)) >>> + "Ensure @var{level} is one of @code{'debug}, @code{'info}, @code{'notice}, >>> +@code{'warn}, @code{'error}, @code{'crit}, @code{'alert}, or @code{'emerg}." >>> + (unless (memq level '(debug info notice warn error crit alert emerg)) >>> + (raise >>> + (make-compound-condition >>> + (formatted-message (G_ "unknown log level '~a'") level) >>> + (condition (&error-location >>> + (location >>> + (source-properties->location procedure-call-location))))))) >>> + level) >> >> It's the first time I've seen define-compile-time-procedure in actual >> use. Is it really necessary? What happens if you omit wrapping >> assert-valid-log-level with it? > > It will still work, provided the declaration is adjusted accordingly. > As for the reasons and benefits of using define-compile-time-procedure, > it's best explained at . I guess it's not actually useful here, since none of the fields thunked? As another note, the nginx-configuration record looks simple enough that perhaps it'd best be migrated to use the define-configuration method, which could be made as a prior commit to this change. As a benefit it'd validate the other field types as well. -- Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 02 11:39:54 2023 Received: (at 62490) by debbugs.gnu.org; 2 Apr 2023 15:39:54 +0000 Received: from localhost ([127.0.0.1]:42462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pizo9-0007f3-Lm for submit@debbugs.gnu.org; Sun, 02 Apr 2023 11:39:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pizo6-0007en-Ou for 62490@debbugs.gnu.org; Sun, 02 Apr 2023 11:39:52 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pizo0-00042r-RA; Sun, 02 Apr 2023 11:39:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=wQSWyJW8knLEgkUWZadbnpiix8L0tlEBX6je/Wv3cW4=; b=aXW9v2xRu8Dx3dtW62kW NyxN4ax9jTUNF0KMuPUXepC03Nc9TrzAl2yeAV/bYjcACecXzXNjNdPVK5PSVHQT0zZNebRy5CdzX Tx/lsGgPbzYLd2484dgsj7FuV3QazgoyUT4dUaY31y7LQlLf0ABKEUg1JKbESn5U6scR4yoOcDA8d n4Sqn/Tu1TDkpG7A9YTfJZV3JATqr25cbFFmy73gG8M2RK2Q+pR7UfH/iLcPDT+dUYj5BCiP1hXy2 vEHHQeNwbfYjdGXoOddlocZIYHFdYulXJKdq3cVNL7QbqY2DT5+CwoHsftb+YJ6AsSJPGtVJyJwFL qiXHeNPJinK0LQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pizo0-0003oJ-4W; Sun, 02 Apr 2023 11:39:44 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Bruno Victal Subject: Re: bug#62490: [PATCH] services: nginx: Make logging level configurable. References: Date: Sun, 02 Apr 2023 17:39:41 +0200 In-Reply-To: (Bruno Victal's message of "Mon, 27 Mar 2023 19:51:04 +0100") Message-ID: <87jzyuths2.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62490 Cc: 62490@debbugs.gnu.org, mail@cbaines.net, maxim.cournoyer@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Bruno Victal skribis: > +(define-compile-time-procedure (assert-valid-log-level (level symbol?)) > + "Ensure @var{level} is one of @code{'debug}, @code{'info}, @code{'noti= ce}, > +@code{'warn}, @code{'error}, @code{'crit}, @code{'alert}, or @code{'emer= g}." As it turns out, =E2=80=98define-compile-time-procedure=E2=80=99 cannot wor= k with symbols. In short, that=E2=80=99s because in the end the generated macro checks: (symbol? #'(quote debug)) which doesn=E2=80=99t do what we want. Anyway, you can either make it a regular procedure instead, or use a trick found in R6RS and used in some places in Guix, Guile-Gcrypt, etc., which is to define a macro that validates things: (endianness little) ;R6RS (operating-id valid-path?) ;(guix store), with =E2=80=98define-enumerate-= type=E2=80=99 Making it a procedure is prolly good enough. The compiler can optimize it out at compile time, FWIW: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,optimize (unless (memq 'debug '(debug info)) (throw '= x)) $13 =3D (if #f #f) --8<---------------cut here---------------end--------------->8--- Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 03 07:58:23 2023 Received: (at 62490) by debbugs.gnu.org; 3 Apr 2023 11:58:23 +0000 Received: from localhost ([127.0.0.1]:43582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjIpL-0006ZY-42 for submit@debbugs.gnu.org; Mon, 03 Apr 2023 07:58:23 -0400 Received: from smtpm2.myservices.hosting ([185.26.105.233]:50304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjIpF-0006ZL-Tq for 62490@debbugs.gnu.org; Mon, 03 Apr 2023 07:58:21 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm2.myservices.hosting (Postfix) with ESMTP id C5EC820292; Mon, 3 Apr 2023 13:58:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 70751800A0; Mon, 3 Apr 2023 13:58:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6u0t27Oxzo75; Mon, 3 Apr 2023 13:58:10 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 1268E8009D; Mon, 3 Apr 2023 13:58:10 +0200 (CEST) From: Bruno Victal To: 62490@debbugs.gnu.org Subject: [PATCH v2 1/2] services: nginx: Make logging level configurable. Date: Mon, 3 Apr 2023 12:58:02 +0100 Message-Id: <4027e6a1d7a59e11a7f4000b821283a1985f1dcc.1680523067.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62490 Cc: ludo@gnu.org, Bruno Victal , maxim.cournoyer@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/web.scm ()[log-level]: New field. (assert-valid-log-level): New procedure. (default-nginx-config): Make log-level configurable. * doc/guix.texi (Web Services): Document it. --- doc/guix.texi | 5 +++++ gnu/services/web.scm | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 4f72e2f34a..6a2380aa3e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -29838,6 +29838,11 @@ Web Services @item @code{log-directory} (default: @code{"/var/log/nginx"}) The directory to which NGinx will write log files. +@item @code{log-level} (default: @code{'error}) (type: symbol) +Logging level, which can be any of the following values: @code{'debug}, +@code{'info}, @code{'notice}, @code{'warn}, @code{'error}, @code{'crit}, +@code{'alert}, or @code{'emerg}. + @item @code{run-directory} (default: @code{"/var/run/nginx"}) The directory in which NGinx will create a pid file, and write temporary files. diff --git a/gnu/services/web.scm b/gnu/services/web.scm index d56e893527..4fe9c2d9ab 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -15,6 +15,7 @@ ;;; Copyright © 2020 Oleg Pykhalov ;;; Copyright © 2020, 2021 Alexandru-Sergiu Marton ;;; Copyright © 2022 Simen Endsjø +;;; Copyright © 2023 Bruno Victal ;;; ;;; This file is part of GNU Guix. ;;; @@ -51,6 +52,8 @@ (define-module (gnu services web) #:use-module (gnu packages logging) #:use-module (gnu packages mail) #:use-module (gnu packages rust-apps) + #:autoload (guix i18n) (G_) + #:use-module (guix diagnostics) #:use-module (guix packages) #:use-module (guix records) #:use-module (guix modules) @@ -61,6 +64,7 @@ (define-module (gnu services web) #:use-module ((guix packages) #:select (package-version)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-34) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (httpd-configuration @@ -96,6 +100,7 @@ (define-module (gnu services web) nginx-configuration-nginx nginx-configuration-shepherd-requirement nginx-configuration-log-directory + nginx-configuration-log-level nginx-configuration-run-directory nginx-configuration-server-blocks nginx-configuration-upstream-blocks @@ -562,6 +567,9 @@ (define-record-type* (default '())) ;list of symbols (log-directory nginx-configuration-log-directory ;string (default "/var/log/nginx")) + (log-level nginx-configuration-log-level + (sanitize assert-valid-log-level) + (default 'error)) (run-directory nginx-configuration-run-directory ;string (default "/var/run/nginx")) (server-blocks nginx-configuration-server-blocks @@ -584,6 +592,14 @@ (define-record-type* (file nginx-configuration-file ;#f | string | file-like (default #f))) +(define (assert-valid-log-level level) + "Ensure @var{level} is one of @code{'debug}, @code{'info}, @code{'notice}, +@code{'warn}, @code{'error}, @code{'crit}, @code{'alert}, or @code{'emerg}." + (unless (memq level '(debug info notice warn error crit alert emerg)) + (raise + (formatted-message (G_ "unknown log level '~a'~%") level))) + level) + (define (config-domain-strings names) "Return a string denoting the nginx config representation of NAMES, a list of domain names." @@ -692,6 +708,7 @@ (define (default-nginx-config config) (match-record config (nginx log-directory run-directory + log-level server-blocks upstream-blocks server-names-hash-bucket-size server-names-hash-bucket-max-size @@ -704,7 +721,7 @@ (define (default-nginx-config config) (flatten "user nginx nginx;\n" "pid " run-directory "/pid;\n" - "error_log " log-directory "/error.log info;\n" + "error_log " log-directory "/error.log " (symbol->string log-level) ";\n" (map emit-load-module modules) (map emit-global-directive global-directives) "http {\n" -- 2.39.2 From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 03 07:59:27 2023 Received: (at 62490) by debbugs.gnu.org; 3 Apr 2023 11:59:28 +0000 Received: from localhost ([127.0.0.1]:43586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjIqN-0006bE-M6 for submit@debbugs.gnu.org; Mon, 03 Apr 2023 07:59:27 -0400 Received: from smtpmciv2.myservices.hosting ([185.26.107.238]:46042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjIqL-0006b4-G8 for 62490@debbugs.gnu.org; Mon, 03 Apr 2023 07:59:25 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv2.myservices.hosting (Postfix) with ESMTP id 202A120513; Mon, 3 Apr 2023 13:59:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id AE0BC800AF; Mon, 3 Apr 2023 13:59:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KSsGCiCdxVLu; Mon, 3 Apr 2023 13:59:23 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 23987800AE; Mon, 3 Apr 2023 13:59:23 +0200 (CEST) From: Bruno Victal To: 62490@debbugs.gnu.org Subject: [PATCH v2 2/2] services: nginx: Add reopen action. Date: Mon, 3 Apr 2023 12:58:03 +0100 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: <4027e6a1d7a59e11a7f4000b821283a1985f1dcc.1680523067.git.mirai@makinata.eu> References: <4027e6a1d7a59e11a7f4000b821283a1985f1dcc.1680523067.git.mirai@makinata.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62490 Cc: ludo@gnu.org, Bruno Victal , maxim.cournoyer@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is required to allow log file rotations using rottlog, etc. * gnu/services/web.scm (nginx-shepherd-service): Add reopen shepherd action. --- gnu/services/web.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 4fe9c2d9ab..45897d7d6f 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -840,7 +840,11 @@ (define (nginx-shepherd-service config) the same configuration file. It is useful for situations where the same nginx configuration file can point to different things after a reload, such as renewed TLS certificates, or @code{include}d files.") - (procedure (nginx-action "-s" "reload")))))))))) + (procedure (nginx-action "-s" "reload"))) + (shepherd-action + (name 'reopen) + (documentation "Re-open log files.") + (procedure (nginx-action "-s" "reopen")))))))))) (define nginx-service-type (service-type (name 'nginx) -- 2.39.2 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 11 13:12:26 2023 Received: (at 62490-done) by debbugs.gnu.org; 11 Apr 2023 17:12:26 +0000 Received: from localhost ([127.0.0.1]:38094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmHXe-0003R2-95 for submit@debbugs.gnu.org; Tue, 11 Apr 2023 13:12:26 -0400 Received: from mail-qv1-f42.google.com ([209.85.219.42]:35774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmHXb-0003Qn-RL for 62490-done@debbugs.gnu.org; Tue, 11 Apr 2023 13:12:24 -0400 Received: by mail-qv1-f42.google.com with SMTP id e9so5924218qvv.2 for <62490-done@debbugs.gnu.org>; Tue, 11 Apr 2023 10:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681233138; x=1683825138; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=q4Lu8BtTFeuAGyhIdbblIIpwreAd3RosQ19abSQsJZc=; b=B11SJFcKh3Q8LCw3TFNR8y7u9KGqH6dpB/YVVvOfK+L7xwUoINtIxjh2gXhW74KuUY d9KGUkC8m7GOK6qpR1T0cnoNAyS5vEYEdWC2HL8Mkhqq2q2+i8M0wKICBesRjjb2B8ip aoQSjbkZHV6RMMpmDc5jLNFXaHD5/erG+JM+OlkA6C1+0b/hFTmp8NVKts090QqUN2WV t7W9FtN62l70/Y7VoW26QfkA5B+ZACIBU8eFQHqMEfTJbBE3IKMw5QTplFFG+bExHska MLSNXlaqJSQhWSjoAoO0bi7M762qCiKM/VyWmUN2WBKK1wRgCHXTIqykLNgd+YPAT6xP Xxeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681233138; x=1683825138; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=q4Lu8BtTFeuAGyhIdbblIIpwreAd3RosQ19abSQsJZc=; b=ikPAG3BTZlTg+lPDBUvXRoNYiM634n2WxVEBZVeP9JV38FWBjZlWTAcRxu4sJwpHew d5J+9wh3aB//1ZHaGsdM3MgImy5xPo2VahU6Dug27pxPa+Smm00uQYXnrHZQQUnnQ49o oHFHfAVFjXFPTAdL41QFiRK0Wf/fcqq0zG55DGjH8bz0Ur3FghMh6Frf0bwvG1JzlJMG Vfa3eBXbTobDDexZwJ4JSsWUdUL+WX5Ssqf8uvcPkyuLhgqsZa1/rxzoIShxBUg60a7d kzfAsblN7IiKuZTk7vbkfKf7KrFjtjiD6ihC4kObe50vgrnIT8Of+A74zcNRw3b7nL7c FKOw== X-Gm-Message-State: AAQBX9dmbOPMkmBl/CBWDEBObPqtV6y8FPfjvPtGOqonLrmnF+uGlL5g Ox8JrAV59edtoj4/+6iJ+zc= X-Google-Smtp-Source: AKy350aTBgEi6hcDzX4PZ6pzzaq1NBM2HQvYhMbVuS11B+BSn+qw+aMnFVHojuhxCkMkVisvLMGoLg== X-Received: by 2002:a05:6214:19eb:b0:5ad:c532:67e6 with SMTP id q11-20020a05621419eb00b005adc53267e6mr6270628qvc.42.1681233138026; Tue, 11 Apr 2023 10:12:18 -0700 (PDT) Received: from hurd (dsl-152-224.b2b2c.ca. [66.158.152.224]) by smtp.gmail.com with ESMTPSA id cz10-20020a056214088a00b005e8d802ce32sm2985019qvb.143.2023.04.11.10.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 10:12:17 -0700 (PDT) From: Maxim Cournoyer To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#62490: [PATCH] services: nginx: Make logging level configurable. References: <87jzyuths2.fsf@gnu.org> Date: Tue, 11 Apr 2023 13:12:16 -0400 In-Reply-To: <87jzyuths2.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sun, 02 Apr 2023 17:39:41 +0200") Message-ID: <87bkjumjgv.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62490-done Cc: 62490-done@debbugs.gnu.org, Bruno Victal , mail@cbaines.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Ludovic Court=C3=A8s writes: > Hi, > > Bruno Victal skribis: > >> +(define-compile-time-procedure (assert-valid-log-level (level symbol?)) >> + "Ensure @var{level} is one of @code{'debug}, @code{'info}, @code{'not= ice}, >> +@code{'warn}, @code{'error}, @code{'crit}, @code{'alert}, or @code{'eme= rg}." > > As it turns out, =E2=80=98define-compile-time-procedure=E2=80=99 cannot w= ork with > symbols. In short, that=E2=80=99s because in the end the generated macro > checks: > > (symbol? #'(quote debug)) > > which doesn=E2=80=99t do what we want. > > Anyway, you can either make it a regular procedure instead, or use a > trick found in R6RS and used in some places in Guix, Guile-Gcrypt, etc., > which is to define a macro that validates things: > > (endianness little) ;R6RS > > (operating-id valid-path?) ;(guix store), with =E2=80=98define-enumerat= e-type=E2=80=99 > > Making it a procedure is prolly good enough. The compiler can optimize > it out at compile time, FWIW: > > scheme@(guile-user)> ,optimize (unless (memq 'debug '(debug info)) (throw= 'x)) > $13 =3D (if #f #f) I've installed Bruno's v2, which reworked the above into a simple procedure. Closing! --=20 Thanks, Maxim From unknown Sat Jun 14 03:58:12 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 10 May 2023 11:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator