Skip to content

Feature: Add logging of HTTP status code #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 29, 2019
Merged

Feature: Add logging of HTTP status code #7

merged 6 commits into from
Jan 29, 2019

Conversation

tisba
Copy link
Contributor

@tisba tisba commented Jan 29, 2019

This PR adds logging of the HTTP status code.

I'm not sure if this is the "right" approach, as I'm still pretty new to Golang. I'd appreciate any guidance on how this might be build in a better or more idiomatic way 🙏

Fixes #6

@tisba tisba requested a review from syntaqx as a code owner January 29, 2019 08:43
@tisba
Copy link
Contributor Author

tisba commented Jan 29, 2019

Not sure why, but I get no errors when running golangci-lint run on master locally ¯_(ツ)_/¯

Anyway, the locations that CI reports, AFAIK have nothing to do with my change set.

@syntaqx
Copy link
Owner

syntaqx commented Jan 29, 2019

Yeah, this is something that's been popping up in the newest version of Go, it's actually super annoying. I haven't quite nailed down what it is. Just take the variables it's talking about and name them _ and it'll fix the issue

@syntaqx
Copy link
Owner

syntaqx commented Jan 29, 2019

Let me actually just make that in a separate PR, one moment.

Copy link
Owner

@syntaqx syntaqx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only main feedback on this, is that I would have probably put statusWriter into a different file, if not a different package entirely. That helps inform others to test it more generally as a standalone object rather than a side-effect of the logger. This pattern is most certainly reusable for other things (ie, # of bytes written, etc). None of this is blocking however, so let's get you merged in.

Copy link
Owner

@syntaqx syntaqx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oop, I didn't realize the codecoverage was lowered based on my previous comment. Can you please ensure we have 100% coverage so I can merge it in?

Seems like you need to add a test where the usecase doesn't set a status code so your default condition kicks in. A table driven test would be great for this in your current implementation.

@tisba
Copy link
Contributor Author

tisba commented Jan 29, 2019

Ups, I already pushed a change to delint serve_test.go. If you like, you can cherry pick.

@tisba
Copy link
Contributor Author

tisba commented Jan 29, 2019

Oop, I didn't realize the codecoverage was lowered based on my previous comment. Can you please ensure we have 100% coverage so I can merge it in?

Seems like you need to add a test where the usecase doesn't set a status code so your default condition kicks in. A table driven test would be great for this in your current implementation.

Sure thing! I'll give it a try :)

@tisba
Copy link
Contributor Author

tisba commented Jan 29, 2019

Okay, so I extracted statusWriter into its own file and also added one more test case without setting the status code (by using table test).

@syntaqx syntaqx merged commit b8ba0e4 into syntaqx:master Jan 29, 2019
@tisba tisba deleted the feature/log-status-code branch January 29, 2019 10:27
@tisba
Copy link
Contributor Author

tisba commented Jan 29, 2019

Out of curiosity: You've uploaded a new release to GitHub, but did not update the homebrew-tap repo. Not sure if this was intentional, or an issue; I just wanted to let you know.

@syntaqx
Copy link
Owner

syntaqx commented Jan 29, 2019

Hmmm... might have been a bug with the release. Let me dig into it. That def is supposed to be automated.

@syntaqx
Copy link
Owner

syntaqx commented Jan 29, 2019

Hopefully should be fixed now

@tisba
Copy link
Contributor Author

tisba commented Jan 31, 2019

Yes, it does! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants