Skip to content

Commit

Permalink
Add logging in the send tweet handler (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
boreq authored Oct 30, 2023
1 parent 27a4d17 commit cc829c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion service/app/handler_send_tweet.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func NewSendTweetHandler(
func (h *SendTweetHandler) Handle(ctx context.Context, cmd SendTweet) (err error) {
defer h.metrics.StartApplicationCall("sendTweet").End(&err)

h.logger.Debug().
WithField("accountID", cmd.accountID).
WithField("tweet", cmd.tweet.Text()).
Message("attempting to post a tweet")

var userTokens *accounts.TwitterUserTokens
if err := h.transactionProvider.Transact(ctx, func(ctx context.Context, adapters Adapters) error {
tmp, err := adapters.UserTokens.Get(cmd.accountID)
Expand All @@ -52,7 +57,7 @@ func (h *SendTweetHandler) Handle(ctx context.Context, cmd SendTweet) (err error
userTokens = tmp
return nil
}); err != nil {
return errors.Wrap(err, "Transaction error")
return errors.Wrap(err, "transaction error")
}

if err := h.twitter.PostTweet(ctx, userTokens.AccessToken(), userTokens.AccessSecret(), cmd.tweet); err != nil {
Expand Down

0 comments on commit cc829c3

Please sign in to comment.