diff --git a/README.md b/README.md index aa5687f..082e394 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,21 @@ Dump AWS SQS messages to the output -Example: - +### Usage ```shell sqsdumper -s your-queue-dead-letter-queue ``` +with `jq` + +```shell + sqsdumper -s your-queue-dead-letter-queue | jq .foo +``` + +get in json_path (if no `jq` installed) + +```shell + sqsdumper -s your-queue-dead-letter-queue -jp foo +``` ### Help: diff --git a/cmd/main.go b/cmd/main.go index 4aa1d7e..16d4bb2 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -92,7 +92,7 @@ func main() { total := poller.GetTotal() defer func() { - fmt.Printf("\n === total processed: %d", total) + l.Log().Msgf(" === total processed: %d", total) }() return poller.PollMessages(ctx.Context, commander.ProcessMessages(ctx.Context)) diff --git a/internal/commands/dump_messages.go b/internal/commands/dump_messages.go index a46df67..fe28067 100644 --- a/internal/commands/dump_messages.go +++ b/internal/commands/dump_messages.go @@ -73,7 +73,11 @@ func (p *SQSDumper) processMessage(_ context.Context, msg types.Message) error { } stringed = strings.ReplaceAll(stringed, `\"`, `"`) - fmt.Printf("\n%s", stringed) + if len(stringed) >= 2 { + fmt.Println(stringed[1 : len(stringed)-1]) + } else { + fmt.Println(stringed) + } return nil } diff --git a/internal/wrappers/aws/sqs.go b/internal/wrappers/aws/sqs.go index b7205f4..6078795 100644 --- a/internal/wrappers/aws/sqs.go +++ b/internal/wrappers/aws/sqs.go @@ -2,6 +2,7 @@ package aws import ( "context" + "fmt" "strconv" "github.com/aws/aws-sdk-go-v2/service/sqs" @@ -120,6 +121,7 @@ func (s *sqsPoller) PollMessages(ctx context.Context, messageHandler MessageHand } if processed >= s.totalMessages && s.stopOnTotal { + fmt.Printf("\n") s.logger.Log().Msg("all messages processed") return nil }