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 uDAAOpy/KmRIxAAASxT56A (envelope-from ) for ; Mon, 03 Apr 2023 13:59:25 +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 sLkgOZy/KmS0bQEAG6o9tA (envelope-from ) for ; Mon, 03 Apr 2023 13:59:24 +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 86EBB9102 for ; Mon, 3 Apr 2023 13:59:24 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjIq5-00060V-Qg; Mon, 03 Apr 2023 07:59:09 -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 1pjIpy-0005y8-D9 for guix-patches@gnu.org; Mon, 03 Apr 2023 07:59:02 -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 1pjIpy-0003pa-49 for guix-patches@gnu.org; Mon, 03 Apr 2023 07:59:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pjIpx-0006aR-Me for guix-patches@gnu.org; Mon, 03 Apr 2023 07:59:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62490] [PATCH v2 1/2] services: nginx: Make logging level configurable. References: In-Reply-To: Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 03 Apr 2023 11:59:01 +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: 62490@debbugs.gnu.org Cc: ludo@gnu.org, Bruno Victal , maxim.cournoyer@gmail.com Received: via spool by 62490-submit@debbugs.gnu.org id=B62490.168052310325272 (code B ref 62490); Mon, 03 Apr 2023 11:59:01 +0000 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 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-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: 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 ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680523164; a=rsa-sha256; cv=none; b=Lrnqtoz3oumXPw6LCgs2XDvvry9mazV1PTuUL6CIEAN6jkTpUXEzkuAiIzxqEH56GW89qI 2uNz+e93vpLlfZakZDj+rYtfIYTLA73N3BGMTzScoHRYVQzK/ItIspm8W6J4YID1CPYIQh 5fWRHiA0Vwy55mlKnuZdBC6dG3S1s1eBvRjBJnyoND7N/hDR8GjoAmHejztg+ZazofxZvV MuWriXFhBt5gYYOBtNyh/3LAnlpNczVe0WGBRK+qjwW1ab6SjdFC/PK+K7CeZanCJqdqP0 OcXg+7C1+gijIS3OW6muzvyrBmsvGYDYP4PhoR/JUi0p6JlmKOFy2wajYgX1Mw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680523164; 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: content-transfer-encoding:content-transfer-encoding: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; bh=e+d7XzoobK4JbsYdJJrHYEoiOFOWP9OKlsBhKAr+4SQ=; b=ZrlKGFCAFK+RF542gJK9KfhMQ9lfZjejZ/nfuUjyl2JmZZUG0TmPsUKnV6yLbvH3d/oe6N HoGg6u521V+vs+mWhsDAoyKEiWmryHlCTPllRNDv6x/4+7ykh/Pvh6RXUlzBfs/cS56IuE amB72Zrfe40M0HbxDAbocrDmd9JW2SGYNS6Bt9SS1pnBQqwNopCItCWnrcjf6XQDt2Msja 4mGlxvrRbw7Ie/u3IRig3BkaxGLsR4/o3VbY54G/I6k1EhFLnqiIKLyuvJvUttbu8u+L6w qHuosrU2EYE4gY3kpSYVJ8Sm7uHb0JNKPIEqxOKPx208+xS+sdBZjMxMkKyY+A== Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -1.52 X-Spam-Score: -1.52 X-Migadu-Queue-Id: 86EBB9102 X-TUID: T80pQ19oqrS2 * 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