From f8c330aae3d696759707c946fb5a6f710355b85c Mon Sep 17 00:00:00 2001 From: James Read Date: Mon, 2 Sep 2024 23:59:19 +0100 Subject: [PATCH] feature: Better feedback on shellAfterCommand, and mark OliveTin specific output with "OliveTin::" in logs (#403) --- internal/executor/executor.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/executor/executor.go b/internal/executor/executor.go index 5821dde..22b7dda 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -491,7 +491,7 @@ func stepExec(req *ExecutionRequest) bool { // The context timeout should kill the process, but let's make sure. req.executor.Kill(req.logEntry) req.logEntry.TimedOut = true - req.logEntry.Output += "This OliveTin action timed out after " + fmt.Sprintf("%v", req.Action.Timeout) + " seconds. If you need more time for this action, set a longer timeout. See https://docs.olivetin.app/timeout.html for more help." + req.logEntry.Output += "OliveTin::timeout - this action timed out after " + fmt.Sprintf("%v", req.Action.Timeout) + " seconds. If you need more time for this action, set a longer timeout. See https://docs.olivetin.app/timeout.html for more help." } req.logEntry.DatetimeFinished = time.Now() @@ -525,17 +525,24 @@ func stepExecAfter(req *ExecutionRequest) bool { waiterr := cmd.Wait() - req.logEntry.Output += "---\n" + stdout.String() - req.logEntry.Output += "---\n" + stderr.String() + req.logEntry.Output += "\n" + stdout.String() + req.logEntry.Output += "OliveTin::shellAfterCompleted stdout\n" + stdout.String() + req.logEntry.Output += stdout.String() + req.logEntry.Output += "OliveTin::shellAfterCompleted stderr\n" + stdout.String() + req.logEntry.Output += stderr.String() + + req.logEntry.Output += "OliveTin::shellAfterCompleted errors and summary\n" + stdout.String() appendErrorToStderr(runerr, req.logEntry) appendErrorToStderr(waiterr, req.logEntry) if ctx.Err() == context.DeadlineExceeded { - req.logEntry.Output += "Your shellAfterCommand command timed out." + req.logEntry.Output += "Your shellAfterCompleted command timed out." } - req.logEntry.Output += fmt.Sprintf("Your shellAfterCommand exited with code %v", cmd.ProcessState.ExitCode()) + req.logEntry.Output += fmt.Sprintf("Your shellAfterCompleted exited with code %v\n", cmd.ProcessState.ExitCode()) + + req.logEntry.Output += "OliveTin::shellAfterCompleted output complete\n" + stdout.String() return true }