From b605039a8535abe3879b69d5c07917a266177601 Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Tue, 17 Oct 2023 11:10:24 +0300 Subject: [PATCH] Add missing slog calls to commands --- cmd/litestream/main.go | 10 +++++----- cmd/litestream/restore.go | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/litestream/main.go b/cmd/litestream/main.go index b3f62d2d..ba168a0a 100644 --- a/cmd/litestream/main.go +++ b/cmd/litestream/main.go @@ -93,17 +93,17 @@ func (m *Main) Run(ctx context.Context, args []string) (err error) { // Wait for signal to stop program. select { case err = <-c.runCh: - fmt.Println("subprocess exited, litestream shutting down") + slog.Info("subprocess exited, litestream shutting down") case sig := <-signalCh: - fmt.Println("signal received, litestream shutting down") + slog.Info("signal received, litestream shutting down") if c.runSignal != nil { - fmt.Println("sending signal to exec process") + slog.Info("sending signal to exec process") if err := c.runSignal(sig); err != nil { return fmt.Errorf("cannot signal exec process: %w", err) } - fmt.Println("waiting for exec process to close") + slog.Info("waiting for exec process to close") if err := <-c.runCh; err != nil && !strings.HasPrefix(err.Error(), "signal:") { return fmt.Errorf("cannot wait for exec process: %w", err) } @@ -114,7 +114,7 @@ func (m *Main) Run(ctx context.Context, args []string) (err error) { if e := c.Close(); e != nil && err == nil { err = e } - fmt.Println("litestream shut down") + slog.Info("litestream shut down") return err case "restore": diff --git a/cmd/litestream/restore.go b/cmd/litestream/restore.go index 3e4c86aa..6e99f131 100644 --- a/cmd/litestream/restore.go +++ b/cmd/litestream/restore.go @@ -5,6 +5,7 @@ import ( "errors" "flag" "fmt" + "log/slog" "os" "strconv" "time" @@ -52,7 +53,7 @@ func (c *RestoreCommand) Run(ctx context.Context, args []string) (err error) { return fmt.Errorf("cannot specify a replica URL and the -config flag") } if r, err = c.loadFromURL(ctx, fs.Arg(0), *ifDBNotExists, &opt); err == errSkipDBExists { - fmt.Println("database already exists, skipping") + slog.Info("database already exists, skipping") return nil } else if err != nil { return err @@ -62,7 +63,7 @@ func (c *RestoreCommand) Run(ctx context.Context, args []string) (err error) { *configPath = DefaultConfigPath() } if r, err = c.loadFromConfig(ctx, fs.Arg(0), *configPath, !*noExpandEnv, *ifDBNotExists, &opt); err == errSkipDBExists { - fmt.Println("database already exists, skipping") + slog.Info("database already exists, skipping") return nil } else if err != nil { return err @@ -73,7 +74,7 @@ func (c *RestoreCommand) Run(ctx context.Context, args []string) (err error) { // If optional flag set, return success. Useful for automated recovery. if opt.Generation == "" { if *ifReplicaExists { - fmt.Println("no matching backups found") + slog.Info("no matching backups found") return nil } return fmt.Errorf("no matching backups found")