fix(logs): rename `code` to `status` on request.summary log lines

Stackdriver doesn't like it when properties change their type across
log lines, and there is a clash between the type of the `code` property
for the `account.signin.confirm.success` and `request.summary` log
lines.

This change renames it to `status` on `request.summary`, because that
seems like a more appropriate name and the other log message appears to
have greater legitimacy to its claim to use the `code` property name
(that is literally the name of the corresponding property in the request
payload).
This commit is contained in:
Phil Booth 2019-01-24 21:43:28 +00:00
Родитель 2097c951d6
Коммит 42c4c372f4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 36FBB106F9C32516
2 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -86,7 +86,7 @@ Lug.prototype.summary = function (request, response) {
var query = request.query || {}
var line = {
op: 'request.summary',
code: (response.isBoom) ? response.output.statusCode : response.statusCode,
status: (response.isBoom) ? response.output.statusCode : response.statusCode,
errno: response.errno || 0,
rid: request.id,
path: request.path,
@ -106,7 +106,7 @@ Lug.prototype.summary = function (request, response) {
line.keys = query.keys
line.email = payload.email || query.email
if (line.code >= 500) {
if (line.status >= 500) {
line.trace = request.app.traced
line.stack = response.stack
this.error(line, response.message)

Просмотреть файл

@ -471,14 +471,17 @@ describe('log', () => {
path: '/v1/frobnicate',
payload: {}
}, {
code: 200
code: 200,
statusCode: 201
})
assert.equal(logger.info.callCount, 1)
assert.equal(logger.info.args[0][1].op, 'request.summary')
assert.equal(logger.info.args[0][1].status, 201)
assert.equal(logger.info.args[0][1].code, undefined)
assert.equal(emitRouteFlowEvent.callCount, 1)
assert.equal(emitRouteFlowEvent.args[0].length, 1)
assert.deepEqual(emitRouteFlowEvent.args[0][0], { code: 200 })
assert.deepEqual(emitRouteFlowEvent.args[0][0], { code: 200, statusCode: 201 })
assert.equal(logger.error.callCount, 0)
})