@defra/lis-infra-ui-services 0.37.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -180,7 +180,7 @@ The main entry point (`@defra/lis-infra-ui-services`) exports `buildMicrositePat
180
180
  | 503 | `service-unavailable` |
181
181
  | anything else | `problem-with-service` |
182
182
 
183
- 5xx responses are logged at `error`, and 4xx responses other than 401, 403 and 404 at `warn`, each with the error object, request method, path and status code. Boom messages are logged, so application code must not put user-supplied text in them.
183
+ 5xx responses are logged at `error`, and 4xx responses other than 401, 403 and 404 at `warn`, each with the error object and the ECS fields `http.request.method`, `url.path` and `http.response.status_code`. Boom messages are logged, so application code must not put user-supplied text in them.
184
184
 
185
185
  ```js
186
186
  import { catchAll } from '@defra/lis-infra-ui-services/errors'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/lis-infra-ui-services",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "UI-Services shared definitions for the livestock taxonomy topology.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -64,11 +64,16 @@ function logFailure(request, statusCode) {
64
64
  return
65
65
  }
66
66
 
67
- // Keys mirror hapi-pino's shape because the CDP pipeline maps them to ECS fields and drops the rest; request.path deliberately omits the query string
67
+ // Native ECS keys: hubs register hapi-pino on the shared logger, whose
68
+ // req/res serialisers expect real HTTP objects (and null the status of a
69
+ // plain one). request.path deliberately omits the query string.
68
70
  const context = {
69
71
  err: getError(response, statusCode),
70
- req: { method: request.method, url: request.path },
71
- res: { statusCode }
72
+ http: {
73
+ request: { method: request.method },
74
+ response: { status_code: statusCode }
75
+ },
76
+ url: { path: request.path }
72
77
  }
73
78
 
74
79
  if (isServerError) {
@@ -107,8 +107,11 @@ test('catchAll logs server errors and renders the problem with the service page'
107
107
  assert.deepEqual(logger.error.mock.calls[0], [
108
108
  {
109
109
  err: request.response,
110
- req: { method: 'get', url: '/mock-path' },
111
- res: { statusCode: statusCodes.internalServerError }
110
+ http: {
111
+ request: { method: 'get' },
112
+ response: { status_code: statusCodes.internalServerError }
113
+ },
114
+ url: { path: '/mock-path' }
112
115
  },
113
116
  'Request failed'
114
117
  ])
@@ -129,8 +132,11 @@ test.each([statusCodes.badRequest, statusCodes.unprocessableEntity])(
129
132
  assert.deepEqual(logger.warn.mock.calls[0], [
130
133
  {
131
134
  err: request.response,
132
- req: { method: 'get', url: '/mock-path' },
133
- res: { statusCode }
135
+ http: {
136
+ request: { method: 'get' },
137
+ response: { status_code: statusCode }
138
+ },
139
+ url: { path: '/mock-path' }
134
140
  },
135
141
  'Request rejected'
136
142
  ])
@@ -214,8 +220,11 @@ test('catchAll logs the error behind plain 500 responses before continuing', ()
214
220
  assert.deepEqual(logger.error.mock.calls[0], [
215
221
  {
216
222
  err: sourceError,
217
- req: { method: 'post', url: '/plain' },
218
- res: { statusCode: statusCodes.internalServerError }
223
+ http: {
224
+ request: { method: 'post' },
225
+ response: { status_code: statusCodes.internalServerError }
226
+ },
227
+ url: { path: '/plain' }
219
228
  },
220
229
  'Request failed'
221
230
  ])