Skip to content

Commit

Permalink
logging tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rgarcia committed Sep 28, 2017
1 parent 2f0a155 commit 4e66813
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.1.2
12 changes: 7 additions & 5 deletions cmd/sfncli/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sfn"
"github.com/aws/aws-sdk-go/service/sfn/sfniface"
"gopkg.in/Clever/kayvee-go.v6/logger"
)

// stay within documented limits of SFN APIs
Expand Down Expand Up @@ -47,11 +48,6 @@ func (t TaskRunner) Process(ctx context.Context) error {
if t.sfnapi == nil {
return nil // if New failed :-/
}
log.InfoD("exec-command", map[string]interface{}{
"args": t.args,
"cmd": t.cmd,
})

cmd := exec.CommandContext(ctx, t.cmd, t.args...)
cmd.Env = os.Environ()

Expand All @@ -62,7 +58,12 @@ func (t TaskRunner) Process(ctx context.Context) error {
cmd.Stderr = io.MultiWriter(os.Stderr, stderrbuf)
cmd.Stdout = io.MultiWriter(os.Stdout, stdoutbuf)

log.InfoD("exec-command-start", map[string]interface{}{
"args": t.args,
"cmd": t.cmd,
})
if err := cmd.Run(); err != nil {
log.InfoD("exec-command-err", logger.M{"error": err.Error()})
if _, e := t.sfnapi.SendTaskFailureWithContext(ctx, &sfn.SendTaskFailureInput{
Cause: aws.String(stderrbuf.String()),
TaskToken: &t.taskToken,
Expand All @@ -71,6 +72,7 @@ func (t TaskRunner) Process(ctx context.Context) error {
}
return err
}
log.Info("exec-command-end")

// AWS requires JSON output. If it isn't, then make it so.
output := stdoutbuf.String()
Expand Down
2 changes: 1 addition & 1 deletion cmd/sfncli/sfncli.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func main() {
log.Info("getactivitytask-stop")
continue
case <-ticker.C:
log.InfoD("getactivitytask-start", logger.M{"activity-arn": *createOutput.ActivityArn, "worker-name": *workerName})
getATOutput, err := sfnapi.GetActivityTaskWithContext(mainCtx, &sfn.GetActivityTaskInput{
ActivityArn: createOutput.ActivityArn,
WorkerName: workerName,
Expand All @@ -102,7 +103,6 @@ func main() {
continue
}
if getATOutput.TaskToken == nil {
log.Info("getactivitytask-restart")
continue
}
input := *getATOutput.Input
Expand Down

0 comments on commit 4e66813

Please sign in to comment.