From 0bd785e04e83f7580cce6f26eb24d5b5092d78cd Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 21 Feb 2024 18:15:37 -0500 Subject: [PATCH] feat: add logging to command plugn trigger output when executed with trace mode on --- plugins/common/plugn.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/common/plugn.go b/plugins/common/plugn.go index 422dbfba3..8ce905ac5 100644 --- a/plugins/common/plugn.go +++ b/plugins/common/plugn.go @@ -2,7 +2,10 @@ package common import ( "context" + "fmt" "io" + "os" + "strings" ) // PlugnTriggerInput is the input for CallPlugnTrigger @@ -41,7 +44,7 @@ func CallPlugnTrigger(input PlugnTriggerInput) (ExecCommandResponse, error) { func CallPlugnTriggerWithContext(ctx context.Context, input PlugnTriggerInput) (ExecCommandResponse, error) { args := []string{"trigger", input.Trigger} args = append(args, input.Args...) - return CallExecCommandWithContext(ctx, ExecCommandInput{ + result, err := CallExecCommandWithContext(ctx, ExecCommandInput{ Command: "plugn", Args: args, DisableStdioBuffer: input.DisableStdioBuffer, @@ -51,4 +54,15 @@ func CallPlugnTriggerWithContext(ctx context.Context, input PlugnTriggerInput) ( StreamStdout: input.StreamStdout, StreamStderr: input.StreamStderr, }) + + if os.Getenv("DOKKU_TRACE") == "1" { + for _, line := range strings.Split(result.Stderr, "\n") { + LogDebug(fmt.Sprintf("plugn trigger %s stderr: %s", input.Trigger, line)) + } + for _, line := range strings.Split(result.Stdout, "\n") { + LogDebug(fmt.Sprintf("plugn trigger %s stdout: %s", input.Trigger, line)) + } + } + + return result, err }