It is sometimes desirable to log messages while rendering the spinner. Users can do this currently is by not setting a StopMessage and using Stop + Start to temporarily pause the spinner, remove the spinner text and log the message to standard output (example program below).
While this does work, I think it is worthwhile to add a spinner.LogMessage API that adds this functionality. Would love to contribute changes here if this idea makes sense.
package main
import (
"fmt"
"time"
"github.com/theckman/yacspin"
)
func logProgress(spin *yacspin.Spinner, message string) {
spin.Stop()
fmt.Println(message)
spin.Start()
}
func main() {
spin, _ := yacspin.New(yacspin.Config{
Frequency: time.Millisecond * 200,
CharSet: yacspin.CharSets[9],
Message: " Spinning...",
})
spin.Start()
for i := 0; i < 10; i++ {
logProgress(spin, fmt.Sprintf("Step %d completed.", i))
time.Sleep(1000 * time.Millisecond)
}
spin.Stop()
}
It is sometimes desirable to log messages while rendering the spinner. Users can do this currently is by not setting a
StopMessageand usingStop+Startto temporarily pause the spinner, remove the spinner text and log the message to standard output (example program below).While this does work, I think it is worthwhile to add a
spinner.LogMessageAPI that adds this functionality. Would love to contribute changes here if this idea makes sense.