unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Bruno Victal <mirai@makinata.eu>
To: 63985@debbugs.gnu.org
Cc: Bruno Victal <mirai@makinata.eu>
Subject: [bug#63985] [PATCH v3 10/11] services: NetworkManager: add log-configuration field.
Date: Mon, 26 Jun 2023 22:59:36 +0100	[thread overview]
Message-ID: <79ae045eeb94e92221fcff8272cae9673c376f9b.1687816734.git.mirai@makinata.eu> (raw)
In-Reply-To: <cover.1687816304.git.mirai@makinata.eu>

* gnu/services/networking.scm (network-manager-log-level?)
(network-manager-log-domain?, network-manager-log-domains?): New predicate.
(serialize-network-manager-log-level, serialize-network-manager-log-domains):
New procedure.
(network-manager-log-configuration): New record type.
(network-manager-configuration)[log-configuration]: New field.
* doc/guix.texi (Networking Setup): Document it.
---
 doc/guix.texi               |  43 +++++++++++++++
 gnu/services/networking.scm | 107 ++++++++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 974bfa3fb0..76bd1b1413 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20361,6 +20361,10 @@ Networking Setup
 @code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet
 networks.
 
+@item @code{log-configuration} (default: @code{(network-manager-log-configuration)})
+Logging configuration for NetworkManager.
+This is a @code{<network-manager-log-configuration>} record object.
+
 @item @code{dns} (default: @code{"default"})
 Processing mode for DNS, which affects how NetworkManager uses the
 @code{resolv.conf} configuration file.
@@ -20412,6 +20416,45 @@ Networking Setup
 @end table
 @end deftp
 
+@deftp {Data Type} network-manager-log-configuration
+Available @code{network-manager-log-configuration} fields are:
+
+@table @asis
+@item @code{level} (type: maybe-network-manager-log-level)
+The default logging verbosity level.  Valid values are (in increasing
+order of verbosity): @code{'off}, @code{'err}, @code{'warn},
+@code{'info}, @code{'debug} and @code{'trace}.
+
+@item @code{domains} (type: maybe-network-manager-log-domains)
+Log messages by topic.  The value for this field is a list of
+@var{domains} or pairs of @var{domains} and @var{levels} where the valid
+values for @var{levels} are the same as those described in the ``level''
+field and @var{domains} are any of: @code{'platform}, @code{'rfkill},
+@code{'ether}, @code{'wifi}, @code{'bt}, @code{'mb}, @code{'dhcp4},
+@code{'dhcp6}, @code{'ppp}, @code{'wifi-scan}, @code{'ip4}, @code{'ip6},
+@code{'autoip4}, @code{'dns}, @code{'vpn}, @code{'sharing},
+@code{'supplicant}, @code{'agents}, @code{'settings}, @code{'suspend},
+@code{'core}, @code{'device}, @code{'olpc}, @code{'wimax},
+@code{'infiniband}, @code{'firewall}, @code{'adsl}, @code{'bond},
+@code{'vlan}, @code{'bridge}, @code{'dbus-props}, @code{'team},
+@code{'concheck}, @code{'dcb}, @code{'dispatch}, @code{'audit},
+@code{'systemd}, @code{'vpn-plugin}, @code{'proxy}, @code{'none},
+@code{'all}, @code{'default}, @code{'dhcp} and @code{'ip}.  The log
+level can be overrided per-domain in a pair with a @var{level}.
+For example:
+@lisp
+(network-manager-log-configuration
+  (level 'warn)
+  (domains '(all (wifi . debug) (wifi-scan . off))))
+@end lisp
+
+@item @code{audit?} (type: maybe-boolean)
+Whether to send audit records to @command{auditd}.
+
+@end table
+@end deftp
+
+
 @cindex Connman
 @defvar connman-service-type
 This is the service type to run @url{https://01.org/connman,Connman},
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 496ff0f0ec..33ff5e040f 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -78,7 +78,10 @@ (define-module (gnu services networking)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-43)
+  #:use-module (srfi srfi-171)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 string-fun)
   #:use-module (json)
   #:re-export (static-networking-service
                static-networking-service-type)
@@ -164,10 +167,16 @@ (define-module (gnu services networking)
             tor-hidden-service  ; deprecated
             tor-service-type
 
+            network-manager-log-configuration
+            network-manager-log-configuration?
+            network-manager-log-configuration-level
+            network-manager-log-configuration-domains?
+            network-manager-log-configuration-audit?
             network-manager-configuration
             network-manager-configuration?
             network-manager-configuration-package
             network-manager-configuration-shepherd-requirement
+            network-manager-configuration-log-configuration
             network-manager-configuration-dns
             network-manager-configuration-vpn-plugins
             network-manager-service-type
@@ -1158,6 +1167,92 @@ (define-record-type* <modem-manager-configuration>
 ;;; NetworkManager
 ;;;
 
+(define-maybe boolean)
+
+;; See the logging section at
+;; <https://networkmanager.dev/docs/api/latest/NetworkManager.conf.html> for
+;; the list of valid values for the predicates below.
+(define (network-manager-log-level? x)
+  (memq x '(off err warn info debug trace)))
+
+(define (network-manager-log-domain? x)
+  (memq x '(platform rfkill ether wifi bt mb dhcp4 dhcp6 ppp wifi-scan ip4 ip6
+                     autoip4 dns vpn sharing supplicant agents settings
+                     suspend core device olpc wimax infiniband firewall adsl
+                     bond vlan bridge dbus-props team concheck dcb dispatch
+                     audit systemd vpn-plugin proxy
+                     ;; Special NetworkManager domains:
+                     none all default dhcp ip)))
+
+(define (network-manager-log-domains? x)
+  (every
+   (match-lambda
+     (((? network-manager-log-domain?) . (? network-manager-log-level?)) #t)
+     ((? network-manager-log-domain?) #t)
+     (_ #f))
+   x))
+
+(define (serialize-network-manager-log-level field-name value)
+  `(logging level ,(format #f "~:@(~a~)" value)))
+
+(define (serialize-network-manager-log-domains field-name value)
+  (define (uglify-domain-symbol x)
+    (string-replace-substring (symbol->string x) "-" "_"))
+
+  (define serialize-entry
+    (match-lambda
+      (((= uglify-domain-symbol domain) . value)
+       (format #f "~:@(~a:~a~)" domain value))
+      ((= uglify-domain-symbol domain)
+       (format #f "~:@(~a~)" domain))))
+
+  (let ((serialized-value (list-transduce (compose (tmap serialize-entry)
+                                                   (tadd-between ","))
+                                          string-append value)))
+    `(logging domains ,serialized-value)))
+
+(define-maybe network-manager-log-level)
+(define-maybe network-manager-log-domains)
+
+;; This implicitly belongs to the INI "logging" section.
+(define-configuration network-manager-log-configuration
+  (level
+   maybe-network-manager-log-level
+   "The default logging verbosity level.  Valid values are (in increasing
+order of verbosity): @code{'off}, @code{'err}, @code{'warn}, @code{'info},
+@code{'debug} and @code{'trace}.")
+
+  (domains
+   maybe-network-manager-log-domains
+   "Log messages by topic. The value for this field is a list of @var{domains}
+or pairs of @var{domains} and @var{levels} where the valid values for
+@var{levels} are the same as those described in the ``level'' field and
+@var{domains} are any of: @code{'platform}, @code{'rfkill}, @code{'ether},
+@code{'wifi}, @code{'bt}, @code{'mb}, @code{'dhcp4}, @code{'dhcp6},
+@code{'ppp}, @code{'wifi-scan}, @code{'ip4}, @code{'ip6}, @code{'autoip4},
+@code{'dns}, @code{'vpn}, @code{'sharing}, @code{'supplicant}, @code{'agents},
+@code{'settings}, @code{'suspend}, @code{'core}, @code{'device}, @code{'olpc},
+@code{'wimax}, @code{'infiniband}, @code{'firewall}, @code{'adsl}, @code{'bond},
+@code{'vlan}, @code{'bridge}, @code{'dbus-props}, @code{'team}, @code{'concheck},
+@code{'dcb}, @code{'dispatch}, @code{'audit}, @code{'systemd},
+@code{'vpn-plugin}, @code{'proxy}, @code{'none}, @code{'all}, @code{'default},
+@code{'dhcp} and @code{'ip}.
+
+The log level can be overrided per-domain in a pair with a @var{level}.
+For example:
+@lisp
+(network-manager-log-configuration
+  (level 'warn)
+  (domains '(all (wifi . debug) (wifi-scan . off))))
+@end lisp")
+
+  (audit?
+   maybe-boolean
+   "Whether to send audit records to @command{auditd}."
+   (serializer generic-ini-serialize-boolean)
+   (serializer-options `(#:section logging
+                         #:field-name-transform ,(const 'audit)))))
+
 ;; TODO: deprecated field, remove later.
 (define (warn-iwd?-field-deprecation value)
   (when value
@@ -1181,6 +1276,18 @@ (define-configuration network-manager-configuration
 networks."
    empty-serializer)
 
+  (log-configuration
+   (network-manager-log-configuration (network-manager-log-configuration))
+   "Logging configuration for NetworkManager.  This is a
+@code{<network-manager-log-configuration>} record object."
+   (serializer
+    (lambda (_ value)
+      ;; Wrap the serialization of the log-configuration which is a list
+      ;; of INI entries in a ‘ini-entries’ object.
+      (ini-entries (list-transduce
+                    (base-transducer value) rcons
+                    network-manager-log-configuration-fields)))))
+
   (dns
    (string "default")
    "Processing mode for DNS, which affects how NetworkManager uses the
-- 
2.39.2





  parent reply	other threads:[~2023-06-26 22:03 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09 21:18 [bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration Bruno Victal
2023-06-09 21:20 ` [bug#63985] [PATCH RFC 1/5] services: configuration: Simplify normalize-extra-args Bruno Victal
2023-06-09 21:20 ` [bug#63985] [PATCH RFC 2/5] services: configuration: Use transducers within serialize-configuration Bruno Victal
2023-06-09 21:20 ` [bug#63985] [PATCH RFC 3/5] services: fstrim-service-type: Serialize with SRFI-171 transducers Bruno Victal
2023-06-09 21:20 ` [bug#63985] [PATCH RFC 4/5] services: configuration: Add serializer-kwargs field Bruno Victal
2023-06-09 21:21 ` [bug#63985] [PATCH RFC 5/5] services: configuration: New generic-ini module Bruno Victal
2023-06-10 20:10 ` [bug#63985] [PATCH RFC v2 1/5] services: configuration: Simplify normalize-extra-args Bruno Victal
2023-06-10 20:10 ` [bug#63985] [PATCH RFC v2 2/5] services: configuration: Use transducers within serialize-configuration Bruno Victal
2023-06-10 20:10 ` [bug#63985] [PATCH RFC v2 3/5] services: fstrim-service-type: Serialize with SRFI-171 transducers Bruno Victal
2023-06-10 20:10 ` [bug#63985] [PATCH RFC v2 4/5] services: configuration: Add serializer-options field Bruno Victal
2023-06-10 20:10 ` [bug#63985] [PATCH RFC v2 5/5] services: configuration: New generic-ini module Bruno Victal
2023-06-26 21:57 ` [bug#63985] [PATCH v3 00/11] Service subsystem improvements Bruno Victal
2023-06-26 21:59   ` [bug#63985] [PATCH v3 01/11] services: configuration: Simplify normalize-extra-args Bruno Victal
2023-10-02 17:00     ` [bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration Maxim Cournoyer
2023-10-07 12:36       ` [bug#63985] [PATCH v3 01/11] services: configuration: Simplify normalize-extra-args. (was: bug#63985: [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration) Bruno Victal
2023-06-26 21:59   ` [bug#63985] [PATCH v3 02/11] services: configuration: Use transducers within serialize-configuration Bruno Victal
2023-10-02 17:25     ` [bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration Maxim Cournoyer
2023-10-07 13:39       ` [bug#63985] [PATCH v3 02/11] services: configuration: Use transducers within serialize-configuration. (was : bug#63985: [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration) Bruno Victal
2023-10-07 14:37         ` Maxim Cournoyer
2023-06-26 21:59   ` [bug#63985] [PATCH v3 03/11] services: fstrim-service-type: Serialize with SRFI-171 transducers Bruno Victal
2023-06-26 21:59   ` [bug#63985] [PATCH v3 04/11] doc: Rewrite define-configuration Bruno Victal
2023-10-02 18:28     ` [bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration Maxim Cournoyer
2023-10-07 14:21       ` Bruno Victal
2023-10-07 16:35         ` Maxim Cournoyer
2023-06-26 21:59   ` [bug#63985] [PATCH v3 05/11] services: configuration: Add serializer-options field Bruno Victal
2023-10-02 19:12     ` [bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration Maxim Cournoyer
2023-10-06 18:29       ` Bruno Victal
2023-06-26 21:59   ` [bug#63985] [PATCH v3 06/11] services: configuration: New generic-ini module Bruno Victal
2023-10-02 19:15     ` [bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration Maxim Cournoyer
2023-06-26 21:59   ` [bug#63985] [PATCH v3 07/11] services: configuration: Add some commonly used predicates Bruno Victal
2023-06-26 21:59   ` [bug#63985] [PATCH v3 08/11] services: NetworkManager: Use define-configuration and generic-ini Bruno Victal
2023-06-26 21:59   ` [bug#63985] [PATCH v3 09/11] services: NetworkManager: Prefer package over network-manager Bruno Victal
2023-10-02 16:52     ` [bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration Maxim Cournoyer
2023-06-26 21:59   ` Bruno Victal [this message]
2023-10-05 16:57     ` [bug#63985] [PATCH v3 10/11] services: NetworkManager: add log-configuration field Maxim Cournoyer
2023-06-26 21:59   ` [bug#63985] [PATCH v3 11/11] services: NetworkManager: Add extra-options field Bruno Victal
2023-10-05 16:59     ` Maxim Cournoyer
2023-06-27  4:20   ` [bug#63985] [PATCH v3 00/11] Service subsystem improvements Liliana Marie Prikler
2023-09-16 21:22   ` Bruno Victal
2023-09-16 21:55     ` Liliana Marie Prikler
2023-09-23 13:35       ` Bruno Victal
2023-09-23 15:22         ` Liliana Marie Prikler
2023-09-25 14:06       ` Ludovic Courtès
2023-10-07 15:57 ` [bug#63985] [PATCH v4 0/5] SRFI-171 based improvements for define-configuration Bruno Victal
2023-10-07 15:57   ` [bug#63985] [PATCH v4 2/5] services: configuration: Use transducers within serialize-configuration Bruno Victal
2023-10-07 15:59   ` [bug#63985] [PATCH v4 1/5] services: configuration: Simplify normalize-extra-args Bruno Victal
2023-10-07 15:59   ` [bug#63985] [PATCH v4 3/5] services: fstrim-service-type: Serialize with SRFI-171 transducers Bruno Victal
2023-10-07 15:59   ` [bug#63985] [PATCH v4 4/5] doc: Rewrite define-configuration Bruno Victal
2023-10-07 15:59   ` [bug#63985] [PATCH v4 5/5] services: configuration: Add some commonly used predicates Bruno Victal
2023-10-07 16:57   ` bug#63985: SRFI-171 based improvements for define-configuration Maxim Cournoyer

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=79ae045eeb94e92221fcff8272cae9673c376f9b.1687816734.git.mirai@makinata.eu \
    --to=mirai@makinata.eu \
    --cc=63985@debbugs.gnu.org \
    /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).