Logging: structured slog messages throughout, and WithLogger options so callers choose the logger

Log messages are lower-case event names with their details as key/value
attributes ("error" for errors), in place of formatted strings.

Loggable package take a WithLogger option as part of their "New*" call,
defaulting to slog.Default(). Each tags its lines with its `component`.

Some debug loggers print directly rather than using slog when in
terminal logging mode.
This commit is contained in:
bwilliams committed 2026-10-15 16:10:52 +01:00
1 parent 0b5fde9563
commit 043e307663
49 files changed
+598 -248

No files matched your search

+3 -3
View File
@@ -19,13 +19,13 @@ func commandInit() *cobra.Command {
Args: cobra.MatchAll(cobra.MinimumNArgs(0), cobra.MaximumNArgs(1)),
Short: "Create an empty configuration file",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
slog.Debug("config.init.PersistentPreRun")
slog.Debug("command persistent pre-run", "command", "config.init")
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
slog.Debug("config.init.PersistentPostRun")
slog.Debug("command persistent post-run", "command", "config.init")
},
RunE: func(cmd *cobra.Command, args []string) error {
slog.Debug("config.init.Run")
slog.Debug("command run", "command", "config.init")
if err := cobra.MinimumNArgs(0)(cmd, args); err != nil {
return err