diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 3fc7332..615779c 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -20,7 +20,7 @@ The CLI is communicating with the Supervisor using the Supervisor's HTTP REST AP - **CLI Framework**: Cobra (github.com/spf13/cobra) - **HTTP Client**: Resty (github.com/go-resty/resty/v2) - **Configuration**: Viper (github.com/spf13/viper) -- **Logging**: Logrus (github.com/sirupsen/logrus) +- **Logging**: Go stdlib log/slog ## Available Commands The CLI provides the following main command categories: @@ -62,7 +62,7 @@ The CLI provides the following main command categories: - Uses Cobra for command structure and flag parsing - Resty for HTTP API calls to Home Assistant Supervisor - Viper for configuration management -- Logrus for structured logging +- Go stdlib log/slog for structured logging - Custom spinner implementation for progress indication ## Testing diff --git a/client/client.go b/client/client.go index 176877a..ebc176c 100644 --- a/client/client.go +++ b/client/client.go @@ -2,11 +2,11 @@ package client import ( "fmt" + "log/slog" "net/http" "time" resty "github.com/go-resty/resty/v2" - log "github.com/sirupsen/logrus" ) // RawJSON controls if the client does json handling or outputs it raw @@ -61,7 +61,7 @@ func genericJSONMethod(get bool, section, command string, body map[string]any, t resp, err = request.Get(url) } else { if len(body) > 0 { - log.WithField("body", body).Debug("Request body") + slog.Debug("Request body", "body", body) request.SetBody(body) } resp, err = request.Post(url) diff --git a/client/helper.go b/client/helper.go index da5b054..0e85b1e 100644 --- a/client/helper.go +++ b/client/helper.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "log/slog" "net/url" "os" "os/signal" @@ -18,7 +19,6 @@ import ( yaml "github.com/ghodss/yaml" resty "github.com/go-resty/resty/v2" - log "github.com/sirupsen/logrus" "github.com/spf13/viper" "strings" @@ -43,11 +43,7 @@ type Response struct { // URLHelper returns a URL built from the arguments func URLHelper(section, command string) (string, error) { base := viper.GetString("endpoint") - log.WithFields(log.Fields{ - "base": base, - "section": section, - "command": command, - }).Debug("[GenerateURI]") + slog.Debug("[GenerateURI]", "base", base, "section", section, "command", command) scheme := "" if !strings.Contains(base, "://") { @@ -69,11 +65,7 @@ func URLHelper(section, command string) (string, error) { myurl.Path = path.Clean(myurl.Path) res, _ := url.PathUnescape(myurl.String()) - log.WithFields(log.Fields{ - "uri": uri, - "url": myurl, - "url(string)": res, - }).Debug("[GenerateURI] Result") + slog.Debug("[GenerateURI] Result", "uri", uri, "url", myurl, "url(string)", res) return res, nil } @@ -108,15 +100,7 @@ func GetRequestTimeout(timeout time.Duration) *resty.Request { // Registering Response Middleware client.OnAfterResponse(func(c *resty.Client, resp *resty.Response) error { // explore response object - log.WithFields(log.Fields{ - "statuscode": resp.StatusCode(), - "status": resp.Status(), - "time": resp.Time(), - "received-at": resp.ReceivedAt(), - "headers": resp.Header(), - "request": resp.Request.RawRequest, - "body": resp, - }).Debug("Response") + slog.Debug("Response", "statuscode", resp.StatusCode(), "status", resp.Status(), "time", resp.Time(), "received-at", resp.ReceivedAt(), "headers", resp.Header(), "request", resp.Request.RawRequest, "body", resp) return nil // if its success otherwise return error }) diff --git a/cmd/apps.go b/cmd/apps.go index 81583cf..5eb9924 100644 --- a/cmd/apps.go +++ b/cmd/apps.go @@ -1,11 +1,11 @@ package cmd import ( + "log/slog" "os" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -30,7 +30,7 @@ information commands for apps.`, rootCmd.PersistentPreRun(cmd, args) }, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps") + slog.Debug("apps", "args", args) section := "addons" command := "" @@ -46,7 +46,7 @@ information commands for apps.`, } func init() { - log.Debug("Init apps") + slog.Debug("Init apps") rootCmd.AddCommand(appsCmd) } diff --git a/cmd/apps_changelog.go b/cmd/apps_changelog.go index 536443b..d1c7b95 100644 --- a/cmd/apps_changelog.go +++ b/cmd/apps_changelog.go @@ -3,9 +3,9 @@ package cmd import ( "errors" "fmt" + "log/slog" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -22,7 +22,7 @@ ha apps changelog core_mosquitto`, ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps changelog") + slog.Debug("apps changelog", "args", args) section := "addons" command := "{slug}/changelog" @@ -48,7 +48,7 @@ ha apps changelog core_mosquitto`, // returns 200 OK or 400, everything else is wrong if err == nil && resp.StatusCode() != 200 && resp.StatusCode() != 400 { err = errors.New("unexpected server response") - log.Error(err) + slog.Error("unexpected server response", "status", resp.StatusCode()) } if err != nil { diff --git a/cmd/apps_info.go b/cmd/apps_info.go index d0f73e8..e7d3971 100644 --- a/cmd/apps_info.go +++ b/cmd/apps_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -21,7 +22,7 @@ is provided, information about a specific app. ValidArgsFunction: appsCompletions, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps info") + slog.Debug("apps info", "args", args) section := "addons" command := "{slug}/info" diff --git a/cmd/apps_install.go b/cmd/apps_install.go index ab2f708..c39d562 100644 --- a/cmd/apps_install.go +++ b/cmd/apps_install.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command allows you to install a Home Assistant app from the commandline. ValidArgsFunction: storeAppCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps install") + slog.Debug("apps install", "args", args) section := "addons" command := "{slug}/install" diff --git a/cmd/apps_logs.go b/cmd/apps_logs.go index 9510b34..37b78e4 100644 --- a/cmd/apps_logs.go +++ b/cmd/apps_logs.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Allowing you to look at the log output generated by a Home Assistant app. ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps logs") + slog.Debug("apps logs", "args", args) section := "addons/{slug}" diff --git a/cmd/apps_rebuild.go b/cmd/apps_rebuild.go index f0989eb..15bcd53 100644 --- a/cmd/apps_rebuild.go +++ b/cmd/apps_rebuild.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -24,7 +25,7 @@ of apps. This command allows you to trigger a rebuild of a locally built app. ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps rebuild") + slog.Debug("apps rebuild", "args", args) section := "addons" command := "{slug}/rebuild" diff --git a/cmd/apps_restart.go b/cmd/apps_restart.go index a7d0ced..0091a19 100644 --- a/cmd/apps_restart.go +++ b/cmd/apps_restart.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Restart a Home Assistant app ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps restart") + slog.Debug("apps restart", "args", args) section := "addons" command := "{slug}/restart" diff --git a/cmd/apps_start.go b/cmd/apps_start.go index 51c961b..5e202f1 100644 --- a/cmd/apps_start.go +++ b/cmd/apps_start.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command allows you to manually start a stopped Home Assistant app ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps start") + slog.Debug("apps start", "args", args) section := "addons" command := "{slug}/start" diff --git a/cmd/apps_stats.go b/cmd/apps_stats.go index 2c9753d..7e94337 100644 --- a/cmd/apps_stats.go +++ b/cmd/apps_stats.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ how much CPU, memory, disk & network resources it uses. ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps stats") + slog.Debug("apps stats", "args", args) section := "addons" command := "{slug}/stats" diff --git a/cmd/apps_stop.go b/cmd/apps_stop.go index 53dde79..e111955 100644 --- a/cmd/apps_stop.go +++ b/cmd/apps_stop.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command allows you to manually stop a Home Assistant app ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps stop") + slog.Debug("apps stop", "args", args) section := "addons" command := "{slug}/stop" diff --git a/cmd/apps_uninstall.go b/cmd/apps_uninstall.go index a13ed53..a6d9925 100644 --- a/cmd/apps_uninstall.go +++ b/cmd/apps_uninstall.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command allows you to uninstall a Home Assistant app. ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps uninstall") + slog.Debug("apps uninstall", "args", args) section := "addons" command := "{slug}/uninstall" diff --git a/cmd/apps_update.go b/cmd/apps_update.go index f1e4ad8..ce339cb 100644 --- a/cmd/apps_update.go +++ b/cmd/apps_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ It is currently not possible to upgrade/downgrade to a specific version. ValidArgsFunction: appsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("apps update") + slog.Debug("apps update", "args", args) section := "addons" command := "{slug}/update" @@ -51,7 +52,7 @@ It is currently not possible to upgrade/downgrade to a specific version. } if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/audio.go b/cmd/audio.go index c47aa84..afc665b 100644 --- a/cmd/audio.go +++ b/cmd/audio.go @@ -1,7 +1,8 @@ package cmd import ( - log "github.com/sirupsen/logrus" + "log/slog" + "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ Control audio devices. } func init() { - log.Debug("Init audio") + slog.Debug("Init audio") rootCmd.AddCommand(audioCmd) } diff --git a/cmd/audio_default.go b/cmd/audio_default.go index 87f4c4d..9b3585a 100644 --- a/cmd/audio_default.go +++ b/cmd/audio_default.go @@ -1,7 +1,8 @@ package cmd import ( - log "github.com/sirupsen/logrus" + "log/slog" + "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Set the default input/output audio device of your Home Assistant system. } func init() { - log.Debug("Init audio default") + slog.Debug("Init audio default") audioCmd.AddCommand(audioDefaultCmd) } diff --git a/cmd/audio_default_input.go b/cmd/audio_default_input.go index 5902aca..15c2f5b 100644 --- a/cmd/audio_default_input.go +++ b/cmd/audio_default_input.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Home Assistant Audio on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio default input") + slog.Debug("audio default input", "args", args) section := "audio" command := "default/input" diff --git a/cmd/audio_default_output.go b/cmd/audio_default_output.go index 3a156a2..24ec8f4 100644 --- a/cmd/audio_default_output.go +++ b/cmd/audio_default_output.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Home Assistant Audio on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio default output") + slog.Debug("audio default output", "args", args) section := "audio" command := "default/output" diff --git a/cmd/audio_info.go b/cmd/audio_info.go index d5975e8..cedbd40 100644 --- a/cmd/audio_info.go +++ b/cmd/audio_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ running on your Home Assistant system, including its devices.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio info") + slog.Debug("audio info", "args", args) section := "audio" command := "info" diff --git a/cmd/audio_logs.go b/cmd/audio_logs.go index 367ec83..565419b 100644 --- a/cmd/audio_logs.go +++ b/cmd/audio_logs.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ running on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio logs") + slog.Debug("audio logs", "args", args) section := "audio" diff --git a/cmd/audio_profile.go b/cmd/audio_profile.go index 325dcc5..e1895a5 100644 --- a/cmd/audio_profile.go +++ b/cmd/audio_profile.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ This command allows you to set the audio profile on a audio card.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio profile") + slog.Debug("audio profile", "args", args) section := "audio" command := "profile" diff --git a/cmd/audio_reload.go b/cmd/audio_reload.go index 0b9c34c..7b74240 100644 --- a/cmd/audio_reload.go +++ b/cmd/audio_reload.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ all data and devices it currently has.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio reload") + slog.Debug("audio reload", "args", args) section := "audio" command := "reload" diff --git a/cmd/audio_restart.go b/cmd/audio_restart.go index aa286bd..f60d646 100644 --- a/cmd/audio_restart.go +++ b/cmd/audio_restart.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -16,7 +17,7 @@ var audioRestartCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio restart") + slog.Debug("audio restart", "args", args) section := "audio" command := "restart" diff --git a/cmd/audio_stats.go b/cmd/audio_stats.go index ad416e1..6ba2e3a 100644 --- a/cmd/audio_stats.go +++ b/cmd/audio_stats.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ It shows you how much CPU, memory, disk & network resources it uses.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio stats") + slog.Debug("audio stats", "args", args) section := "audio" command := "stats" diff --git a/cmd/audio_update.go b/cmd/audio_update.go index c79b369..3d5c1c1 100644 --- a/cmd/audio_update.go +++ b/cmd/audio_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ instance running on your system to the latest version or the version specified.` ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio update") + slog.Debug("audio update", "args", args) section := "audio" command := "update" diff --git a/cmd/audio_volume.go b/cmd/audio_volume.go index 0bf6fab..933be6e 100644 --- a/cmd/audio_volume.go +++ b/cmd/audio_volume.go @@ -1,9 +1,9 @@ package cmd import ( + "log/slog" "strconv" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -23,7 +23,7 @@ Control the volume of your audio devices. } func init() { - log.Debug("Init audio volume") + slog.Debug("Init audio volume") audioCmd.AddCommand(audioVolumeCmd) } diff --git a/cmd/audio_volume_input.go b/cmd/audio_volume_input.go index ebab83e..16c4378 100644 --- a/cmd/audio_volume_input.go +++ b/cmd/audio_volume_input.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -24,7 +25,7 @@ input channel or application on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio volume input") + slog.Debug("audio volume input", "args", args) section := "audio" command := "volume/input" diff --git a/cmd/audio_volume_output.go b/cmd/audio_volume_output.go index faa5ce4..d123e9a 100644 --- a/cmd/audio_volume_output.go +++ b/cmd/audio_volume_output.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -24,7 +25,7 @@ output channel or application on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("audio volume output") + slog.Debug("audio volume output", "args", args) section := "audio" command := "volume/output" diff --git a/cmd/auth.go b/cmd/auth.go index c95a4b0..8ec82b0 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -1,7 +1,8 @@ package cmd import ( - log "github.com/sirupsen/logrus" + "log/slog" + "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ The authentication command allows you to manage Home Assistant user accounts. } func init() { - log.Debug("Init authentication") + slog.Debug("Init authentication") rootCmd.AddCommand(authCmd) } diff --git a/cmd/auth_cache.go b/cmd/auth_cache.go index 16501aa..ce785ff 100644 --- a/cmd/auth_cache.go +++ b/cmd/auth_cache.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command allows you to reset the internal password cache of a Home Assistant ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("auth cache") + slog.Debug("auth cache", "args", args) section := "auth" command := "cache" diff --git a/cmd/auth_list.go b/cmd/auth_list.go index d3b66d8..a315686 100644 --- a/cmd/auth_list.go +++ b/cmd/auth_list.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -21,7 +22,7 @@ only work on some locations. For example, the Operating System CLI. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("auth list") + slog.Debug("auth list", "args", args) section := "auth" command := "list" diff --git a/cmd/auth_reset.go b/cmd/auth_reset.go index 3f0957c..f17b753 100644 --- a/cmd/auth_reset.go +++ b/cmd/auth_reset.go @@ -2,9 +2,9 @@ package cmd import ( "fmt" + "log/slog" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -78,7 +78,7 @@ only work on some locations. For example, the Operating System CLI. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("auth reset") + slog.Debug("auth reset", "args", args) section := "auth" command := "reset" diff --git a/cmd/available_updates.go b/cmd/available_updates.go index 34e0751..d892766 100644 --- a/cmd/available_updates.go +++ b/cmd/available_updates.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command provides information about the currently pending updates on the sys ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("available_updates") + slog.Debug("available_updates", "args", args) section := "available_updates" command := "" diff --git a/cmd/backups.go b/cmd/backups.go index 762ebf7..487edb4 100644 --- a/cmd/backups.go +++ b/cmd/backups.go @@ -1,11 +1,11 @@ package cmd import ( + "log/slog" "os" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -30,7 +30,7 @@ restore, and delete using this command.`, rootCmd.PersistentPreRun(cmd, args) }, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups") + slog.Debug("backups", "args", args) section := "backups" command := "info" @@ -46,7 +46,7 @@ restore, and delete using this command.`, } func init() { - log.Debug("Init backups") + slog.Debug("Init backups") // add cmd to root command rootCmd.AddCommand(backupsCmd) } diff --git a/cmd/backups_freeze.go b/cmd/backups_freeze.go index 49010d2..7243125 100644 --- a/cmd/backups_freeze.go +++ b/cmd/backups_freeze.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ or snapshot taken by external software. Caller should call thaw when done.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups freeze") + slog.Debug("backups freeze", "args", args) section := "backups" command := "freeze" diff --git a/cmd/backups_info.go b/cmd/backups_info.go index 0fdb1f2..67433d9 100644 --- a/cmd/backups_info.go +++ b/cmd/backups_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ This command gives you information about a specific backup.`, ValidArgsFunction: backupsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups info") + slog.Debug("backups info", "args", args) section := "backups" command := "{slug}/info" diff --git a/cmd/backups_new.go b/cmd/backups_new.go index b1134bb..c23286f 100644 --- a/cmd/backups_new.go +++ b/cmd/backups_new.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -22,7 +23,7 @@ backup.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups new") + slog.Debug("backups new", "args", args) section := "backups" command := "new/full" @@ -42,7 +43,7 @@ backup.`, apps, err := cmd.Flags().GetStringArray("app") addonsDeprecated, _ := cmd.Flags().GetStringArray("addons") apps = append(apps, addonsDeprecated...) - log.WithField("app", apps).Debug("app") + slog.Debug("apps", "apps", apps) if len(apps) != 0 && err == nil && (cmd.Flags().Changed("app") || cmd.Flags().Changed("addons")) { options["addons"] = apps @@ -50,7 +51,7 @@ backup.`, } folders, err := cmd.Flags().GetStringArray("folders") - log.WithField("folders", folders).Debug("folders") + slog.Debug("folders", "folders", folders) if len(folders) != 0 && err == nil && cmd.Flags().Changed("folders") { options["folders"] = folders @@ -62,13 +63,13 @@ backup.`, } location, err := cmd.Flags().GetStringArray("location") - log.WithField("location", location).Debug("location") + slog.Debug("location", "location", location) if len(location) > 0 && err == nil && cmd.Flags().Changed("location") { options["location"] = location } filename, err := cmd.Flags().GetString("filename") - log.WithField("filename", filename).Debug("filename") + slog.Debug("filename", "filename", filename) if filename != "" && err == nil && cmd.Flags().Changed("filename") { options["filename"] = filename } diff --git a/cmd/backups_options.go b/cmd/backups_options.go index fcf2a35..e006a3a 100644 --- a/cmd/backups_options.go +++ b/cmd/backups_options.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -20,7 +20,7 @@ This command allows you to set configuration options for backup manager.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups options") + slog.Debug("backups options", "args", args) section := "backups" command := "options" diff --git a/cmd/backups_reload.go b/cmd/backups_reload.go index c817d6a..f2368df 100644 --- a/cmd/backups_reload.go +++ b/cmd/backups_reload.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ on disk`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups reload") + slog.Debug("backups reload", "args", args) section := "backups" command := "reload" diff --git a/cmd/backups_remove.go b/cmd/backups_remove.go index 634e38e..57238b8 100644 --- a/cmd/backups_remove.go +++ b/cmd/backups_remove.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ clean backups from disk.`, ValidArgsFunction: backupsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups remove") + slog.Debug("backups remove", "args", args) section := "backups" command := "{slug}" @@ -39,13 +40,13 @@ clean backups from disk.`, }) location, err := cmd.Flags().GetStringArray("location") - log.WithField("location", location).Debug("location") + slog.Debug("location", "location", location) if len(location) > 0 && err == nil && cmd.Flags().Changed(("location")) { options["location"] = location } if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/backups_restore.go b/cmd/backups_restore.go index 0a9cc36..b58a219 100644 --- a/cmd/backups_restore.go +++ b/cmd/backups_restore.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ take Home Assistant backup on your system.`, ValidArgsFunction: backupsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups restore") + slog.Debug("backups restore", "args", args) section := "backups/{slug}" command := "restore/full" @@ -48,7 +49,7 @@ take Home Assistant backup on your system.`, apps, err := cmd.Flags().GetStringArray("app") addonsDeprecated, _ := cmd.Flags().GetStringArray("addons") apps = append(apps, addonsDeprecated...) - log.WithField("app", apps).Debug("app") + slog.Debug("apps", "apps", apps) if len(apps) > 0 && err == nil { options["addons"] = apps @@ -56,7 +57,7 @@ take Home Assistant backup on your system.`, } folders, err := cmd.Flags().GetStringArray("folders") - log.WithField("folders", folders).Debug("folders") + slog.Debug("folders", "folders", folders) if len(folders) > 0 && err == nil { options["folders"] = folders @@ -76,7 +77,7 @@ take Home Assistant backup on your system.`, } if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/backups_thaw.go b/cmd/backups_thaw.go index 7f08189..edf2da1 100644 --- a/cmd/backups_thaw.go +++ b/cmd/backups_thaw.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ has completed.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("backups thaw") + slog.Debug("backups thaw", "args", args) section := "backups" command := "thaw" diff --git a/cmd/banner.go b/cmd/banner.go index aa139a9..f50b8e3 100644 --- a/cmd/banner.go +++ b/cmd/banner.go @@ -2,11 +2,11 @@ package cmd import ( "fmt" + "log/slog" "strings" "time" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -65,7 +65,7 @@ var bannerCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("info") + slog.Debug("info", "args", args) fmt.Print(haBanner) fmt.Println() diff --git a/cmd/cli_info.go b/cmd/cli_info.go index 910a8ae..2ff8a72 100644 --- a/cmd/cli_info.go +++ b/cmd/cli_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Shows information about the internally running Home Assistant CLI backend ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("cli info") + slog.Debug("cli info", "args", args) section := "cli" command := "info" diff --git a/cmd/cli_stats.go b/cmd/cli_stats.go index 4ce5035..4481328 100644 --- a/cmd/cli_stats.go +++ b/cmd/cli_stats.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ It shows you how much CPU, memory, disk & network resources it uses. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("cli stats") + slog.Debug("cli stats", "args", args) section := "cli" command := "stats" diff --git a/cmd/cli_update.go b/cmd/cli_update.go index 1c0de1e..e7a23e2 100644 --- a/cmd/cli_update.go +++ b/cmd/cli_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ CLI backend, to the latest version or the version specified. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("cli update") + slog.Debug("cli update", "args", args) section := "cli" command := "update" diff --git a/cmd/core_check.go b/cmd/core_check.go index 5109a98..034e648 100644 --- a/cmd/core_check.go +++ b/cmd/core_check.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ Home Assistant Core.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core check") + slog.Debug("core check", "args", args) section := "core" command := "check" diff --git a/cmd/core_info.go b/cmd/core_info.go index 8f703a4..ee09a9a 100644 --- a/cmd/core_info.go +++ b/cmd/core_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ running on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core info") + slog.Debug("core info", "args", args) section := "core" command := "info" diff --git a/cmd/core_logs.go b/cmd/core_logs.go index cda81fb..b0b3284 100644 --- a/cmd/core_logs.go +++ b/cmd/core_logs.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ running on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core logs") + slog.Debug("core logs", "args", args) section := "core" diff --git a/cmd/core_options.go b/cmd/core_options.go index 09e26be..cd173a8 100644 --- a/cmd/core_options.go +++ b/cmd/core_options.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -21,7 +21,7 @@ instance running on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core options") + slog.Debug("core options", "args", args) section := "core" command := "options" diff --git a/cmd/core_rebuild.go b/cmd/core_rebuild.go index 41d952b..5cf3941 100644 --- a/cmd/core_rebuild.go +++ b/cmd/core_rebuild.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Don't worry, this does not delete your config.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core rebuild") + slog.Debug("core rebuild", "args", args) section := "core" command := "rebuild" diff --git a/cmd/core_restart.go b/cmd/core_restart.go index c61e243..a304cb9 100644 --- a/cmd/core_restart.go +++ b/cmd/core_restart.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ Restart the Home Assistant Core instance running on your system`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core restart") + slog.Debug("core restart", "args", args) section := "core" command := "restart" diff --git a/cmd/core_start.go b/cmd/core_start.go index 46e9326..f268694 100644 --- a/cmd/core_start.go +++ b/cmd/core_start.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ your system. This, of course, only applies when it has been stopped.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core start") + slog.Debug("core start", "args", args) section := "core" command := "start" diff --git a/cmd/core_stats.go b/cmd/core_stats.go index 25e62c4..1de9887 100644 --- a/cmd/core_stats.go +++ b/cmd/core_stats.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ It shows you how much CPU, memory, disk & network resources it uses.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core stats") + slog.Debug("core stats", "args", args) section := "core" command := "stats" diff --git a/cmd/core_stop.go b/cmd/core_stop.go index 19d5fd3..00cb884 100644 --- a/cmd/core_stop.go +++ b/cmd/core_stop.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ your system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core stop") + slog.Debug("core stop", "args", args) section := "core" command := "stop" diff --git a/cmd/core_update.go b/cmd/core_update.go index 117f925..6f57466 100644 --- a/cmd/core_update.go +++ b/cmd/core_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ running on your system to the latest version or the version specified.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("core update") + slog.Debug("core update", "args", args) section := "core" command := "update" diff --git a/cmd/dns_info.go b/cmd/dns_info.go index 2d7d6a8..94cce76 100644 --- a/cmd/dns_info.go +++ b/cmd/dns_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Shows information about the internally running Home Assistant DNS server ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("dns info") + slog.Debug("dns info", "args", args) section := "dns" command := "info" diff --git a/cmd/dns_logs.go b/cmd/dns_logs.go index afcc54e..a2f9183 100644 --- a/cmd/dns_logs.go +++ b/cmd/dns_logs.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Allowing you to look at the log output generated by the Home Assistant DNS serve ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("dns logs") + slog.Debug("dns logs", "args", args) section := "dns" diff --git a/cmd/dns_options.go b/cmd/dns_options.go index 0dc49a5..4e598d3 100644 --- a/cmd/dns_options.go +++ b/cmd/dns_options.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ running Home Assistant DNS server. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("dns options") + slog.Debug("dns options", "args", args) section := "dns" command := "options" @@ -28,7 +29,7 @@ running Home Assistant DNS server. options := make(map[string]any) servers, err := cmd.Flags().GetStringArray("servers") - log.WithField("servers", servers).Debug("servers") + slog.Debug("servers", "servers", servers) if len(servers) >= 1 && err == nil { options["servers"] = servers diff --git a/cmd/dns_reset.go b/cmd/dns_reset.go index 8dc6b1f..b2f9e21 100644 --- a/cmd/dns_reset.go +++ b/cmd/dns_reset.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -14,7 +15,7 @@ var dnsResetCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("dns reset") + slog.Debug("dns reset", "args", args) section := "dns" command := "reset" diff --git a/cmd/dns_restart.go b/cmd/dns_restart.go index 39e9792..1376a7f 100644 --- a/cmd/dns_restart.go +++ b/cmd/dns_restart.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -16,7 +17,7 @@ var dnsRestartCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("dns restart") + slog.Debug("dns restart", "args", args) section := "dns" command := "restart" diff --git a/cmd/dns_stats.go b/cmd/dns_stats.go index 1eefd7f..c264565 100644 --- a/cmd/dns_stats.go +++ b/cmd/dns_stats.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ It shows you how much CPU, memory, disk & network resources it uses. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("dns stats") + slog.Debug("dns stats", "args", args) section := "dns" command := "stats" diff --git a/cmd/dns_update.go b/cmd/dns_update.go index 8425e03..f383099 100644 --- a/cmd/dns_update.go +++ b/cmd/dns_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ DNS server, to the latest version or the version specified. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("dns update") + slog.Debug("dns update", "args", args) section := "dns" command := "update" diff --git a/cmd/docker_info.go b/cmd/docker_info.go index 6aa03d3..2f00cd9 100644 --- a/cmd/docker_info.go +++ b/cmd/docker_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Shows information about the local Docker backend on the host system ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("docker info") + slog.Debug("docker info", "args", args) section := "docker" command := "info" diff --git a/cmd/docker_migrate_storage_driver.go b/cmd/docker_migrate_storage_driver.go index f06ee05..9c6f6db 100644 --- a/cmd/docker_migrate_storage_driver.go +++ b/cmd/docker_migrate_storage_driver.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -28,7 +29,7 @@ to complete the migration. }, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("docker migrate-storage-driver") + slog.Debug("docker migrate-storage-driver", "args", args) section := "docker" command := "migrate-storage-driver" diff --git a/cmd/docker_options.go b/cmd/docker_options.go index e7854c2..2d7fb6e 100644 --- a/cmd/docker_options.go +++ b/cmd/docker_options.go @@ -2,10 +2,10 @@ package cmd import ( "fmt" + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -23,7 +23,7 @@ docker backend running on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("docker options") + slog.Debug("docker options", "args", args) section := "docker" command := "options" diff --git a/cmd/docker_registries.go b/cmd/docker_registries.go index f2569d5..6fb110c 100644 --- a/cmd/docker_registries.go +++ b/cmd/docker_registries.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Manage private OCI registry server on the local Docker host. ha docker registries delete my-docker.example.com `, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("docker registries") + slog.Debug("docker registries", "args", args) section := "docker" command := "registries" diff --git a/cmd/docker_registries_add.go b/cmd/docker_registries_add.go index e87fa73..6b7eeb8 100644 --- a/cmd/docker_registries_add.go +++ b/cmd/docker_registries_add.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Add new login for the Docker OCI registry server. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("registries add") + slog.Debug("registries add", "args", args) section := "docker" command := "registries" @@ -49,7 +50,7 @@ Add new login for the Docker OCI registry server. } if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/docker_registries_delete.go b/cmd/docker_registries_delete.go index 5cd970f..f79c965 100644 --- a/cmd/docker_registries_delete.go +++ b/cmd/docker_registries_delete.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Remove login for the Docker OCI registry server. ValidArgsFunction: dockerRegistriesDeleteCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("registries delete") + slog.Debug("registries delete", "args", args) section := "docker" command := "registries/{host}" diff --git a/cmd/hardware.go b/cmd/hardware.go index 0ec37e0..3566244 100644 --- a/cmd/hardware.go +++ b/cmd/hardware.go @@ -1,7 +1,8 @@ package cmd import ( - log "github.com/sirupsen/logrus" + "log/slog" + "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ audio devices and serial ports.`, } func init() { - log.Debug("Init hardware") + slog.Debug("Init hardware") // add cmd to root command rootCmd.AddCommand(hardwareCmd) diff --git a/cmd/hardware_audio.go b/cmd/hardware_audio.go index 5452b64..19024f5 100644 --- a/cmd/hardware_audio.go +++ b/cmd/hardware_audio.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -16,7 +17,7 @@ The command provides information about audio devices available on your system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("hardware info") + slog.Debug("hardware audio", "args", args) section := "hardware" command := "audio" diff --git a/cmd/hardware_info.go b/cmd/hardware_info.go index f680222..697f111 100644 --- a/cmd/hardware_info.go +++ b/cmd/hardware_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ serial ports.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("hardware info") + slog.Debug("hardware info", "args", args) section := "hardware" command := "info" diff --git a/cmd/host.go b/cmd/host.go index 3e45163..a386eeb 100644 --- a/cmd/host.go +++ b/cmd/host.go @@ -2,10 +2,10 @@ package cmd import ( "fmt" + "log/slog" "github.com/go-resty/resty/v2" "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -71,7 +71,7 @@ func processLogsFlags(section string, cmd *cobra.Command) (*resty.Request, error lines, _ := cmd.Flags().GetUint32("lines") if lines > 0 { rangeHeader := fmt.Sprintf("entries=:%d:", -(int(lines) - 1)) - log.WithField("value", rangeHeader).Debug("Range header") + slog.Debug("Range header", "value", rangeHeader) request.SetHeader("Range", rangeHeader) } diff --git a/cmd/host_disks_usage.go b/cmd/host_disks_usage.go index 59d8d8f..45dcae9 100644 --- a/cmd/host_disks_usage.go +++ b/cmd/host_disks_usage.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ that Home Assistant is running on.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host disks usage") + slog.Debug("host disks usage", "args", args) section := "host" command := "disks/default/usage" diff --git a/cmd/host_info.go b/cmd/host_info.go index 15817de..a89ee0d 100644 --- a/cmd/host_info.go +++ b/cmd/host_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ running on`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host info") + slog.Debug("host info", "args", args) section := "host" command := "info" diff --git a/cmd/host_logs.go b/cmd/host_logs.go index 0916703..e7a8703 100644 --- a/cmd/host_logs.go +++ b/cmd/host_logs.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -22,7 +22,7 @@ across services and boots. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host logs") + slog.Debug("host logs", "args", args) section := "host" diff --git a/cmd/host_logs_boots.go b/cmd/host_logs_boots.go index 5376512..175713d 100644 --- a/cmd/host_logs_boots.go +++ b/cmd/host_logs_boots.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -21,7 +21,7 @@ Show all values that can be used with the boot arg to find logs. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host logs boots") + slog.Debug("host logs boots", "args", args) section := "host" command := "logs/boots" diff --git a/cmd/host_logs_identifiers.go b/cmd/host_logs_identifiers.go index 54c2cd4..1e05c87 100644 --- a/cmd/host_logs_identifiers.go +++ b/cmd/host_logs_identifiers.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Show all values that can be used with the identifier arg to find logs. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host logs identifiers") + slog.Debug("host logs identifiers", "args", args) section := "host" command := "logs/identifiers" diff --git a/cmd/host_options.go b/cmd/host_options.go index ebdafb8..ebe007a 100644 --- a/cmd/host_options.go +++ b/cmd/host_options.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ your Home Assistant is running on.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host options") + slog.Debug("host options", "args", args) section := "host" command := "options" diff --git a/cmd/host_reboot.go b/cmd/host_reboot.go index 260f5c4..0a21d02 100644 --- a/cmd/host_reboot.go +++ b/cmd/host_reboot.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ Reboot the machine that your Home Assistant is running on.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host reboot") + slog.Debug("host reboot", "args", args) section := "host" command := "reboot" diff --git a/cmd/host_reload.go b/cmd/host_reload.go index e250159..b2ea52f 100644 --- a/cmd/host_reload.go +++ b/cmd/host_reload.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ the internals of Home Assistant.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host reload") + slog.Debug("host reload", "args", args) section := "host" command := "reload" diff --git a/cmd/host_shutdown.go b/cmd/host_shutdown.go index c1defe1..e08db99 100644 --- a/cmd/host_shutdown.go +++ b/cmd/host_shutdown.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ WARNING: This is turning off the computer/device.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("host shutdown") + slog.Debug("host shutdown", "args", args) section := "host" command := "shutdown" diff --git a/cmd/info.go b/cmd/info.go index 3329b24..c078c7d 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -21,7 +22,7 @@ issues or when reporting one on GitHub. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("info") + slog.Debug("info", "args", args) section := "info" command := "" diff --git a/cmd/jobs_info.go b/cmd/jobs_info.go index d29ee9c..70508db 100644 --- a/cmd/jobs_info.go +++ b/cmd/jobs_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command provides general information about the Home Assistant Job backend. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("jobs info") + slog.Debug("jobs info", "args", args) section := "jobs" command := "info" diff --git a/cmd/jobs_options.go b/cmd/jobs_options.go index e06e1e7..6aab174 100644 --- a/cmd/jobs_options.go +++ b/cmd/jobs_options.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ Home Assistant Job Manager. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("jobs options") + slog.Debug("jobs options", "args", args) section := "jobs" command := "options" diff --git a/cmd/jobs_reset.go b/cmd/jobs_reset.go index 7e21246..66dfbd7 100644 --- a/cmd/jobs_reset.go +++ b/cmd/jobs_reset.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -14,7 +15,7 @@ var jobsResetCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("jobs reset") + slog.Debug("jobs reset", "args", args) section := "jobs" command := "reset" diff --git a/cmd/mounts_add.go b/cmd/mounts_add.go index 5c24074..7b167fa 100644 --- a/cmd/mounts_add.go +++ b/cmd/mounts_add.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Add and configure a new mount in Supervisor. ValidArgsFunction: mountsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("mounts add") + slog.Debug("mounts add", "args", args) section := "mounts" command := "" @@ -40,7 +41,7 @@ Add and configure a new mount in Supervisor. mountFlagsToOptions(cmd, options) if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/mounts_delete.go b/cmd/mounts_delete.go index 4b44db6..6b0116c 100644 --- a/cmd/mounts_delete.go +++ b/cmd/mounts_delete.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Unmount and delete an existing mount from Supervisor. ValidArgsFunction: mountsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("mounts delete") + slog.Debug("mounts delete", "args", args) section := "mounts" command := "{name}" diff --git a/cmd/mounts_info.go b/cmd/mounts_info.go index a02ceb2..bf58b2d 100644 --- a/cmd/mounts_info.go +++ b/cmd/mounts_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Shows information about the currently configured mounts in Supervisor ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("mounts info") + slog.Debug("mounts info", "args", args) section := "mounts" command := "" diff --git a/cmd/mounts_options.go b/cmd/mounts_options.go index 9cac4b0..cd3e864 100644 --- a/cmd/mounts_options.go +++ b/cmd/mounts_options.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -22,7 +22,7 @@ Change value for options of mount manager in Supervisor. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("mounts options") + slog.Debug("mounts options", "args", args) section := "mounts" command := "options" diff --git a/cmd/mounts_reload.go b/cmd/mounts_reload.go index 0408357..7ff1fdb 100644 --- a/cmd/mounts_reload.go +++ b/cmd/mounts_reload.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ the same configuration. ValidArgsFunction: mountsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("mounts reload") + slog.Debug("mounts reload", "args", args) section := "mounts" command := "{name}/reload" diff --git a/cmd/mounts_update.go b/cmd/mounts_update.go index 0a37c48..585e0e3 100644 --- a/cmd/mounts_update.go +++ b/cmd/mounts_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Update or change the configuration of an existing mount in Supervisor. ValidArgsFunction: mountsCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("mounts update") + slog.Debug("mounts update", "args", args) section := "mounts" command := "{name}" @@ -42,7 +43,7 @@ Update or change the configuration of an existing mount in Supervisor. mountFlagsToOptions(cmd, options) if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/multicast_info.go b/cmd/multicast_info.go index 2e0ee27..8763416 100644 --- a/cmd/multicast_info.go +++ b/cmd/multicast_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Shows information about the internally running Home Assistant Multicast server ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("multicast info") + slog.Debug("multicast info", "args", args) section := "multicast" command := "info" diff --git a/cmd/multicast_logs.go b/cmd/multicast_logs.go index 1e5d99d..4b12c31 100644 --- a/cmd/multicast_logs.go +++ b/cmd/multicast_logs.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Allowing you to look at the log output generated by the Home Assistant Multicast ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("multicast logs") + slog.Debug("multicast logs", "args", args) section := "multicast" diff --git a/cmd/multicast_restart.go b/cmd/multicast_restart.go index e429b02..ac9e18d 100644 --- a/cmd/multicast_restart.go +++ b/cmd/multicast_restart.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -16,7 +17,7 @@ var multicastRestartCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("multicast restart") + slog.Debug("multicast restart", "args", args) section := "multicast" command := "restart" diff --git a/cmd/multicast_stats.go b/cmd/multicast_stats.go index 5b2e729..69ce4ee 100644 --- a/cmd/multicast_stats.go +++ b/cmd/multicast_stats.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ It shows you how much CPU, memory, disk & network resources it uses. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("multicast stats") + slog.Debug("multicast stats", "args", args) section := "multicast" command := "stats" diff --git a/cmd/multicast_update.go b/cmd/multicast_update.go index 73b5d01..204a796 100644 --- a/cmd/multicast_update.go +++ b/cmd/multicast_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ Multicast server, to the latest version or the version specified. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("multicast update") + slog.Debug("multicast update", "args", args) section := "multicast" command := "update" diff --git a/cmd/network.go b/cmd/network.go index 2eccc21..03cd8b2 100644 --- a/cmd/network.go +++ b/cmd/network.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ system network IP address, set connection options or join a Wi-Fi network.`, } func init() { - log.Debug("Init network") + slog.Debug("Init network") rootCmd.AddCommand(networkCmd) } diff --git a/cmd/network_info.go b/cmd/network_info.go index 4655fb2..fb5f3dc 100644 --- a/cmd/network_info.go +++ b/cmd/network_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ Shows information about the host network and interfaces or only from a specific ValidArgsFunction: networkInterfaceCompletions, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("network info") + slog.Debug("network info", "args", args) section := "network" command := "info" diff --git a/cmd/network_reload.go b/cmd/network_reload.go index b265c01..03383bf 100644 --- a/cmd/network_reload.go +++ b/cmd/network_reload.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Reload information about the host network and interfaces. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("network reload") + slog.Debug("network reload", "args", args) section := "network" command := "reload" diff --git a/cmd/network_scan.go b/cmd/network_scan.go index 7ad6350..59536d8 100644 --- a/cmd/network_scan.go +++ b/cmd/network_scan.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ This function works only on a wireless interface! ValidArgsFunction: networkInterfaceCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("network scan") + slog.Debug("network scan", "args", args) section := "network" command := "interface/{interface}/accesspoints" diff --git a/cmd/network_update.go b/cmd/network_update.go index 3af3c6e..4f967e5 100644 --- a/cmd/network_update.go +++ b/cmd/network_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Update network interface settings of a specific adapter. ValidArgsFunction: networkInterfaceCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("network update") + slog.Debug("network update", "args", args) section := "network" command := "interface/{interface}/update" @@ -56,7 +57,7 @@ Update network interface settings of a specific adapter. options["enabled"] = !disabled } - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) resp, err := request.Post(url) diff --git a/cmd/network_vlan.go b/cmd/network_vlan.go index ac55dc8..16a9818 100644 --- a/cmd/network_vlan.go +++ b/cmd/network_vlan.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ This function works only on an ethernet interface! ValidArgsFunction: networkInterfaceCompletions, Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("network vlan") + slog.Debug("network vlan", "args", args) section := "network" command := "interface/{interface}/vlan/{vlan}" @@ -52,7 +53,7 @@ This function works only on an ethernet interface! helperMdnsConfig(cmd, options) if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/observer_info.go b/cmd/observer_info.go index 16d4be7..9865650 100644 --- a/cmd/observer_info.go +++ b/cmd/observer_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ Shows information about the internally running Home Assistant observer ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("observer info") + slog.Debug("observer info", "args", args) section := "observer" command := "info" diff --git a/cmd/observer_stats.go b/cmd/observer_stats.go index 2a141c2..444bf7d 100644 --- a/cmd/observer_stats.go +++ b/cmd/observer_stats.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ It shows you how much CPU, memory, disk & network resources it uses. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("observer stats") + slog.Debug("observer stats", "args", args) section := "observer" command := "stats" diff --git a/cmd/observer_update.go b/cmd/observer_update.go index 0082010..e4e7adf 100644 --- a/cmd/observer_update.go +++ b/cmd/observer_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ observer, to the latest version or the version specified. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("observer update") + slog.Debug("observer update", "args", args) section := "observer" command := "update" diff --git a/cmd/os_boards_green.go b/cmd/os_boards_green.go index c025543..7d7fae1 100644 --- a/cmd/os_boards_green.go +++ b/cmd/os_boards_green.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ Assistant is running on.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os boards green") + slog.Debug("os boards green", "args", args) section := "os" command := "boards/green" diff --git a/cmd/os_boards_green_options.go b/cmd/os_boards_green_options.go index 98961a1..f5f9c81 100644 --- a/cmd/os_boards_green_options.go +++ b/cmd/os_boards_green_options.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +20,7 @@ Assistant is running on.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os boards green options") + slog.Debug("os boards green options", "args", args) section := "os" command := "boards/green" diff --git a/cmd/os_boards_yellow.go b/cmd/os_boards_yellow.go index 7901e92..ead9f46 100644 --- a/cmd/os_boards_yellow.go +++ b/cmd/os_boards_yellow.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ Assistant is running on.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os boards yellow") + slog.Debug("os boards yellow", "args", args) section := "os" command := "boards/yellow" diff --git a/cmd/os_boards_yellow_options.go b/cmd/os_boards_yellow_options.go index e3ed3a9..f86e3af 100644 --- a/cmd/os_boards_yellow_options.go +++ b/cmd/os_boards_yellow_options.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +20,7 @@ Assistant is running on. A host reboot is required for changes to take effect.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os boards yellow options") + slog.Debug("os boards yellow options", "args", args) section := "os" command := "boards/yellow" diff --git a/cmd/os_boot_slot.go b/cmd/os_boot_slot.go index e25542a..73fddd6 100644 --- a/cmd/os_boot_slot.go +++ b/cmd/os_boot_slot.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -21,7 +22,7 @@ an OS update without making more changes to the system. ValidArgsFunction: osBootSlotCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os boot-slot") + slog.Debug("os boot-slot", "args", args) section := "os" command := "boot-slot" diff --git a/cmd/os_config_swap_info.go b/cmd/os_config_swap_info.go index 351fdd4..d3191d7 100644 --- a/cmd/os_config_swap_info.go +++ b/cmd/os_config_swap_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command allows you to see how swap is used by the Home Assistant OS.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os config swap info") + slog.Debug("os config swap info", "args", args) section := "os" command := "config/swap" diff --git a/cmd/os_config_swap_options.go b/cmd/os_config_swap_options.go index fefe7bc..31a7056 100644 --- a/cmd/os_config_swap_options.go +++ b/cmd/os_config_swap_options.go @@ -2,10 +2,10 @@ package cmd import ( "fmt" + "log/slog" "strconv" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +20,7 @@ This command allows you to override how the Home Assistant OS uses swap.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os config swap options") + slog.Debug("os config swap options", "args", args) section := "os" command := "config/swap" diff --git a/cmd/os_datadisk_list.go b/cmd/os_datadisk_list.go index 12437ca..9c07176 100644 --- a/cmd/os_datadisk_list.go +++ b/cmd/os_datadisk_list.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command provides general information about available Harddisk for using wit ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os datadisk list") + slog.Debug("os datadisk list", "args", args) section := "os" command := "datadisk/list" diff --git a/cmd/os_datadisk_move.go b/cmd/os_datadisk_move.go index 76d797a..3e58ec8 100644 --- a/cmd/os_datadisk_move.go +++ b/cmd/os_datadisk_move.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -25,7 +26,7 @@ data partition to a new harddisk. The system reboots afterwards! }, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os datadisk move") + slog.Debug("os datadisk move", "args", args) section := "os" command := "datadisk/move" diff --git a/cmd/os_datadisk_wipe.go b/cmd/os_datadisk_wipe.go index c2e2d21..b869980 100644 --- a/cmd/os_datadisk_wipe.go +++ b/cmd/os_datadisk_wipe.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -31,7 +32,7 @@ only work on some locations. For example, the Operating System CLI. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os datadisk wipe") + slog.Debug("os datadisk wipe", "args", args) section := "os" command := "datadisk/wipe" diff --git a/cmd/os_import.go b/cmd/os_import.go index 589a2f9..d8b2866 100644 --- a/cmd/os_import.go +++ b/cmd/os_import.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ configuration to load for the Home Assistant Operating System. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os import") + slog.Debug("os import", "args", args) section := "os" command := "config/sync" diff --git a/cmd/os_info.go b/cmd/os_info.go index 6842d96..79d7993 100644 --- a/cmd/os_info.go +++ b/cmd/os_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command provides general information about the running Home Assistant Opera ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os info") + slog.Debug("os info", "args", args) section := "os" command := "info" diff --git a/cmd/os_update.go b/cmd/os_update.go index 4838bb3..eacaecd 100644 --- a/cmd/os_update.go +++ b/cmd/os_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -21,7 +22,7 @@ Operating System to the latest version or the version specified. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("os update") + slog.Debug("os update", "args", args) section := "os" command := "update" diff --git a/cmd/refresh_updates.go b/cmd/refresh_updates.go index 9a08979..62eaee1 100644 --- a/cmd/refresh_updates.go +++ b/cmd/refresh_updates.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command reloads information about app repositories and fetches new version ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("refresh_updates") + slog.Debug("refresh_updates", "args", args) section := "refresh_updates" command := "" diff --git a/cmd/resolution_check_options.go b/cmd/resolution_check_options.go index 0eebda9..722f0ad 100644 --- a/cmd/resolution_check_options.go +++ b/cmd/resolution_check_options.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command allows to apply options to an specific check managed by the system. ValidArgsFunction: resolutionCheckCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("check options") + slog.Debug("check options", "args", args) section := "resolution" command := "check/{check}/options" @@ -44,7 +45,7 @@ This command allows to apply options to an specific check managed by the system. } if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } resp, err := request.Post(url) diff --git a/cmd/resolution_check_run.go b/cmd/resolution_check_run.go index 14cba82..9d166fe 100644 --- a/cmd/resolution_check_run.go +++ b/cmd/resolution_check_run.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command executes an backend check immediately on the system.`, ValidArgsFunction: resolutionCheckCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("check run") + slog.Debug("check run", "args", args) section := "resolution" command := "check/{check}/run" diff --git a/cmd/resolution_healthcheck.go b/cmd/resolution_healthcheck.go index b83771d..a49f19a 100644 --- a/cmd/resolution_healthcheck.go +++ b/cmd/resolution_healthcheck.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ are still around and try to fix it again.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("resolution") + slog.Debug("resolution", "args", args) section := "resolution" command := "healthcheck" diff --git a/cmd/resolution_info.go b/cmd/resolution_info.go index e27832b..b599dcb 100644 --- a/cmd/resolution_info.go +++ b/cmd/resolution_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command provides general information about the issues, suggestion and the s ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("resolution") + slog.Debug("resolution", "args", args) section := "resolution" command := "info" diff --git a/cmd/resolution_issue_dismiss.go b/cmd/resolution_issue_dismiss.go index 016e170..2be706f 100644 --- a/cmd/resolution_issue_dismiss.go +++ b/cmd/resolution_issue_dismiss.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command allows dismissing issues reported by the system.`, ValidArgsFunction: resolutionIssueCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("issue dismiss") + slog.Debug("issue dismiss", "args", args) section := "resolution" command := "issue/{issue}" diff --git a/cmd/resolution_issue_suggestions.go b/cmd/resolution_issue_suggestions.go index 798a19c..0c9ac8c 100644 --- a/cmd/resolution_issue_suggestions.go +++ b/cmd/resolution_issue_suggestions.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command returns suggestions which resolve an issue when applied.`, ValidArgsFunction: resolutionIssueCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("issue suggestions") + slog.Debug("issue suggestions", "args", args) section := "resolution" command := "issue/{issue}/suggestions" diff --git a/cmd/resolution_suggestion_apply.go b/cmd/resolution_suggestion_apply.go index dacf86e..81902df 100644 --- a/cmd/resolution_suggestion_apply.go +++ b/cmd/resolution_suggestion_apply.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command allow to apply an suggestion reported by the System.`, ValidArgsFunction: resolutionSuggestionCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("suggestion dismiss") + slog.Debug("suggestion apply", "args", args) section := "resolution" command := "suggestion/{suggestion}" diff --git a/cmd/resolution_suggestion_dismiss.go b/cmd/resolution_suggestion_dismiss.go index bfea92a..b3c376d 100644 --- a/cmd/resolution_suggestion_dismiss.go +++ b/cmd/resolution_suggestion_dismiss.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command allows dismissing a suggestion reported by the system.`, ValidArgsFunction: resolutionSuggestionCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("suggestion dismiss") + slog.Debug("suggestion dismiss", "args", args) section := "resolution" command := "suggestion/{suggestion}" diff --git a/cmd/root.go b/cmd/root.go index 2511ef1..a05122f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "log/slog" "os" "path" "strings" @@ -10,7 +11,6 @@ import ( helper "github.com/home-assistant/cli/client" "github.com/home-assistant/cli/spinner" homedir "github.com/mitchellh/go-homedir" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" "golang.org/x/term" @@ -37,10 +37,9 @@ The Home Assistant CLI is a small and simple command line utility that allows you to control and configure different aspects of Home Assistant`, PersistentPreRun: func(cmd *cobra.Command, args []string) { // set loglevel if possible - logrusLevel, err := log.ParseLevel(viper.GetString("log-level")) - - if err == nil { - log.SetLevel(logrusLevel) + var level slog.Level + if level.UnmarshalText([]byte(viper.GetString("log-level"))) == nil { + slog.SetLogLoggerLevel(level) } helper.RawJSON = viper.GetBool("raw-json") @@ -51,14 +50,14 @@ you to control and configure different aspects of Home Assistant`, ProgressSpinner.Writer = os.Stderr } - log.WithFields(log.Fields{ - "apiToken": viper.GetString("api-token"), - "cfgFile": viper.GetString("config"), - "endpoint": viper.GetString("endpoint"), - "logLevel": viper.GetString("log-level"), - "noProgress": viper.GetBool("no-progress"), - "rawJSON": viper.GetBool("raw-json"), - }).Debugln("Debug flags") + slog.Debug("Debug flags", + "apiToken", viper.GetString("api-token"), + "cfgFile", viper.GetString("config"), + "endpoint", viper.GetString("endpoint"), + "logLevel", viper.GetString("log-level"), + "noProgress", viper.GetBool("no-progress"), + "rawJSON", viper.GetBool("raw-json"), + ) }, PersistentPostRun: func(cmd *cobra.Command, args []string) { if ProgressSpinner.Active() { @@ -81,18 +80,19 @@ func init() { rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "Optional config file (default is $HOME/.homeassistant.yaml)") rootCmd.PersistentFlags().StringVar(&endPoint, "endpoint", "", "Endpoint for Home Assistant Supervisor (default is 'supervisor')") - rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "", "Log level (defaults to Warn)") + rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "", "Log level (defaults to "+slog.LevelWarn.String()+")") rootCmd.PersistentFlags().StringVar(&apiToken, "api-token", "", "Home Assistant Supervisor API token") rootCmd.PersistentFlags().BoolVar(&rawJSON, "raw-json", false, "Output raw JSON from the API") rootCmd.PersistentFlags().BoolVar(&noProgress, "no-progress", false, "Disable the progress spinner") rootCmd.RegisterFlagCompletionFunc("endpoint", cobra.NoFileCompletions) rootCmd.RegisterFlagCompletionFunc("log-level", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - vals := make([]string, 0, len(log.AllLevels)) - for _, lvl := range log.AllLevels { - vals = append(vals, lvl.String()) - } - return vals, cobra.ShellCompDirectiveNoFileComp + return []string{ + slog.LevelDebug.String(), + slog.LevelInfo.String(), + slog.LevelWarn.String(), + slog.LevelError.String(), + }, cobra.ShellCompDirectiveNoFileComp }) rootCmd.RegisterFlagCompletionFunc("api-token", cobra.NoFileCompletions) rootCmd.RegisterFlagCompletionFunc("raw-json", boolCompletions) @@ -125,10 +125,9 @@ func initConfig() { viper.BindEnv("api-token", "SUPERVISOR_TOKEN") // set loglevel if possible - logLevel, err := log.ParseLevel(viper.GetString("log-level")) - - if err == nil { - log.SetLevel(logLevel) + var level slog.Level + if level.UnmarshalText([]byte(viper.GetString("log-level"))) == nil { + slog.SetLogLoggerLevel(level) } if cfgFile != "" { @@ -144,15 +143,15 @@ func initConfig() { // Search config in home directory with name ".homeassistant" (without extension). viper.AddConfigPath(home) - log.WithField("homedir", home).Debug("Adding homedir to searchpath") + slog.Debug("Adding homedir to searchpath", "homedir", home) viper.SetConfigName(".homeassistant") } // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { - log.WithField("configfile", viper.ConfigFileUsed()).Info("Using configfile") + slog.Info("Using configfile", "configfile", viper.ConfigFileUsed()) } else { - log.Info("No configfile found") + slog.Info("No configfile found") } } diff --git a/cmd/security_info.go b/cmd/security_info.go index 8efd77d..1751107 100644 --- a/cmd/security_info.go +++ b/cmd/security_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command provides general information about the Home Assistant Security back ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("security info") + slog.Debug("security info", "args", args) section := "security" command := "info" diff --git a/cmd/security_integrity.go b/cmd/security_integrity.go index 95c0d7b..07a5f8b 100644 --- a/cmd/security_integrity.go +++ b/cmd/security_integrity.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ This need content trust to be enabled.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("security") + slog.Debug("security integrity", "args", args) section := "security" command := "integrity" diff --git a/cmd/security_options.go b/cmd/security_options.go index d33fe69..d759695 100644 --- a/cmd/security_options.go +++ b/cmd/security_options.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -22,7 +22,7 @@ Home Assistant Security backend. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("security options") + slog.Debug("security options", "args", args) section := "security" command := "options" diff --git a/cmd/store.go b/cmd/store.go index d5e0cd5..1f2657e 100644 --- a/cmd/store.go +++ b/cmd/store.go @@ -1,10 +1,11 @@ package cmd import ( + "log/slog" + "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -22,7 +23,7 @@ for managing stores that provide additional apps.`, ha store delete 94cfad5a ha store reload`, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("store") + slog.Debug("store", "args", args) section := "store" command := "" @@ -38,7 +39,7 @@ for managing stores that provide additional apps.`, } func init() { - log.Debug("Init store") + slog.Debug("Init store") rootCmd.AddCommand(storeCmd) } diff --git a/cmd/store_apps.go b/cmd/store_apps.go index c0868d9..5324a76 100644 --- a/cmd/store_apps.go +++ b/cmd/store_apps.go @@ -1,11 +1,11 @@ package cmd import ( + "log/slog" "os" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -28,7 +28,7 @@ commands for installing or update them.`, rootCmd.PersistentPreRun(cmd, args) }, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("store apps") + slog.Debug("store apps", "args", args) section := "store" command := "addons" diff --git a/cmd/store_apps_install.go b/cmd/store_apps_install.go index 013a0e7..e6934a6 100644 --- a/cmd/store_apps_install.go +++ b/cmd/store_apps_install.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ This command allows you to install a Home Assistant app from the commandline. ValidArgsFunction: storeAppCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("store apps install") + slog.Debug("store apps install", "args", args) section := "store" command := "addons/{slug}/install" diff --git a/cmd/store_apps_update.go b/cmd/store_apps_update.go index 01f125f..ceacaf0 100644 --- a/cmd/store_apps_update.go +++ b/cmd/store_apps_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ It is currently not possible to upgrade/downgrade to a specific version. ValidArgsFunction: storeAppCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("store apps update") + slog.Debug("store apps update", "args", args) section := "store" command := "addons/{slug}/update" @@ -51,7 +52,7 @@ It is currently not possible to upgrade/downgrade to a specific version. } if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/store_reload.go b/cmd/store_reload.go index bf18a27..5d358c7 100644 --- a/cmd/store_reload.go +++ b/cmd/store_reload.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -22,7 +23,7 @@ an app is released, but not yet available as an upgrade in Home Assistant. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("store reload") + slog.Debug("store reload", "args", args) section := "store" command := "reload" diff --git a/cmd/store_repositories_add.go b/cmd/store_repositories_add.go index 2605b02..66753c1 100644 --- a/cmd/store_repositories_add.go +++ b/cmd/store_repositories_add.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ ha store add https://github.com/home-assistant/addons-example ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("store add") + slog.Debug("store add", "args", args) section := "store" command := "repositories" @@ -39,7 +40,7 @@ ha store add https://github.com/home-assistant/addons-example options["repository"] = repository if len(options) > 0 { - log.WithField("options", options).Debug("Request body") + slog.Debug("Request body", "options", options) request.SetBody(options) } diff --git a/cmd/store_repositories_delete.go b/cmd/store_repositories_delete.go index 23f7ec0..d7adfe8 100644 --- a/cmd/store_repositories_delete.go +++ b/cmd/store_repositories_delete.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -19,7 +20,7 @@ ha store delete 94cfad5a ValidArgsFunction: storeRepositoriesCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("store delete") + slog.Debug("store delete", "args", args) section := "store" command := "repositories/{slug}" diff --git a/cmd/store_repositories_repair.go b/cmd/store_repositories_repair.go index 35cec33..dd01d32 100644 --- a/cmd/store_repositories_repair.go +++ b/cmd/store_repositories_repair.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ ha store repair 94cfad5a ValidArgsFunction: storeRepositoriesCompletions, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("store repair") + slog.Debug("store repair", "args", args) section := "store" command := "repositories/{slug}/repair" diff --git a/cmd/supervisor.go b/cmd/supervisor.go index dc2ed42..c09bbd6 100644 --- a/cmd/supervisor.go +++ b/cmd/supervisor.go @@ -1,7 +1,8 @@ package cmd import ( - log "github.com/sirupsen/logrus" + "log/slog" + "github.com/spf13/cobra" ) @@ -21,6 +22,6 @@ Home Assistant Supervisor.`, } func init() { - log.Debug("Init supervisor") + slog.Debug("Init supervisor") rootCmd.AddCommand(supervisorCmd) } diff --git a/cmd/supervisor_available_updates.go b/cmd/supervisor_available_updates.go index ef516c8..92909de 100644 --- a/cmd/supervisor_available_updates.go +++ b/cmd/supervisor_available_updates.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ This command provides you information about available updates.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor available-updates") + slog.Debug("supervisor available-updates", "args", args) section := "supervisor" command := "available_updates" diff --git a/cmd/supervisor_info.go b/cmd/supervisor_info.go index 6d1013d..4a9ba15 100644 --- a/cmd/supervisor_info.go +++ b/cmd/supervisor_info.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ Supervisor currently knows.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor info") + slog.Debug("supervisor info", "args", args) section := "supervisor" command := "info" diff --git a/cmd/supervisor_logs.go b/cmd/supervisor_logs.go index 7cc0aab..3de1e63 100644 --- a/cmd/supervisor_logs.go +++ b/cmd/supervisor_logs.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ Supervisor running on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor logs") + slog.Debug("supervisor logs", "args", args) section := "supervisor" diff --git a/cmd/supervisor_options.go b/cmd/supervisor_options.go index 046db6e..a16c557 100644 --- a/cmd/supervisor_options.go +++ b/cmd/supervisor_options.go @@ -1,10 +1,10 @@ package cmd import ( + "log/slog" "strings" helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +20,7 @@ Supervisor running on your Home Assistant system.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor options") + slog.Debug("supervisor options", "args", args) section := "supervisor" command := "options" diff --git a/cmd/supervisor_reload.go b/cmd/supervisor_reload.go index 5f86f2a..e51665a 100644 --- a/cmd/supervisor_reload.go +++ b/cmd/supervisor_reload.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ all data it currently has, including checking for updates.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor reload") + slog.Debug("supervisor reload", "args", args) section := "supervisor" command := "reload" diff --git a/cmd/supervisor_repair.go b/cmd/supervisor_repair.go index 5b4ddac..7a526e7 100644 --- a/cmd/supervisor_repair.go +++ b/cmd/supervisor_repair.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ the Home Assistant Supervisor will try to resolve these. ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor repair") + slog.Debug("supervisor repair", "args", args) section := "supervisor" command := "repair" diff --git a/cmd/supervisor_restart.go b/cmd/supervisor_restart.go index ba7f478..8824b4c 100644 --- a/cmd/supervisor_restart.go +++ b/cmd/supervisor_restart.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -17,7 +18,7 @@ Restart the Supervisor internal, this can solve healthy issues.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor restart") + slog.Debug("supervisor restart", "args", args) section := "supervisor" command := "restart" diff --git a/cmd/supervisor_stats.go b/cmd/supervisor_stats.go index 20eae91..10b7554 100644 --- a/cmd/supervisor_stats.go +++ b/cmd/supervisor_stats.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ It shows you how much CPU, memory, disk & network resources it uses.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor stats") + slog.Debug("supervisor stats", "args", args) section := "supervisor" command := "stats" diff --git a/cmd/supervisor_update.go b/cmd/supervisor_update.go index a5deccf..2592d18 100644 --- a/cmd/supervisor_update.go +++ b/cmd/supervisor_update.go @@ -1,8 +1,9 @@ package cmd import ( + "log/slog" + helper "github.com/home-assistant/cli/client" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -20,7 +21,7 @@ or the version specified.`, ValidArgsFunction: cobra.NoFileCompletions, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - log.WithField("args", args).Debug("supervisor update") + slog.Debug("supervisor update", "args", args) section := "supervisor" command := "update" diff --git a/go.mod b/go.mod index 90993ca..ff01310 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/ghodss/yaml v1.0.0 github.com/go-resty/resty/v2 v2.17.1 github.com/mitchellh/go-homedir v1.1.0 - github.com/sirupsen/logrus v1.9.4 github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 github.com/spf13/viper v1.21.0 diff --git a/go.sum b/go.sum index 5f68caf..14f87cb 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,6 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc= github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik= -github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w= -github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= diff --git a/main.go b/main.go index 7d5ba43..9954c6a 100644 --- a/main.go +++ b/main.go @@ -1,15 +1,15 @@ package main import ( + "log/slog" "os" "github.com/home-assistant/cli/cmd" - log "github.com/sirupsen/logrus" ) func main() { // Only log the warning severity or above. - log.SetLevel(log.WarnLevel) + slog.SetLogLoggerLevel(slog.LevelWarn) defer func() { if cmd.ExitWithError { os.Exit(1)