Skip to content

Commit

Permalink
✨ Add time taken to success logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jun 29, 2022
1 parent 4d4b3d8 commit d1a9694
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ func run(cmd *cobra.Command, args []string) (err error) {
fmt.Println("::set-output name=filename::" + conf.Filename)
}

var startTime = time.Now()

bar := progressbar.New(-1, "downloading")
plogger := progressbar.NewBarSafeLogger(os.Stderr, bar)
log.SetOutput(plogger)
Expand Down Expand Up @@ -216,7 +218,10 @@ func run(cmd *cobra.Command, args []string) (err error) {
}
}

log.WithField("file", conf.Filename).Info("dump complete")
log.WithFields(log.Fields{
"file": conf.Filename,
"in": time.Since(startTime).Truncate(10 * time.Millisecond),
}).Info("dump complete")
return nil
}

Expand Down
8 changes: 7 additions & 1 deletion cmd/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/kubectl/pkg/util/term"
"os"
"strings"
"time"
)

var Command = &cobra.Command{
Expand Down Expand Up @@ -126,6 +127,8 @@ func run(cmd *cobra.Command, args []string) (err error) {
}
}

startTime := time.Now()

bar := progressbar.New(-1, "uploading")
errLog := progressbar.NewBarSafeLogger(os.Stderr, bar)
outLog := progressbar.NewBarSafeLogger(os.Stdout, bar)
Expand Down Expand Up @@ -193,7 +196,10 @@ func run(cmd *cobra.Command, args []string) (err error) {
return err
}

log.WithField("file", conf.Filename).Info("restore complete")
log.WithFields(log.Fields{
"file": conf.Filename,
"in": time.Since(startTime).Truncate(10 * time.Millisecond),
}).Info("restore complete")
return nil
}

Expand Down

0 comments on commit d1a9694

Please sign in to comment.