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:
1 parent
0b5fde9563
commit
043e307663
49 files changed
+598
-248
No files matched your search
@@ -21,13 +21,13 @@ func commandDown(opts *cli.Options) *cobra.Command {
|
||||
confirmed by providing -yes.`,
|
||||
Args: cobra.NoArgs,
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.down.PersistentPreRun")
|
||||
slog.Debug("command persistent pre-run", "command", "migrate.down")
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.down.PersistentPostRun")
|
||||
slog.Debug("command persistent post-run", "command", "migrate.down")
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
slog.Debug("migrate.down.Run")
|
||||
slog.Debug("command run", "command", "migrate.down")
|
||||
|
||||
yes, _ := cmd.Flags().GetBool("yes")
|
||||
steps, _ := cmd.Flags().GetUint("steps")
|
||||
|
||||
@@ -26,13 +26,13 @@ Running without a subcommand is the same as running "migrate up": every pending
|
||||
migration is applied.`,
|
||||
Args: cobra.NoArgs,
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.PersistentPreRun")
|
||||
slog.Debug("command persistent pre-run", "command", "migrate")
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.PersistentPostRun")
|
||||
slog.Debug("command persistent post-run", "command", "migrate")
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
slog.Debug("migrate.Run")
|
||||
slog.Debug("command run", "command", "migrate")
|
||||
return runStepUp(cmd, opts, 0, false)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -75,13 +75,13 @@ func commandStatus(opts *cli.Options) *cobra.Command {
|
||||
Short: "Show which migrations have been applied to the SQLite database",
|
||||
Args: cobra.NoArgs,
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.status.PersistentPreRun")
|
||||
slog.Debug("command persistent pre-run", "command", "migrate.status")
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.status.PersistentPostRun")
|
||||
slog.Debug("command persistent post-run", "command", "migrate.status")
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
slog.Debug("migrate.status.Run")
|
||||
slog.Debug("command run", "command", "migrate.status")
|
||||
|
||||
m, db, err := openMigrator(cmd, opts, false, false)
|
||||
if err != nil {
|
||||
|
||||
@@ -46,13 +46,13 @@ func commandUp(opts *cli.Options) *cobra.Command {
|
||||
Short: "Migrate SQLite database to the latest version, or by a number of steps",
|
||||
Args: cobra.NoArgs,
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.up.PersistentPreRun")
|
||||
slog.Debug("command persistent pre-run", "command", "migrate.up")
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.up.PersistentPostRun")
|
||||
slog.Debug("command persistent post-run", "command", "migrate.up")
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
slog.Debug("migrate.up.Run")
|
||||
slog.Debug("command run", "command", "migrate.up")
|
||||
|
||||
steps, _ := cmd.Flags().GetUint("steps")
|
||||
create, _ := cmd.Flags().GetBool("create")
|
||||
|
||||
Reference in new issue
Block a user