github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/cmd/chore/e2e/run/progress.go (about)

     1  package main
     2  
     3  import (
     4  	"math"
     5  	"strings"
     6  	"time"
     7  )
     8  
     9  func printProgress(prefix operatorPrefix, settings programSettings, step string, started time.Time, timeout time.Duration) {
    10  	elapsed := int(math.Round(float64(time.Now().Sub(started)) / float64(timeout) * 100))
    11  	left := 100 - elapsed
    12  
    13  	logProgress := settings.logger.Infof
    14  	if elapsed > 85 {
    15  		logProgress = settings.logger.Warnf
    16  	}
    17  	logProgress("%s%s step %s timeout status %s [%s%s] %s (%d%%)\n",
    18  		prefix,
    19  		settings.orbID,
    20  		step,
    21  		started.Format("15:04:05"),
    22  		strings.Repeat("#", elapsed),
    23  		strings.Repeat("_", left),
    24  		started.Add(timeout).Format("15:04:05"), elapsed)
    25  }