Convert pkg/cmd/load_plugins.go to slog

- Replace log.Output() calls with slog.Debug() for structured logging
- Remove 'log' import and use 'log/slog' instead
- Removes the settings.Debug checks in favor of slog's built-in log level handling
- Improves logging consistency across the codebase

Fixes #13454

Signed-off-by: ritoban23 <ankudutt101@gmail.com>
pull/31457/head
ritoban23 11 months ago
parent 99cd196435
commit 5a5674c36c
No known key found for this signature in database
GPG Key ID: 76892C9B880C928B

@ -20,7 +20,7 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"log" "log/slog"
"os" "os"
"path/filepath" "path/filepath"
"slices" "slices"
@ -217,9 +217,7 @@ func loadCompletionForPlugin(pluginCmd *cobra.Command, plug plugin.Plugin) {
if err != nil { if err != nil {
// The file could be missing or invalid. No static completion for this plugin. // The file could be missing or invalid. No static completion for this plugin.
if settings.Debug { slog.Debug("plugin completion file loading", "error", err.Error())
log.Output(2, fmt.Sprintf("[info] %s\n", err.Error()))
}
// Continue to setup dynamic completion. // Continue to setup dynamic completion.
cmds = &pluginCommand{} cmds = &pluginCommand{}
} }
@ -239,9 +237,7 @@ func addPluginCommands(plug plugin.Plugin, baseCmd *cobra.Command, cmds *pluginC
if len(cmds.Name) == 0 { if len(cmds.Name) == 0 {
// Missing name for a command // Missing name for a command
if settings.Debug { slog.Debug("sub-command name field missing", "commandPath", baseCmd.CommandPath())
log.Output(2, fmt.Sprintf("[info] sub-command name field missing for %s", baseCmd.CommandPath()))
}
return return
} }

Loading…
Cancel
Save