Skip to content

Commit

Permalink
Log as debug the case when we can't get terminal size
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Jun 18, 2024
1 parent 23d8f91 commit 41db838
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ func showProgress(ctx context.Context, gs *state.GlobalState, pbs []*pb.Progress
return
}

var errTermGetSize bool
var terminalSizeUnknown bool
termWidth := defaultTermWidth
if gs.Stdout.IsTTY {
tw, _, err := term.GetSize(gs.Stdout.RawOutFd)
if !(tw > 0) || err != nil {
errTermGetSize = true
logger.WithError(err).Warn("error getting terminal size")
terminalSizeUnknown = true
logger.WithError(err).Debug("can't get terminal size")
} else {
termWidth = tw
}
Expand Down Expand Up @@ -353,7 +353,7 @@ func showProgress(ctx context.Context, gs *state.GlobalState, pbs []*pb.Progress
gs.OutMutex.Unlock()
return
case <-winch:
if gs.Stdout.IsTTY && !errTermGetSize {
if gs.Stdout.IsTTY && !terminalSizeUnknown {
// More responsive progress bar resizing on platforms with SIGWINCH (*nix)
tw, _, err := term.GetSize(stdoutFD)
if tw > 0 && err == nil {
Expand All @@ -362,7 +362,7 @@ func showProgress(ctx context.Context, gs *state.GlobalState, pbs []*pb.Progress
}
case <-ticker.C:
// Default ticker-based progress bar resizing
if gs.Stdout.IsTTY && !errTermGetSize && winch == nil {
if gs.Stdout.IsTTY && !terminalSizeUnknown && winch == nil {
tw, _, err := term.GetSize(stdoutFD)
if tw > 0 && err == nil {
termWidth = tw
Expand Down

0 comments on commit 41db838

Please sign in to comment.