Skip to content

Commit

Permalink
Legacy logging: fix remoteAddress being duplicated in userAgent field (
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet authored Sep 7, 2020
1 parent 2521bd0 commit f5b4aac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/legacy/server/logging/log_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class TransformObjStream extends Stream.Transform {
method: event.method || '',
headers: event.headers,
remoteAddress: source.remoteAddress,
userAgent: source.remoteAddress,
userAgent: source.userAgent,
referer: source.referer,
};

Expand Down
4 changes: 3 additions & 1 deletion src/legacy/server/logging/log_format_json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ describe('KbnLoggerJsonFormat', () => {
},
};
const result = await createPromiseFromStreams([createListStream([event]), format]);
const { type, method, statusCode, message } = JSON.parse(result);
const { type, method, statusCode, message, req } = JSON.parse(result);

expect(type).toBe('response');
expect(method).toBe('GET');
expect(statusCode).toBe(200);
expect(message).toBe('GET /path/to/resource 200 12000ms - 13.0B');
expect(req.remoteAddress).toBe('127.0.0.1');
expect(req.userAgent).toBe('Test Thing');
});

it('ops', async () => {
Expand Down

0 comments on commit f5b4aac

Please sign in to comment.