{"action":"created","comment":{"url":"https://api.github.com/repos/restify/node-restify/pulls/comments/198023353","pull_request_review_id":131876054,"id":198023353,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODAyMzM1Mw==","diff_hunk":"@@ -196,68 +196,90 @@ function auditLogger(opts) {\n     if (typeof printLog === 'undefined') {\n         printLog = true;\n     }\n+\n+    /**\n+     * Serialize the HTTP Request into a plain object, for logging\n+     *\n+     * @private\n+     * @function auditRequestSerializer\n+     * @param {http.ClientRequest} req - Incoming request\n+     * @returns {object} Serialized request\n+     */\n+    function auditRequestSerializer(req) {\n+        if (!req) {\n+            return false;\n+        }\n+\n+        var timers = {};\n+        (req.timers || []).forEach(function forEach(time) {\n+            var t = time.time;\n+            var _t = Math.floor(1000000 * t[0] + t[1] / 1000);\n+            timers[time.name] = (timers[time.name] || 0) + _t;\n+        });\n+        return {\n+            // account for native and queryParser plugin usage\n+            query: typeof req.query === 'function' ? req.query() : req.query,\n+            method: req.method,\n+            url: req.url,\n+            headers: req.headers,\n+            httpVersion: req.httpVersion,\n+            trailers: req.trailers,\n+            version: req.version(),\n+            body: opts.body === true ? req.body : undefined,\n+            timers: timers,\n+            connectionState: req.connectionState && req.connectionState()\n+        };\n+    }\n+\n+    /**\n+     * Serialize the HTTP Response into a plain object, for logging\n+     *\n+     * @private\n+     * @function auditResponseSerializer\n+     * @param {http.ServerResponse} res - outgoing server response\n+     * @returns {object} Serialized response\n+     */\n+    function auditResponseSerializer(res) {\n+        if (!res) {\n+            return false;\n+        }\n+\n+        var body;\n+\n+        if (opts.body === true) {\n+            if (res._body instanceof HttpError) {\n+                body = res._body.body;\n+            } else {\n+                body = res._body;\n+            }\n+        }\n+\n+        return {\n+            statusCode: res.statusCode,\n+            headers: getResponseHeaders(res),\n+            trailer: res._trailer || false,\n+            body: body\n+        };\n+    }\n+\n     var errSerializer = bunyan.stdSerializers.err;\n+    var reqSerializer = auditRequestSerializer;\n+    var resSerializer = auditResponseSerializer;\n \n-    if (opts.log.serializers && opts.log.serializers.err) {\n-        errSerializer = opts.log.serializers.err;\n+    // Allow override of serializers\n+    if (opts.log.serializers) {","path":"lib/plugins/audit.js","position":77,"original_position":77,"commit_id":"fbd7ec3ce068fe91131787c9514a3a507fc71436","original_commit_id":"fbd7ec3ce068fe91131787c9514a3a507fc71436","user":{"login":"DonutEspresso","id":2381315,"node_id":"MDQ6VXNlcjIzODEzMTU=","avatar_url":"https://avatars3.githubusercontent.com/u/2381315?v=4","gravatar_id":"","url":"https://api.github.com/users/DonutEspresso","html_url":"https://github.com/DonutEspresso","followers_url":"https://api.github.com/users/DonutEspresso/followers","following_url":"https://api.github.com/users/DonutEspresso/following{/other_user}","gists_url":"https://api.github.com/users/DonutEspresso/gists{/gist_id}","starred_url":"https://api.github.com/users/DonutEspresso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DonutEspresso/subscriptions","organizations_url":"https://api.github.com/users/DonutEspresso/orgs","repos_url":"https://api.github.com/users/DonutEspresso/repos","events_url":"https://api.github.com/users/DonutEspresso/events{/privacy}","received_events_url":"https://api.github.com/users/DonutEspresso/received_events","type":"User","site_admin":false},"body":"Basically, I am thinking of an explicit serializers option:\r\n\r\n```js\r\nSERVER.once('after', restify.plugins.auditLogger({\r\n    serializers: {...}\r\n});\r\n```\r\n\r\nThen within the audit logger we'd pull serializers from a top level `opts.serializers` instead of from `opts.log.serializers`.  I believe the fallback logic you have for picking between a passed in serializer and the default one is still applicable. This just makes serializers a bit more explicit since we're creating a new child logger here anyway. ","created_at":"2018-06-26T06:13:29Z","updated_at":"2018-06-26T06:13:29Z","html_url":"https://github.com/restify/node-restify/pull/1681#discussion_r198023353","pull_request_url":"https://api.github.com/repos/restify/node-restify/pulls/1681","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/restify/node-restify/pulls/comments/198023353"},"html":{"href":"https://github.com/restify/node-restify/pull/1681#discussion_r198023353"},"pull_request":{"href":"https://api.github.com/repos/restify/node-restify/pulls/1681"}},"in_reply_to_id":197597151},"pull_request":{"url":"https://api.github.com/repos/restify/node-restify/pulls/1681","id":194208763,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0MjA4NzYz","html_url":"https://github.com/restify/node-restify/pull/1681","diff_url":"https://github.com/restify/node-restify/pull/1681.diff","patch_url":"https://github.com/restify/node-restify/pull/1681.patch","issue_url":"https://api.github.com/repos/restify/node-restify/issues/1681","number":1681,"state":"open","locked":false,"title":"feat(audit): Support overriding default serializers","user":{"login":"mattgoucher","id":391298,"node_id":"MDQ6VXNlcjM5MTI5OA==","avatar_url":"https://avatars1.githubusercontent.com/u/391298?v=4","gravatar_id":"","url":"https://api.github.com/users/mattgoucher","html_url":"https://github.com/mattgoucher","followers_url":"https://api.github.com/users/mattgoucher/followers","following_url":"https://api.github.com/users/mattgoucher/following{/other_user}","gists_url":"https://api.github.com/users/mattgoucher/gists{/gist_id}","starred_url":"https://api.github.com/users/mattgoucher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattgoucher/subscriptions","organizations_url":"https://api.github.com/users/mattgoucher/orgs","repos_url":"https://api.github.com/users/mattgoucher/repos","events_url":"https://api.github.com/users/mattgoucher/events{/privacy}","received_events_url":"https://api.github.com/users/mattgoucher/received_events","type":"User","site_admin":false},"body":"<!--\r\nThank you for taking the time to open an PR for restify! If this is your first\r\ntime here, welcome to our community! We are a group of developers who work on\r\nrestify in our free-time. Some of us do it as a hobby, others are using restify\r\nat work. When asking for help here, keep in mind most of us are volunteers\r\ncontributing our daily work back to the community at no cost (and often for no\r\nreward). Please be respectful!\r\n\r\nBelow you will find a checklist to help you create the best PR possible. While\r\nthe checklist items aren't all _strictly_ required, they dramatically increase\r\nthe probability of your PR getting a response and getting merged. Often times,\r\nthe least time consuming part of maintaining and open source project is writing\r\ncode, its the process and discussions that happen around the code base that\r\nconsume a majority of the maintainers' time. By spending a few moments to\r\nadhere to this template, you are not only improve the quality of your PR, you\r\nare also helping save the maintainers a considerable amount of time when trying\r\nto understand and review your changes.\r\n\r\nAnd remember, positive vibes are met with positive vibes. Kindness helps Free\r\nSoftware go round, pay it forward!\r\n-->\r\n\r\n## Pre-Submission Checklist\r\n\r\n- [x] Opened an issue discussing these changes before opening the PR **(existing issue)**\r\n- [x] Ran the linter and tests via `make prepush`\r\n- [x] Included comprehensive and convincing tests for changes\r\n\r\n## Issues\r\n\r\nCloses:\r\n\r\n* Issue #1601\r\n\r\n> Similar to @ekristen, I have a use-case to override the existing req/res serializers that are passed by the Restify Audit plugin. As discussed in the issue #1601, when a child logger is derrived from the passed in logger, the serializers of the parent are overwritten by the child's.\r\n\r\n# Changes\r\n\r\n> This PR gives consumers the ability to pass their own serializers for req, res and err objects.\r\n","created_at":"2018-06-12T08:52:51Z","updated_at":"2018-06-26T06:13:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8044197ba79d536c7199ed3f8b7c20d7e2264160","assignee":null,"assignees":[],"requested_reviewers":[{"login":"hekike","id":1764512,"node_id":"MDQ6VXNlcjE3NjQ1MTI=","avatar_url":"https://avatars0.githubusercontent.com/u/1764512?v=4","gravatar_id":"","url":"https://api.github.com/users/hekike","html_url":"https://github.com/hekike","followers_url":"https://api.github.com/users/hekike/followers","following_url":"https://api.github.com/users/hekike/following{/other_user}","gists_url":"https://api.github.com/users/hekike/gists{/gist_id}","starred_url":"https://api.github.com/users/hekike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hekike/subscriptions","organizations_url":"https://api.github.com/users/hekike/orgs","repos_url":"https://api.github.com/users/hekike/repos","events_url":"https://api.github.com/users/hekike/events{/privacy}","received_events_url":"https://api.github.com/users/hekike/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/restify/node-restify/pulls/1681/commits","review_comments_url":"https://api.github.com/repos/restify/node-restify/pulls/1681/comments","review_comment_url":"https://api.github.com/repos/restify/node-restify/pulls/comments{/number}","comments_url":"https://api.github.com/repos/restify/node-restify/issues/1681/comments","statuses_url":"https://api.github.com/repos/restify/node-restify/statuses/fbd7ec3ce068fe91131787c9514a3a507fc71436","head":{"label":"mattgoucher:master","ref":"master","sha":"fbd7ec3ce068fe91131787c9514a3a507fc71436","user":{"login":"mattgoucher","id":391298,"node_id":"MDQ6VXNlcjM5MTI5OA==","avatar_url":"https://avatars1.githubusercontent.com/u/391298?v=4","gravatar_id":"","url":"https://api.github.com/users/mattgoucher","html_url":"https://github.com/mattgoucher","followers_url":"https://api.github.com/users/mattgoucher/followers","following_url":"https://api.github.com/users/mattgoucher/following{/other_user}","gists_url":"https://api.github.com/users/mattgoucher/gists{/gist_id}","starred_url":"https://api.github.com/users/mattgoucher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattgoucher/subscriptions","organizations_url":"https://api.github.com/users/mattgoucher/orgs","repos_url":"https://api.github.com/users/mattgoucher/repos","events_url":"https://api.github.com/users/mattgoucher/events{/privacy}","received_events_url":"https://api.github.com/users/mattgoucher/received_events","type":"User","site_admin":false},"repo":{"id":137038922,"node_id":"MDEwOlJlcG9zaXRvcnkxMzcwMzg5MjI=","name":"node-restify","full_name":"mattgoucher/node-restify","owner":{"login":"mattgoucher","id":391298,"node_id":"MDQ6VXNlcjM5MTI5OA==","avatar_url":"https://avatars1.githubusercontent.com/u/391298?v=4","gravatar_id":"","url":"https://api.github.com/users/mattgoucher","html_url":"https://github.com/mattgoucher","followers_url":"https://api.github.com/users/mattgoucher/followers","following_url":"https://api.github.com/users/mattgoucher/following{/other_user}","gists_url":"https://api.github.com/users/mattgoucher/gists{/gist_id}","starred_url":"https://api.github.com/users/mattgoucher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattgoucher/subscriptions","organizations_url":"https://api.github.com/users/mattgoucher/orgs","repos_url":"https://api.github.com/users/mattgoucher/repos","events_url":"https://api.github.com/users/mattgoucher/events{/privacy}","received_events_url":"https://api.github.com/users/mattgoucher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mattgoucher/node-restify","description":"The future of Node.js REST development","fork":true,"url":"https://api.github.com/repos/mattgoucher/node-restify","forks_url":"https://api.github.com/repos/mattgoucher/node-restify/forks","keys_url":"https://api.github.com/repos/mattgoucher/node-restify/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mattgoucher/node-restify/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mattgoucher/node-restify/teams","hooks_url":"https://api.github.com/repos/mattgoucher/node-restify/hooks","issue_events_url":"https://api.github.com/repos/mattgoucher/node-restify/issues/events{/number}","events_url":"https://api.github.com/repos/mattgoucher/node-restify/events","assignees_url":"https://api.github.com/repos/mattgoucher/node-restify/assignees{/user}","branches_url":"https://api.github.com/repos/mattgoucher/node-restify/branches{/branch}","tags_url":"https://api.github.com/repos/mattgoucher/node-restify/tags","blobs_url":"https://api.github.com/repos/mattgoucher/node-restify/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mattgoucher/node-restify/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mattgoucher/node-restify/git/refs{/sha}","trees_url":"https://api.github.com/repos/mattgoucher/node-restify/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mattgoucher/node-restify/statuses/{sha}","languages_url":"https://api.github.com/repos/mattgoucher/node-restify/languages","stargazers_url":"https://api.github.com/repos/mattgoucher/node-restify/stargazers","contributors_url":"https://api.github.com/repos/mattgoucher/node-restify/contributors","subscribers_url":"https://api.github.com/repos/mattgoucher/node-restify/subscribers","subscription_url":"https://api.github.com/repos/mattgoucher/node-restify/subscription","commits_url":"https://api.github.com/repos/mattgoucher/node-restify/commits{/sha}","git_commits_url":"https://api.github.com/repos/mattgoucher/node-restify/git/commits{/sha}","comments_url":"https://api.github.com/repos/mattgoucher/node-restify/comments{/number}","issue_comment_url":"https://api.github.com/repos/mattgoucher/node-restify/issues/comments{/number}","contents_url":"https://api.github.com/repos/mattgoucher/node-restify/contents/{+path}","compare_url":"https://api.github.com/repos/mattgoucher/node-restify/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mattgoucher/node-restify/merges","archive_url":"https://api.github.com/repos/mattgoucher/node-restify/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mattgoucher/node-restify/downloads","issues_url":"https://api.github.com/repos/mattgoucher/node-restify/issues{/number}","pulls_url":"https://api.github.com/repos/mattgoucher/node-restify/pulls{/number}","milestones_url":"https://api.github.com/repos/mattgoucher/node-restify/milestones{/number}","notifications_url":"https://api.github.com/repos/mattgoucher/node-restify/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mattgoucher/node-restify/labels{/name}","releases_url":"https://api.github.com/repos/mattgoucher/node-restify/releases{/id}","deployments_url":"https://api.github.com/repos/mattgoucher/node-restify/deployments","created_at":"2018-06-12T08:12:30Z","updated_at":"2018-06-12T09:08:31Z","pushed_at":"2018-06-12T09:08:28Z","git_url":"git://github.com/mattgoucher/node-restify.git","ssh_url":"git@github.com:mattgoucher/node-restify.git","clone_url":"https://github.com/mattgoucher/node-restify.git","svn_url":"https://github.com/mattgoucher/node-restify","homepage":"http://restify.com","size":4018,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"restify:master","ref":"master","sha":"b69e6ed106cf6784d1b2ed4995d812636ed23598","user":{"login":"restify","id":6948699,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NDg2OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/6948699?v=4","gravatar_id":"","url":"https://api.github.com/users/restify","html_url":"https://github.com/restify","followers_url":"https://api.github.com/users/restify/followers","following_url":"https://api.github.com/users/restify/following{/other_user}","gists_url":"https://api.github.com/users/restify/gists{/gist_id}","starred_url":"https://api.github.com/users/restify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/restify/subscriptions","organizations_url":"https://api.github.com/users/restify/orgs","repos_url":"https://api.github.com/users/restify/repos","events_url":"https://api.github.com/users/restify/events{/privacy}","received_events_url":"https://api.github.com/users/restify/received_events","type":"Organization","site_admin":false},"repo":{"id":1661758,"node_id":"MDEwOlJlcG9zaXRvcnkxNjYxNzU4","name":"node-restify","full_name":"restify/node-restify","owner":{"login":"restify","id":6948699,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NDg2OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/6948699?v=4","gravatar_id":"","url":"https://api.github.com/users/restify","html_url":"https://github.com/restify","followers_url":"https://api.github.com/users/restify/followers","following_url":"https://api.github.com/users/restify/following{/other_user}","gists_url":"https://api.github.com/users/restify/gists{/gist_id}","starred_url":"https://api.github.com/users/restify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/restify/subscriptions","organizations_url":"https://api.github.com/users/restify/orgs","repos_url":"https://api.github.com/users/restify/repos","events_url":"https://api.github.com/users/restify/events{/privacy}","received_events_url":"https://api.github.com/users/restify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/restify/node-restify","description":"The future of Node.js REST development","fork":false,"url":"https://api.github.com/repos/restify/node-restify","forks_url":"https://api.github.com/repos/restify/node-restify/forks","keys_url":"https://api.github.com/repos/restify/node-restify/keys{/key_id}","collaborators_url":"https://api.github.com/repos/restify/node-restify/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/restify/node-restify/teams","hooks_url":"https://api.github.com/repos/restify/node-restify/hooks","issue_events_url":"https://api.github.com/repos/restify/node-restify/issues/events{/number}","events_url":"https://api.github.com/repos/restify/node-restify/events","assignees_url":"https://api.github.com/repos/restify/node-restify/assignees{/user}","branches_url":"https://api.github.com/repos/restify/node-restify/branches{/branch}","tags_url":"https://api.github.com/repos/restify/node-restify/tags","blobs_url":"https://api.github.com/repos/restify/node-restify/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/restify/node-restify/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/restify/node-restify/git/refs{/sha}","trees_url":"https://api.github.com/repos/restify/node-restify/git/trees{/sha}","statuses_url":"https://api.github.com/repos/restify/node-restify/statuses/{sha}","languages_url":"https://api.github.com/repos/restify/node-restify/languages","stargazers_url":"https://api.github.com/repos/restify/node-restify/stargazers","contributors_url":"https://api.github.com/repos/restify/node-restify/contributors","subscribers_url":"https://api.github.com/repos/restify/node-restify/subscribers","subscription_url":"https://api.github.com/repos/restify/node-restify/subscription","commits_url":"https://api.github.com/repos/restify/node-restify/commits{/sha}","git_commits_url":"https://api.github.com/repos/restify/node-restify/git/commits{/sha}","comments_url":"https://api.github.com/repos/restify/node-restify/comments{/number}","issue_comment_url":"https://api.github.com/repos/restify/node-restify/issues/comments{/number}","contents_url":"https://api.github.com/repos/restify/node-restify/contents/{+path}","compare_url":"https://api.github.com/repos/restify/node-restify/compare/{base}...{head}","merges_url":"https://api.github.com/repos/restify/node-restify/merges","archive_url":"https://api.github.com/repos/restify/node-restify/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/restify/node-restify/downloads","issues_url":"https://api.github.com/repos/restify/node-restify/issues{/number}","pulls_url":"https://api.github.com/repos/restify/node-restify/pulls{/number}","milestones_url":"https://api.github.com/repos/restify/node-restify/milestones{/number}","notifications_url":"https://api.github.com/repos/restify/node-restify/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/restify/node-restify/labels{/name}","releases_url":"https://api.github.com/repos/restify/node-restify/releases{/id}","deployments_url":"https://api.github.com/repos/restify/node-restify/deployments","created_at":"2011-04-25T21:19:26Z","updated_at":"2018-06-25T06:09:09Z","pushed_at":"2018-06-19T23:03:39Z","git_url":"git://github.com/restify/node-restify.git","ssh_url":"git@github.com:restify/node-restify.git","clone_url":"https://github.com/restify/node-restify.git","svn_url":"https://github.com/restify/node-restify","homepage":"http://restify.com","size":4010,"stargazers_count":8373,"watchers_count":8373,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":889,"mirror_url":null,"archived":false,"open_issues_count":40,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":889,"open_issues":40,"watchers":8373,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/restify/node-restify/pulls/1681"},"html":{"href":"https://github.com/restify/node-restify/pull/1681"},"issue":{"href":"https://api.github.com/repos/restify/node-restify/issues/1681"},"comments":{"href":"https://api.github.com/repos/restify/node-restify/issues/1681/comments"},"review_comments":{"href":"https://api.github.com/repos/restify/node-restify/pulls/1681/comments"},"review_comment":{"href":"https://api.github.com/repos/restify/node-restify/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/restify/node-restify/pulls/1681/commits"},"statuses":{"href":"https://api.github.com/repos/restify/node-restify/statuses/fbd7ec3ce068fe91131787c9514a3a507fc71436"}},"author_association":"NONE"}}
{"actor":{"display_login":"DonutEspresso"}}