azify-logger 1.0.23 → 1.0.24
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/middleware-express.js +2 -11
- package/middleware-restify.js +2 -14
- package/package.json +1 -1
package/middleware-express.js
CHANGED
|
@@ -382,17 +382,8 @@ function createExpressLoggingMiddleware(options = {}) {
|
|
|
382
382
|
|
|
383
383
|
const statusCode = res._actualStatusCode || res._statusCode || res.statusCode || 200
|
|
384
384
|
|
|
385
|
-
let parsedResponseBody = serializedResponseBody
|
|
386
|
-
try {
|
|
387
|
-
if (typeof serializedResponseBody === 'string' && serializedResponseBody.trim().startsWith('{')) {
|
|
388
|
-
parsedResponseBody = JSON.parse(serializedResponseBody)
|
|
389
|
-
} else if (typeof serializedResponseBody === 'string' && serializedResponseBody.trim().startsWith('[')) {
|
|
390
|
-
parsedResponseBody = JSON.parse(serializedResponseBody)
|
|
391
|
-
}
|
|
392
|
-
} catch (_) {}
|
|
393
|
-
|
|
394
385
|
const responseMessage = serializedResponseBody && serializedResponseBody.length > 0
|
|
395
|
-
? `[RESPONSE] ${
|
|
386
|
+
? `[RESPONSE] ${serializedResponseBody}`
|
|
396
387
|
: `[RESPONSE] ${req.method} ${req.url} ${statusCode} ${duration}ms`
|
|
397
388
|
|
|
398
389
|
const responseData = {
|
|
@@ -401,7 +392,7 @@ function createExpressLoggingMiddleware(options = {}) {
|
|
|
401
392
|
statusCode: statusCode,
|
|
402
393
|
responseTime: duration,
|
|
403
394
|
responseHeaders: res.getHeaders ? res.getHeaders() : {},
|
|
404
|
-
responseBody:
|
|
395
|
+
responseBody: serializedResponseBody
|
|
405
396
|
}
|
|
406
397
|
|
|
407
398
|
try { res._azifyResponseLogged = true } catch (_) {}
|
package/middleware-restify.js
CHANGED
|
@@ -282,20 +282,8 @@ function createRestifyLoggingMiddleware(options = {}) {
|
|
|
282
282
|
|
|
283
283
|
const statusCode = res._actualStatusCode || res._statusCode || res.statusCode || 200
|
|
284
284
|
|
|
285
|
-
// Try to parse serializedResponseBody back to object for cleaner display in Grafana
|
|
286
|
-
let parsedResponseBody = serializedResponseBody
|
|
287
|
-
try {
|
|
288
|
-
if (typeof serializedResponseBody === 'string' && serializedResponseBody.trim().startsWith('{')) {
|
|
289
|
-
parsedResponseBody = JSON.parse(serializedResponseBody)
|
|
290
|
-
} else if (typeof serializedResponseBody === 'string' && serializedResponseBody.trim().startsWith('[')) {
|
|
291
|
-
parsedResponseBody = JSON.parse(serializedResponseBody)
|
|
292
|
-
}
|
|
293
|
-
} catch (_) {
|
|
294
|
-
// Keep as string if parsing fails
|
|
295
|
-
}
|
|
296
|
-
|
|
297
285
|
const responseMessage = serializedResponseBody && serializedResponseBody.length > 0
|
|
298
|
-
? `[RESPONSE] ${
|
|
286
|
+
? `[RESPONSE] ${serializedResponseBody}`
|
|
299
287
|
: `[RESPONSE] ${req.method} ${req.url} ${statusCode} ${duration}ms`
|
|
300
288
|
|
|
301
289
|
const responseData = {
|
|
@@ -304,7 +292,7 @@ function createRestifyLoggingMiddleware(options = {}) {
|
|
|
304
292
|
statusCode: statusCode,
|
|
305
293
|
responseTime: duration,
|
|
306
294
|
responseHeaders: res.getHeaders ? res.getHeaders() : {},
|
|
307
|
-
responseBody:
|
|
295
|
+
responseBody: serializedResponseBody
|
|
308
296
|
}
|
|
309
297
|
|
|
310
298
|
try { res._azifyResponseLogged = true } catch (_) {}
|