From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id MPcUAOnlIWSDGAAASxT56A (envelope-from ) for ; Mon, 27 Mar 2023 20:52:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 2FzWOujlIWQK/AAAG6o9tA (envelope-from ) for ; Mon, 27 Mar 2023 20:52: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 98663CB27 for ; Mon, 27 Mar 2023 20:52:24 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=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"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679943144; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ENxsc2JKUqfWy5f2w043VK5EnTvWbrjhQNr72duDmyU=; b=GsRfiOFKWL8bi3GYjd4HBVMnsK56LxnMfXdkFTGNXIwNW4SH6YWZem2TRsoXDDs+XvyFtE dan/U0/r8LE1sbAGbBQMaZsD1JTQICm5psyEs7Kylnw1ZOKeYwiM6QnFVZJK2+R2d+JlR0 aOUb+cgvEWnkWtR/RsKKxUMhlaXrvhO1GHC+X+E9QZy+wmVG+Uc344Y/HRxK4FNO0rxqV9 +nBxoWKwLejnKs3dOLpobYfZmsjKezpCV47OHZPnIi1QiZwMUuOMMlCeKoxTKkKqMa7d8+ otYGIRS6IA4inYZCXR50N/vcCjQReJjYLkMCgEWi99+nW6Clo7UxUJAboqC5CA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679943144; a=rsa-sha256; cv=none; b=OJ49yJKqinFEOAYlOpEHPDy4kAHDydBtIQkmEMtuKKCqrqoqBCOiphsKsZPE+7T0Edsu+2 yUXEqDUU5nAUaU75P6czD06WQLsP8GougMCGrFOCxdJlPwGRZEmrOHgsmeCHGZRhKvNOxd nMzhukivEQyJcDLsfgHDEs9kEj0A/TTNqRPj8KJX9kK41NxVLq+BBbjFd9S2shJbCL9Lvv S9WDmpU+klSkqTMw/QBdMUe4JfpEq1Ci6LDrHZ2+Lojj13TH20fW7N/Lbu2VPchnvG8akt wkCxgueZ9SNM7nCQBGYXsxxzJpDME2lYsWiJPXnC11og6/zVlV288KEKXbSceQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=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"; dmarc=none Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgrwr-0000sL-I8; Mon, 27 Mar 2023 14:52:05 -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 1pgrwp-0000ra-JM for guix-patches@gnu.org; Mon, 27 Mar 2023 14:52:03 -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 1pgrwp-0004Rx-24; Mon, 27 Mar 2023 14:52:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pgrwo-00086a-7p; Mon, 27 Mar 2023 14:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62490] [PATCH] services: nginx: Make logging level configurable. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, mail@cbaines.net, guix-patches@gnu.org Resent-Date: Mon, 27 Mar 2023 18:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62490 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62490@debbugs.gnu.org Cc: Bruno Victal , ludo@gnu.org, maxim.cournoyer@gmail.com, mail@cbaines.net X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ludo@gnu.org, maxim.cournoyer@gmail.com, mail@cbaines.net Received: via spool by submit@debbugs.gnu.org id=B.167994308031104 (code B ref -1); Mon, 27 Mar 2023 18:52:02 +0000 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 Date: Mon, 27 Mar 2023 19:51:04 +0100 Message-Id: X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 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-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: 98663CB27 X-Spam-Score: -0.73 X-Migadu-Spam-Score: -0.73 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: 4ujjWb01T7C0 * 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