From 7afc01d14e6d4734783a2083e060a6130394e122 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 17 Nov 2024 16:08:00 -0600 Subject: [PATCH] try a really fast loop to see how it works out --- cmd.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd.go b/cmd.go index 7c466db..b48d9ff 100644 --- a/cmd.go +++ b/cmd.go @@ -149,21 +149,31 @@ func PathRunRealtime(pwd string, args []string) cmd.Status { } statusChan := findCmd.Start() // non-blocking - ticker := time.NewTicker(500 * time.Millisecond) + ticker := time.NewTicker(5 * time.Millisecond) // this is interesting, maybe useful, but wierd, but neat. interesting even // Print last line of stdout every 2s go func() { + // loop very quickly, but only print the line if it changes + var lastout string + var lasterr string for range ticker.C { status := findCmd.Status() n := len(status.Stdout) if n != 0 { - log.Info(status.Stdout[n-1]) - // fmt.Printf("status", status.Exit, "complete =", status.Complete) + newline := status.Stdout[n-1] + if lastout != newline { + lastout = newline + log.Info(lastout) + } } n = len(status.Stderr) if n != 0 { - log.Info(status.Stderr[n-1]) + newline := status.Stderr[n-1] + if lasterr != newline { + lasterr = newline + log.Info(lasterr) + } } if status.Complete { return