From: Bruno Victal <mirai@makinata.eu>
To: 62490@debbugs.gnu.org
Cc: ludo@gnu.org, Bruno Victal <mirai@makinata.eu>,
maxim.cournoyer@gmail.com
Subject: [bug#62490] [PATCH v2 1/2] services: nginx: Make logging level configurable.
Date: Mon, 3 Apr 2023 12:58:02 +0100 [thread overview]
Message-ID: <4027e6a1d7a59e11a7f4000b821283a1985f1dcc.1680523067.git.mirai@makinata.eu> (raw)
In-Reply-To: <fa44bc8a46021c3d307479ea2fbdf04d68e0cd10.1679942599.git.mirai@makinata.eu>
* gnu/services/web.scm (<nginx-configuration>)[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 <go.wigust@gmail.com>
;;; Copyright © 2020, 2021 Alexandru-Sergiu Marton <brown121407@posteo.ro>
;;; Copyright © 2022 Simen Endsjø <simendsjo@gmail.com>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
;;;
;;; 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* <nginx-configuration>
(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* <nginx-configuration>
(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-configuration>
(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
next prev parent reply other threads:[~2023-04-03 11:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 18:51 [bug#62490] [PATCH] services: nginx: Make logging level configurable Bruno Victal
2023-03-28 14:12 ` Maxim Cournoyer
2023-03-28 14:32 ` Bruno Victal
2023-03-28 15:03 ` Maxim Cournoyer
2023-04-02 15:39 ` Ludovic Courtès
2023-04-11 17:12 ` bug#62490: " Maxim Cournoyer
2023-04-03 11:58 ` Bruno Victal [this message]
2023-04-03 11:58 ` [bug#62490] [PATCH v2 2/2] services: nginx: Add reopen action Bruno Victal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4027e6a1d7a59e11a7f4000b821283a1985f1dcc.1680523067.git.mirai@makinata.eu \
--to=mirai@makinata.eu \
--cc=62490@debbugs.gnu.org \
--cc=ludo@gnu.org \
--cc=maxim.cournoyer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).