diff --git a/docs/castsponsorskip.md b/docs/castsponsorskip.md index 865d929..154026d 100644 --- a/docs/castsponsorskip.md +++ b/docs/castsponsorskip.md @@ -32,7 +32,7 @@ castsponsorskip [flags] -h, --help help for castsponsorskip --ignore-segment-duration duration Ignores the previous sponsored segment for a set amount of time. Useful if you want to to go back and watch a segment. (default 1m0s) --log-format string Log format (one of: auto, color, plain, json) (default "auto") - --log-level string Log level (one of: debug, info, warn, error) (default "info") + --log-level string Log level (one of: debug, info, warn, error, none) (default "info") --mute-ads Mutes the device while an ad is playing (default true) -i, --network-interface string Network interface to use for multicast dns discovery. (default all interfaces) --paused-interval duration Interval to scan paused devices (default 1m0s) diff --git a/docs/envs.md b/docs/envs.md index aba8a49..c2508b2 100644 --- a/docs/envs.md +++ b/docs/envs.md @@ -8,7 +8,7 @@ | `CSS_DISCOVER_INTERVAL` | Interval to restart the DNS discovery client | `5m0s` | | `CSS_IGNORE_SEGMENT_DURATION` | Ignores the previous sponsored segment for a set amount of time. Useful if you want to to go back and watch a segment. | `1m0s` | | `CSS_LOG_FORMAT` | Log format (one of: auto, color, plain, json) | `auto` | -| `CSS_LOG_LEVEL` | Log level (one of: debug, info, warn, error) | `info` | +| `CSS_LOG_LEVEL` | Log level (one of: debug, info, warn, error, none) | `info` | | `CSS_MUTE_ADS` | Mutes the device while an ad is playing | `true` | | `CSS_NETWORK_INTERFACE` | Network interface to use for multicast dns discovery. (default all interfaces) | ` ` | | `CSS_PAUSED_INTERVAL` | Interval to scan paused devices | `1m0s` | diff --git a/internal/config/completions.go b/internal/config/completions.go index 777d89c..189db8b 100644 --- a/internal/config/completions.go +++ b/internal/config/completions.go @@ -16,7 +16,7 @@ import ( func RegisterCompletions(cmd *cobra.Command) { if err := errors.Join( cmd.RegisterFlagCompletionFunc(names.FlagLogLevel, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { - return []string{"debug", "info", "warn", "error"}, cobra.ShellCompDirectiveNoFileComp | cobra.ShellCompDirectiveKeepOrder + return []string{"debug", "info", "warn", "error", "none"}, cobra.ShellCompDirectiveNoFileComp | cobra.ShellCompDirectiveKeepOrder }), cmd.RegisterFlagCompletionFunc(names.FlagNetworkInterface, completeNetworkInterface), cmd.RegisterFlagCompletionFunc(names.FlagDiscoverInterval, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { diff --git a/internal/config/config.go b/internal/config/config.go index 21e16c2..b04e87e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -57,7 +57,7 @@ func RegisterFlags(cmd *cobra.Command) { c := New() fs.String(names.FlagConfig, "", "Config file path") - fs.String(names.FlagLogLevel, c.LogLevel, "Log level (one of: debug, info, warn, error)") + fs.String(names.FlagLogLevel, c.LogLevel, "Log level (one of: debug, info, warn, error, none)") fs.String(names.FlagLogFormat, c.LogFormat, "Log format (one of: "+strings.Join(LogFormatStrings(), ", ")+")") fs.StringSlice(names.FlagDevices, c.DeviceAddrStrs, "Comma-separated list of device addresses. This will disable discovery and is not recommended unless discovery fails") diff --git a/internal/config/log.go b/internal/config/log.go index 5dc221c..ee153b4 100644 --- a/internal/config/log.go +++ b/internal/config/log.go @@ -23,7 +23,9 @@ const ( func (c *Config) InitLog(w io.Writer) { var level slog.Level - if err := level.UnmarshalText([]byte(c.LogLevel)); err != nil { + if c.LogLevel == "none" { + level = slog.LevelError + 1 + } else if err := level.UnmarshalText([]byte(c.LogLevel)); err != nil { slog.Warn("Invalid log level. Defaulting to info.", "value", c.LogLevel) level = slog.LevelInfo c.LogLevel = level.String()