From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id SCCfBwL2ImSqtwAASxT56A (envelope-from ) for ; Tue, 28 Mar 2023 16:13:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aDOaBgL2ImR4ZwEAG6o9tA (envelope-from ) for ; Tue, 28 Mar 2023 16:13:22 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B7C86896E for ; Tue, 28 Mar 2023 16:13:21 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=gx+Z3F+l; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680012801; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=gHmilTmVT2IKiXv6bcUI5zZ1iz5ZhXijQuUA2bnjZo4=; b=n+g1h86Um9dWX3sIZ0D2ql6Q4yEwNB+uF4FxGR5NMtBmm6xPbNSCnyRSgE2QRbqzpPJLRc ZBz637E+c4Pd755LIvLMIvnqknbcljxLjp4qmZZyWM8mipbDL/W7nmvzu+zWV6BBOJqrZz oAEs4yjtDpvCzMgOyW2tiysb+teKrN2k0Q9v7hhNYC1uwPdNbaVWTOSK0X3mCksmQq/uuP Fe/VwlrCgtk3JNAKdnU04IT7L9HPp/vKQ+xCnUWG9dnv3xvPFK0evFo/E/vOu/iCN0HcR0 DPzVYidmo44Xf2c4ZFCZcNkd0rfERHSvVCSzxSHnpSeNxqiKbgID+/rNF2msMQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680012801; a=rsa-sha256; cv=none; b=Wbt8DESvCYihsSehJxyRkT+6QDcMEh6ovQqqJzVs4+EFRMUmtzAdcAzTzbhsx6kJcs6C7+ 6J6eVjZLlw2hMKetGpbfRMgQIYVe/OE6m2Q/+pn0Hks2eiSG8vclK7iDk1A8KKb7wINEt9 h817nSzCeuFakciecJXwBCfqDM4G/cVMwu0c6ZuT30bGxJC323PrCBxCRp2k9sge4yYg8d UqRDFq+fd6MxjyCfL62uBv0+XkDfRhsi1vzf+tS72n7pr1lCxLrhpTjaegh9gXbCfTxBCI kpCDM1x6TbmuLI6r+rYmuEmh8W4rdBJJqm/96RecVs8WHTiTUGTbv1vrNZ1Ofw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=gx+Z3F+l; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phA4Q-0002BZ-EM; Tue, 28 Mar 2023 10:13:06 -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 1phA4O-0002BP-77 for guix-patches@gnu.org; Tue, 28 Mar 2023 10:13:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1phA4M-0003gK-9h for guix-patches@gnu.org; Tue, 28 Mar 2023 10:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1phA4M-00026l-4r for guix-patches@gnu.org; Tue, 28 Mar 2023 10:13:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62490] [PATCH] services: nginx: Make logging level configurable. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 28 Mar 2023 14:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62490 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Bruno Victal Cc: 62490@debbugs.gnu.org, ludo@gnu.org, mail@cbaines.net Received: via spool by 62490-submit@debbugs.gnu.org id=B62490.16800127608074 (code B ref 62490); Tue, 28 Mar 2023 14:13:02 +0000 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 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Queue-Id: B7C86896E X-Spam-Score: -0.63 X-Migadu-Spam-Score: -0.63 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: +t0+EAwxSl3i 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