diff --git a/CHANGELOG.md b/CHANGELOG.md index 320b87e..a3463e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,11 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass - [x] -# [0.4.0] - 2025-04-04 +# [0.4.1] - 2025-04-05 ### Changed -- `log-level` flag is now of type string. It accepts any one of trace, debug, info, warn, error, fatal or panic. +- `-loglevel` flag is now of type string. It accepts any one of trace, debug, info, warn, error, fatal or panic. - It defaults to warn. # [0.3.1] - 2025-03-31 diff --git a/README.md b/README.md index 5f2eed4..b3ee488 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ vbantxt -s=streamname "Point(ASIO128.IN[2],ASIO128.OUT[1]).dBGain = -8" ## `Logging` -The `-log-level` flag allows you to control the verbosity of the application's logging output. +The `-loglevel` flag allows you to control the verbosity of the application's logging output. Acceptable values for this flag are: @@ -131,7 +131,7 @@ Acceptable values for this flag are: For example, to set the log level to `debug`, you can use: ``` -vbantxt -s=streamname -log-level=debug "bus[0].eq.on=1 bus[1].gain=-12.8" +vbantxt -s=streamname -loglevel=debug "bus[0].eq.on=1 bus[1].gain=-12.8" ``` The default log level is `warn` if the flag is not specified. diff --git a/cmd/vbantxt/main.go b/cmd/vbantxt/main.go index f7c0472..1ac09fa 100644 --- a/cmd/vbantxt/main.go +++ b/cmd/vbantxt/main.go @@ -23,7 +23,7 @@ type opts struct { } func exit(err error) { - _, _ = fmt.Fprintf(os.Stderr, "Error: %s", err) + _, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err) os.Exit(1) } @@ -60,29 +60,16 @@ func main() { defaultConfigPath := filepath.Join(configDir, "vbantxt", "config.toml") flag.StringVar(&configPath, "config", defaultConfigPath, "config path") flag.StringVar(&configPath, "C", defaultConfigPath, "config path (shorthand)") - flag.StringVar(&loglevel, "log-level", "warn", "log level") + flag.StringVar(&loglevel, "loglevel", "warn", "log level") flag.StringVar(&loglevel, "l", "warn", "log level (shorthand)") flag.Parse() - switch loglevel { - case "trace": - log.SetLevel(log.TraceLevel) - case "debug": - log.SetLevel(log.DebugLevel) - case "info": - log.SetLevel(log.InfoLevel) - case "warn": - log.SetLevel(log.WarnLevel) - case "error": - log.SetLevel(log.ErrorLevel) - case "fatal": - log.SetLevel(log.FatalLevel) - case "panic": - log.SetLevel(log.PanicLevel) - default: + level, err := log.ParseLevel(loglevel) + if err != nil { exit(fmt.Errorf("invalid log level: %s", loglevel)) } + log.SetLevel(level) o := opts{ host: host,