-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
story(sqsslog): create helpers to standardize log attributes related …
…to sqs (#37) * feat(issue-25): add helper package for standardizing sqs log messages * refactor(issue-25): use helper package to ensure consistent log field names
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023 Z5Labs and Contributors | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
package sqsslog | ||
|
||
import "log/slog" | ||
|
||
// MessageId | ||
func MessageId(s string) slog.Attr { | ||
return slog.String("sqs_message_id", s) | ||
} | ||
|
||
// ReceiptHandle | ||
func ReceiptHandle(s string) slog.Attr { | ||
return slog.String("sqs_receipt_handle", s) | ||
} | ||
|
||
// MessageAttributes | ||
func MessageAttributes(m map[string]string) slog.Attr { | ||
attrs := make([]any, len(m)) | ||
for key, val := range m { | ||
attrs = append(attrs, slog.String(key, val)) | ||
} | ||
return slog.Group("sqs_message_attributes", attrs...) | ||
} |