diff --git a/lib/logging.go b/lib/logging.go index cc7466a0..33b9eb2f 100644 --- a/lib/logging.go +++ b/lib/logging.go @@ -10,6 +10,7 @@ var ( loggingTemplateDebug = "{{datetime}} {{level}} [{{caller}}] {{message}} {{data}} {{extra}}\n" loggingTemplate = "{{datetime}} {{level}} {{message}} {{data}} {{extra}}\n" logger *slog.Logger + ErrorLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel} NormalLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel, slog.WarnLevel, slog.InfoLevel} NoticeLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel, slog.WarnLevel, slog.InfoLevel, slog.NoticeLevel} DebugLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel, slog.WarnLevel, slog.InfoLevel, slog.NoticeLevel, slog.DebugLevel} @@ -24,6 +25,10 @@ func InitLogger(logLevel string) *slog.Logger { var h *handler.ConsoleHandler switch logLevel { + case "ERROR": + h = handler.NewConsoleHandler(ErrorLogging) + formatter.SetTemplate(loggingTemplateDebug) + break case "TRACE": h = handler.NewConsoleHandler(TraceLogging) formatter.SetTemplate(loggingTemplateDebug) diff --git a/lib/param_parsing/parameters.go b/lib/param_parsing/parameters.go index dc02437b..8fb8e826 100644 --- a/lib/param_parsing/parameters.go +++ b/lib/param_parsing/parameters.go @@ -42,7 +42,7 @@ func GetParameters() Params { getopt.StringVarLong(¶ms.LatestPre, "latest-pre", 'p', "Latest pre-release implicit version. Ex: tfswitch --latest-pre 0.13 downloads 0.13.0-rc1 (latest)") getopt.StringVarLong(¶ms.LatestStable, "latest-stable", 's', "Latest implicit version based on a constraint. Ex: tfswitch --latest-stable 0.13.0 downloads 0.13.7 and 0.13 downloads 0.15.5 (latest)") getopt.BoolVarLong(¶ms.ListAllFlag, "list-all", 'l', "List all versions of terraform - including beta and rc") - getopt.StringVarLong(¶ms.LogLevel, "log-level", 'g', "Set loglevel for tfswitch. One of (INFO, NOTICE, DEBUG, TRACE)") + getopt.StringVarLong(¶ms.LogLevel, "log-level", 'g', "Set loglevel for tfswitch. One of (ERROR, INFO, NOTICE, DEBUG, TRACE)") getopt.StringVarLong(¶ms.MirrorURL, "mirror", 'm', "install from a remote API other than the default. Default: "+lib.DefaultMirror) getopt.BoolVarLong(¶ms.ShowLatestFlag, "show-latest", 'U', "Show latest stable version") getopt.StringVarLong(¶ms.ShowLatestPre, "show-latest-pre", 'P', "Show latest pre-release implicit version. Ex: tfswitch --show-latest-pre 0.13 prints 0.13.0-rc1 (latest)")