-
Notifications
You must be signed in to change notification settings - Fork 984
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
feat(audit): Add the ability to specify a custom audit log serializer… #1746
Conversation
fdf4e59
to
443374d
Compare
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.
Thanks! Some minor style suggestions - let me know what you think.
lib/plugins/audit.js
Outdated
if (!res) { | ||
return false; | ||
} | ||
var reqSerializer = function auditRequestSerializer(req) { |
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.
Now that you've broken out the default serializers, it looks like these could probably be lifted to the top as constants/defaults (or maybe even a DEFAULT_SERIALIZERS
obj). Is that possible, or do we need the closure still?
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.
I think we still need the closure because of the " body: opts.body === true ? req.body : undefined,". We could do something like create a function that returns the DEFAULT_SERIALIZERS and pass it the opts/opts.body param. It might just be enough to define a DEFAULTS_SERIALIZERS within the clousure, though. What do you think is more readable?
lib/plugins/audit.js
Outdated
}; | ||
}; | ||
|
||
if (opts.serializers && opts.serializers.res) { |
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.
Style nit: might we be able to collapse these three if checks into a single assignment? Something like:
var serializers = Object.assign({}, DEFAULT_SERIALIZERS, opts.serializers);
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.
This is a good idea.
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.
Made the change, what do you think now @DonutEspresso?
… (for err, req and res)
443374d
to
8380209
Compare
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.
awesome, lgtm!
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.
LGTM!
I think this resolves this stale issue: #1601
… (for err, req and res)
Pre-Submission Checklist
make prepush
Issues
Closes:
Changes
Adds the ability to specify a custom audit log serializer for err, req and res