Skip to content

Commit

Permalink
Add missing slog calls to commands (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
hifi authored Oct 20, 2023
1 parent fe9ab5c commit 9f0e50d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions cmd/litestream/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.execCh:
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.cmd != nil {
fmt.Println("sending signal to exec process")
slog.Info("sending signal to exec process")
if err := c.cmd.Process.Signal(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.execCh; err != nil && !strings.HasPrefix(err.Error(), "signal:") {
return fmt.Errorf("cannot wait for exec process: %w", err)
}
Expand All @@ -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":
Expand Down
7 changes: 4 additions & 3 deletions cmd/litestream/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"flag"
"fmt"
"log/slog"
"os"
"strconv"
"time"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 9f0e50d

Please sign in to comment.