From af5c1201cd46ced26eb2aa6882077d2294482798 Mon Sep 17 00:00:00 2001 From: CMGS Date: Fri, 13 Jan 2023 16:24:43 +0800 Subject: [PATCH] output binary input --- resource3/plugins/binary/call.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resource3/plugins/binary/call.go b/resource3/plugins/binary/call.go index 45b2bad97..ea4ee7054 100644 --- a/resource3/plugins/binary/call.go +++ b/resource3/plugins/binary/call.go @@ -19,7 +19,7 @@ func (p Plugin) call(ctx context.Context, cmd string, req interface{}, resp inte command.Dir = p.config.ResourcePlugin.Dir logger.Infof(ctx, "call %s", command.String()) - out, err := p.execCommand(command, req) + out, err := p.execCommand(ctx, command, req) if err != nil { logger.Error(ctx, err, string(out)) return err @@ -31,11 +31,13 @@ func (p Plugin) call(ctx context.Context, cmd string, req interface{}, resp inte return json.Unmarshal(out, resp) } -func (p Plugin) execCommand(cmd *exec.Cmd, req interface{}) ([]byte, error) { +func (p Plugin) execCommand(ctx context.Context, cmd *exec.Cmd, req interface{}) ([]byte, error) { + logger := log.WithFunc("resource.binary.execCommand") b, err := json.Marshal(req) if err != nil { return nil, err } + logger.WithField("in", string(b)).Debug(ctx, "call params") cmd.Stdin = bytes.NewBuffer(b) return cmd.CombinedOutput() }