Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log as debug the case when we can't get terminal size #3798

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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