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

feat(audit): Add the ability to specify a custom audit log serializer… #1746

Merged
merged 1 commit into from Feb 1, 2019

Conversation

daviande
Copy link
Contributor

… (for err, req and res)

Pre-Submission Checklist

  • Opened an issue discussing these changes before opening the PR
  • [x ] Ran the linter and tests via make prepush
  • [x ] Included comprehensive and convincing tests for changes

Issues

Closes:

  • Issue #
  • Issue #
  • Issue #

Summarize the issues that discussed these changes

Changes

What does this PR do?

Adds the ability to specify a custom audit log serializer for err, req and res

@daviande daviande force-pushed the audit-serializers branch 2 times, most recently from fdf4e59 to 443374d Compare January 30, 2019 23:17
Copy link
Member

@DonutEspresso DonutEspresso left a 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.

if (!res) {
return false;
}
var reqSerializer = function auditRequestSerializer(req) {
Copy link
Member

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?

Copy link
Contributor Author

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?

};
};

if (opts.serializers && opts.serializers.res) {
Copy link
Member

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);

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Member

@DonutEspresso DonutEspresso left a comment

Choose a reason for hiding this comment

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

awesome, lgtm!

Copy link
Member

@retrohacker retrohacker left a 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

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.

None yet

3 participants