From a3c9f0cca96d3e0c40c0231e380543419574cc4d Mon Sep 17 00:00:00 2001 From: Damon To Date: Fri, 7 Jun 2024 16:55:06 +0800 Subject: [PATCH] chore: update lpac cmd.go to capture and log command wait error and stderr --- internal/lpac/cmd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/lpac/cmd.go b/internal/lpac/cmd.go index ad737cf..2028b0d 100644 --- a/internal/lpac/cmd.go +++ b/internal/lpac/cmd.go @@ -2,6 +2,7 @@ package lpac import ( "bufio" + "bytes" "context" "encoding/json" "errors" @@ -31,6 +32,8 @@ func (c *Cmd) Run(arguments []string, dst any, progress Progress) error { cmd.Env = append(cmd.Env, "LPAC_APDU=stdio") c.forSystem(cmd) + stderr := bytes.Buffer{} + cmd.Stderr = &stderr stdout, _ := cmd.StdoutPipe() stdin, _ := cmd.StdinPipe() @@ -40,7 +43,7 @@ func (c *Cmd) Run(arguments []string, dst any, progress Progress) error { cmdErr := c.process(stdout, stdin, dst, progress) if err := cmd.Wait(); err != nil { - slog.Error("command wait error", "error", err) + slog.Error("command wait error", "error", err, "stderr", stderr.String()) } return cmdErr }