@@ -28,6 +28,15 @@ import (
2828 "github.com/prometheus/procfs"
2929)
3030
31+ // TODO: Tune these parameters for optimal experience/performance
32+ const (
33+ // Output is flushed when the cursor doesn't move for this duration
34+ AnsiStripFlushInterval = 500 * time .Millisecond
35+
36+ // Output is flushed regardless of cursor activity after this maximum delay
37+ AnsiStripMaxDelay = 3 * time .Second
38+ )
39+
3140type RunExecutor struct {
3241 tempDir string
3342 homeDir string
@@ -132,7 +141,7 @@ func (ex *RunExecutor) Run(ctx context.Context) (err error) {
132141 }
133142 }()
134143
135- stripper := ansistrip .NewWriter (ex .runnerLogs , 500 * time . Millisecond , 3 * time . Second )
144+ stripper := ansistrip .NewWriter (ex .runnerLogs , AnsiStripFlushInterval , AnsiStripMaxDelay )
136145 logger := io .MultiWriter (runnerLogFile , os .Stdout , stripper )
137146 ctx = log .WithLogger (ctx , log .NewEntry (logger , int (log .DefaultEntry .Logger .Level ))) // todo loglevel
138147 log .Info (ctx , "Run job" , "log_level" , log .GetLogger (ctx ).Logger .Level .String ())
@@ -439,7 +448,7 @@ func (ex *RunExecutor) execJob(ctx context.Context, jobLogFile io.Writer) error
439448 defer func () { _ = ptm .Close () }()
440449 defer func () { _ = cmd .Wait () }() // release resources if copy fails
441450
442- stripper := ansistrip .NewWriter (ex .jobLogs , 500 * time . Millisecond , 3 * time . Second )
451+ stripper := ansistrip .NewWriter (ex .jobLogs , AnsiStripFlushInterval , AnsiStripMaxDelay )
443452 logger := io .MultiWriter (jobLogFile , ex .jobWsLogs , stripper )
444453 _ , err = io .Copy (logger , ptm )
445454 if err != nil && ! isPtyError (err ) {
0 commit comments