Skip to content
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

Support excluding request headers from log output #12

Merged
merged 6 commits into from
May 12, 2017

Conversation

ch2ch3
Copy link
Contributor

@ch2ch3 ch2ch3 commented Mar 7, 2017

Hi @tellnes ,

I'd like to submit a PR for excluding headers from log output. When working in development I often find the log output too noisy, but I still want to be able to inspect req and res. This option follows a similar pattern to obscureHeaders.

Copy link
Owner

@tellnes tellnes left a comment

Choose a reason for hiding this comment

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

Added a few comments. If you don't feel like doing more work, I'm happy to merge this as it is.

index.js Outdated
var headers = {}
Object.keys(obj.headers).forEach(function(name) {
headers[name] = obj.headers[name]
})
Copy link
Owner

Choose a reason for hiding this comment

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

We don't need to copy obj.headers both here and above in the obscureHeaders block if you are using both obscureHeaders and excludeHeaders. This can be merged to one operation.

Eg.
if (obj.headers && (obscureHeaders || excludeHeaders)) {

And then wrapping the for-loops with for obscureHeaders and excldueHeaders` in an if.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout. I've made a further change to do all the copying/deleting in a single reduce loop. What do you think?

index.js Outdated
} else {
excludeHeaders = false
}

Copy link
Owner

Choose a reason for hiding this comment

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

Just a suggestion, maybe we should split this out to a function so we don't repeat the code twice?

@ch2ch3
Copy link
Contributor Author

ch2ch3 commented Apr 3, 2017

Hey @tellnes, did you have any further thoughts on this? I left a comment above but it's been collapsed, so not sure if you've seen it. Copying below:

Good shout. I've made a further change to do all the copying/deleting in a single reduce loop. What do you think?

@tellnes tellnes merged commit 389fb98 into tellnes:master May 12, 2017
@tellnes
Copy link
Owner

tellnes commented May 12, 2017

Merged, thanks :)

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