Skip to content

Commit

Permalink
Development (#4)
Browse files Browse the repository at this point in the history
* updated README, releases

* updated logging
  • Loading branch information
andboson authored Jul 31, 2022
1 parent 4ef965c commit 1cba96b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@

Dump AWS SQS messages to the output

Example:

### Usage
```shell
<AWS_PROFILE=specific_profile> sqsdumper -s your-queue-dead-letter-queue
```
with `jq`

```shell
<AWS_PROFILE=specific_profile> sqsdumper -s your-queue-dead-letter-queue | jq .foo
```

get in json_path (if no `jq` installed)

```shell
<AWS_PROFILE=specific_profile> sqsdumper -s your-queue-dead-letter-queue -jp foo
```


### Help:
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 5 additions & 1 deletion internal/commands/dump_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions internal/wrappers/aws/sqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"context"
"fmt"
"strconv"

"github.com/aws/aws-sdk-go-v2/service/sqs"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 1cba96b

Please sign in to comment.