-
Notifications
You must be signed in to change notification settings - Fork 32
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
Conversation
There was a problem hiding this 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] | ||
}) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | ||
} | ||
|
There was a problem hiding this comment.
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?
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:
|
Merged, thanks :) |
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
andres
. This option follows a similar pattern toobscureHeaders
.