Conversation
This improves package structure.
This follows similar pattern as normal logger and log writer, except here we have structuredLogBuilder.
This improves readability.
More elegant. Does a deep copy.
Although, we assume request won't be nil, it's better to validate that.
go test -bench=. -benchmem -benchtime 10s goos: darwin goarch: arm64 pkg: github.com/saucelabs/forwarder/httplog cpu: Apple M1 Pro BenchmarkNormalShortURL-10 33868418 352.9 ns/op 288 B/op 11 allocs/op BenchmarkNormalHeaders-10 3090453 3852 ns/op 7480 B/op 52 allocs/op BenchmarkNormalBody-10 2540685 4772 ns/op 10299 B/op 60 allocs/op BenchmarkStructuredShortURL-10 42058107 287.0 ns/op 464 B/op 8 allocs/op BenchmarkStructuredHeaders-10 7712139 1558 ns/op 2704 B/op 22 allocs/op BenchmarkStructuredBody-10 6497708 1852 ns/op 3904 B/op 30 allocs/op PASS Note: Actual performance may vary depending on the logFunc implementation and the sink.
Contributor
Author
|
I decided to apply some improvements. PTAL @markamsauce. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Structured http logs will be needed once we migrate to
log/slog.