@nxtedition/nxt-undici 6.3.6 → 6.3.7
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/lib/interceptor/log.js +17 -12
- package/package.json +1 -1
package/lib/interceptor/log.js
CHANGED
|
@@ -89,19 +89,24 @@ class Handler extends DecoratorHandler {
|
|
|
89
89
|
onComplete() {
|
|
90
90
|
this.#timing.end = performance.now() - this.#created
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
bytesReadPerSecond: (this.#pos * 1e3) / (this.#timing.end - this.#timing.data),
|
|
100
|
-
},
|
|
101
|
-
elapsedTime: this.#timing.end,
|
|
92
|
+
const data = {
|
|
93
|
+
ures: {
|
|
94
|
+
statusCode: this.#statusCode,
|
|
95
|
+
headers: this.#headers,
|
|
96
|
+
timing: this.#timing,
|
|
97
|
+
bytesRead: this.#pos,
|
|
98
|
+
bytesReadPerSecond: (this.#pos * 1e3) / (this.#timing.end - this.#timing.data),
|
|
102
99
|
},
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
elapsedTime: this.#timing.end,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.#statusCode >= 500) {
|
|
104
|
+
this.#logger.error(data, 'upstream request completed')
|
|
105
|
+
} else if (this.#statusCode >= 400) {
|
|
106
|
+
this.#logger.warn(data, 'upstream request completed')
|
|
107
|
+
} else {
|
|
108
|
+
this.#logger.debug(data, 'upstream request completed')
|
|
109
|
+
}
|
|
105
110
|
|
|
106
111
|
super.onComplete()
|
|
107
112
|
}
|