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.
This commit is contained in:
parent
194fd9b484
commit
87245df5d3
1 changed files with 20 additions and 6 deletions
|
@ -7,7 +7,9 @@ let
|
||||||
settingsFormat = pkgs.formats.yaml { };
|
settingsFormat = pkgs.formats.yaml { };
|
||||||
confFile = settingsFormat.generate "stubby.yml" cfg.settings;
|
confFile = settingsFormat.generate "stubby.yml" cfg.settings;
|
||||||
in {
|
in {
|
||||||
imports = map (x:
|
imports = [
|
||||||
|
(mkRemovedOptionModule [ "stubby" "debugLogging" ] "Use services.stubby.logLevel = \"debug\"; instead.")
|
||||||
|
] ++ map (x:
|
||||||
(mkRemovedOptionModule [ "services" "stubby" x ]
|
(mkRemovedOptionModule [ "services" "stubby" x ]
|
||||||
"Stubby configuration moved to services.stubby.settings.")) [
|
"Stubby configuration moved to services.stubby.settings.")) [
|
||||||
"authenticationMode"
|
"authenticationMode"
|
||||||
|
@ -49,10 +51,22 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
debugLogging = mkOption {
|
logLevel = let
|
||||||
default = false;
|
logLevels = {
|
||||||
type = types.bool;
|
emerg = 0;
|
||||||
description = lib.mdDoc "Enable or disable debug level logging.";
|
alert = 1;
|
||||||
|
crit = 2;
|
||||||
|
error = 3;
|
||||||
|
warning = 4;
|
||||||
|
notice = 5;
|
||||||
|
info = 6;
|
||||||
|
debug = 7;
|
||||||
|
};
|
||||||
|
in mkOption {
|
||||||
|
default = null;
|
||||||
|
type = types.nullOr (types.enum (attrNames logLevels ++ attrValues logLevels));
|
||||||
|
apply = v: if isString v then logLevels.${v} else v;
|
||||||
|
description = lib.mdDoc "Log verbosity (syslog keyword or level).";
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -80,7 +94,7 @@ in {
|
||||||
Type = "notify";
|
Type = "notify";
|
||||||
AmbientCapabilities = "CAP_NET_BIND_SERVICE";
|
AmbientCapabilities = "CAP_NET_BIND_SERVICE";
|
||||||
CapabilityBoundingSet = "CAP_NET_BIND_SERVICE";
|
CapabilityBoundingSet = "CAP_NET_BIND_SERVICE";
|
||||||
ExecStart = "${pkgs.stubby}/bin/stubby -C ${confFile} ${optionalString cfg.debugLogging "-l"}";
|
ExecStart = "${pkgs.stubby}/bin/stubby -C ${confFile} ${optionalString (cfg.logLevel != null) "-v ${toString cfg.logLevel}"}";
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
CacheDirectory = "stubby";
|
CacheDirectory = "stubby";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue