Skip to content

Commit 9f0e50d

Browse files
authored
Add missing slog calls to commands (#508)
1 parent fe9ab5c commit 9f0e50d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

cmd/litestream/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ func (m *Main) Run(ctx context.Context, args []string) (err error) {
9393
// Wait for signal to stop program.
9494
select {
9595
case err = <-c.execCh:
96-
fmt.Println("subprocess exited, litestream shutting down")
96+
slog.Info("subprocess exited, litestream shutting down")
9797
case sig := <-signalCh:
98-
fmt.Println("signal received, litestream shutting down")
98+
slog.Info("signal received, litestream shutting down")
9999

100100
if c.cmd != nil {
101-
fmt.Println("sending signal to exec process")
101+
slog.Info("sending signal to exec process")
102102
if err := c.cmd.Process.Signal(sig); err != nil {
103103
return fmt.Errorf("cannot signal exec process: %w", err)
104104
}
105105

106-
fmt.Println("waiting for exec process to close")
106+
slog.Info("waiting for exec process to close")
107107
if err := <-c.execCh; err != nil && !strings.HasPrefix(err.Error(), "signal:") {
108108
return fmt.Errorf("cannot wait for exec process: %w", err)
109109
}
@@ -114,7 +114,7 @@ func (m *Main) Run(ctx context.Context, args []string) (err error) {
114114
if e := c.Close(); e != nil && err == nil {
115115
err = e
116116
}
117-
fmt.Println("litestream shut down")
117+
slog.Info("litestream shut down")
118118
return err
119119

120120
case "restore":

cmd/litestream/restore.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"flag"
77
"fmt"
8+
"log/slog"
89
"os"
910
"strconv"
1011
"time"
@@ -52,7 +53,7 @@ func (c *RestoreCommand) Run(ctx context.Context, args []string) (err error) {
5253
return fmt.Errorf("cannot specify a replica URL and the -config flag")
5354
}
5455
if r, err = c.loadFromURL(ctx, fs.Arg(0), *ifDBNotExists, &opt); err == errSkipDBExists {
55-
fmt.Println("database already exists, skipping")
56+
slog.Info("database already exists, skipping")
5657
return nil
5758
} else if err != nil {
5859
return err
@@ -62,7 +63,7 @@ func (c *RestoreCommand) Run(ctx context.Context, args []string) (err error) {
6263
*configPath = DefaultConfigPath()
6364
}
6465
if r, err = c.loadFromConfig(ctx, fs.Arg(0), *configPath, !*noExpandEnv, *ifDBNotExists, &opt); err == errSkipDBExists {
65-
fmt.Println("database already exists, skipping")
66+
slog.Info("database already exists, skipping")
6667
return nil
6768
} else if err != nil {
6869
return err
@@ -73,7 +74,7 @@ func (c *RestoreCommand) Run(ctx context.Context, args []string) (err error) {
7374
// If optional flag set, return success. Useful for automated recovery.
7475
if opt.Generation == "" {
7576
if *ifReplicaExists {
76-
fmt.Println("no matching backups found")
77+
slog.Info("no matching backups found")
7778
return nil
7879
}
7980
return fmt.Errorf("no matching backups found")

0 commit comments

Comments
 (0)