lol

nixos/stubby: Support fine-grained logLevel

In much older versions, Stubby only supported debug logging, but that is
no longer true, so support the fine-grained log level.

authored by

Andrew Marshall and committed by
Emery Hemingway
87245df5 194fd9b4

+20 -6
+20 -6
nixos/modules/services/networking/stubby.nix
··· 7 7 settingsFormat = pkgs.formats.yaml { }; 8 8 confFile = settingsFormat.generate "stubby.yml" cfg.settings; 9 9 in { 10 - imports = map (x: 10 + imports = [ 11 + (mkRemovedOptionModule [ "stubby" "debugLogging" ] "Use services.stubby.logLevel = \"debug\"; instead.") 12 + ] ++ map (x: 11 13 (mkRemovedOptionModule [ "services" "stubby" x ] 12 14 "Stubby configuration moved to services.stubby.settings.")) [ 13 15 "authenticationMode" ··· 49 51 ''; 50 52 }; 51 53 52 - debugLogging = mkOption { 53 - default = false; 54 - type = types.bool; 55 - description = lib.mdDoc "Enable or disable debug level logging."; 54 + logLevel = let 55 + logLevels = { 56 + emerg = 0; 57 + alert = 1; 58 + crit = 2; 59 + error = 3; 60 + warning = 4; 61 + notice = 5; 62 + info = 6; 63 + debug = 7; 64 + }; 65 + in mkOption { 66 + default = null; 67 + type = types.nullOr (types.enum (attrNames logLevels ++ attrValues logLevels)); 68 + apply = v: if isString v then logLevels.${v} else v; 69 + description = lib.mdDoc "Log verbosity (syslog keyword or level)."; 56 70 }; 57 71 58 72 }; ··· 80 94 Type = "notify"; 81 95 AmbientCapabilities = "CAP_NET_BIND_SERVICE"; 82 96 CapabilityBoundingSet = "CAP_NET_BIND_SERVICE"; 83 - ExecStart = "${pkgs.stubby}/bin/stubby -C ${confFile} ${optionalString cfg.debugLogging "-l"}"; 97 + ExecStart = "${pkgs.stubby}/bin/stubby -C ${confFile} ${optionalString (cfg.logLevel != null) "-v ${toString cfg.logLevel}"}"; 84 98 DynamicUser = true; 85 99 CacheDirectory = "stubby"; 86 100 };