@lark-apaas/nestjs-logger 1.0.2-alpha.39 → 1.0.2-alpha.40
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/dist/index.cjs +26 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7241,7 +7241,7 @@ var require_tap = __commonJS({
|
|
|
7241
7241
|
var lift_1 = require_lift();
|
|
7242
7242
|
var OperatorSubscriber_1 = require_OperatorSubscriber();
|
|
7243
7243
|
var identity_1 = require_identity();
|
|
7244
|
-
function
|
|
7244
|
+
function tap2(observerOrNext, error, complete) {
|
|
7245
7245
|
var tapObserver = isFunction_1.isFunction(observerOrNext) || error || complete ? {
|
|
7246
7246
|
next: observerOrNext,
|
|
7247
7247
|
error,
|
|
@@ -7274,8 +7274,8 @@ var require_tap = __commonJS({
|
|
|
7274
7274
|
}));
|
|
7275
7275
|
}) : identity_1.identity;
|
|
7276
7276
|
}
|
|
7277
|
-
__name(
|
|
7278
|
-
exports.tap =
|
|
7277
|
+
__name(tap2, "tap");
|
|
7278
|
+
exports.tap = tap2;
|
|
7279
7279
|
}
|
|
7280
7280
|
});
|
|
7281
7281
|
|
|
@@ -9581,24 +9581,6 @@ url=${req.url}`, "HTTPTraceInterceptor");
|
|
|
9581
9581
|
const isError = statusCode >= 400;
|
|
9582
9582
|
const appLog = this.appLogger[isError ? "error" : "log"].bind(this.appLogger);
|
|
9583
9583
|
const traceLevel = isError ? "error" : "verbose";
|
|
9584
|
-
const responseData = {
|
|
9585
|
-
method,
|
|
9586
|
-
path,
|
|
9587
|
-
url: fullUrl,
|
|
9588
|
-
duration_ms: durationMs,
|
|
9589
|
-
request_body: req.body ?? {},
|
|
9590
|
-
error_message: isError ? finalResponseBody?.message ?? "" : ""
|
|
9591
|
-
};
|
|
9592
|
-
if (isJsonResponse) {
|
|
9593
|
-
responseData.response = JSON.parse(finalResponseBody);
|
|
9594
|
-
}
|
|
9595
|
-
const reportData = JSON.stringify(responseData);
|
|
9596
|
-
if (!isDev) {
|
|
9597
|
-
this.appLogger.log(reportData, {
|
|
9598
|
-
paas_attributes_module: "app_server",
|
|
9599
|
-
source_type: "platform"
|
|
9600
|
-
}, "HTTPTraceInterceptor");
|
|
9601
|
-
}
|
|
9602
9584
|
const shouldLogBody = this.config.logResponseBody && isJsonResponse && finalResponseBody !== void 0;
|
|
9603
9585
|
if (isError) {
|
|
9604
9586
|
if (shouldLogBody) {
|
|
@@ -9629,7 +9611,29 @@ duration_ms=${durationMs}`, "HTTPTraceInterceptor");
|
|
|
9629
9611
|
}
|
|
9630
9612
|
this.traceLogger.logStructured(traceLevel, isError ? "HTTP request failed" : "HTTP request completed", responseMeta, "HTTPTraceInterceptor");
|
|
9631
9613
|
});
|
|
9632
|
-
return next.handle().pipe((0, import_operators.
|
|
9614
|
+
return next.handle().pipe((0, import_operators.tap)({
|
|
9615
|
+
next: /* @__PURE__ */ __name((data) => {
|
|
9616
|
+
const statusCode = res.statusCode;
|
|
9617
|
+
const durationMs = Date.now() - startedAt;
|
|
9618
|
+
const isError = statusCode > 400;
|
|
9619
|
+
const responseData = {
|
|
9620
|
+
method,
|
|
9621
|
+
path,
|
|
9622
|
+
url: fullUrl,
|
|
9623
|
+
duration_ms: durationMs,
|
|
9624
|
+
error_message: isError ? data?.message ?? "" : ""
|
|
9625
|
+
};
|
|
9626
|
+
if (req.body) responseData.request_body = req.body;
|
|
9627
|
+
if (data) responseData.response = data;
|
|
9628
|
+
const reportData = JSON.stringify(responseData);
|
|
9629
|
+
if (!isDev) {
|
|
9630
|
+
this.appLogger.log(reportData, {
|
|
9631
|
+
paas_attributes_module: "app_server",
|
|
9632
|
+
source_type: "platform"
|
|
9633
|
+
}, "HTTPTraceInterceptor");
|
|
9634
|
+
}
|
|
9635
|
+
}, "next")
|
|
9636
|
+
}), (0, import_operators.catchError)((error) => {
|
|
9633
9637
|
this.appLogger.error(format("HTTP request exception\nmethod=%s url=%s\nerror=%o", req.method, req.url, error), {
|
|
9634
9638
|
paas_attributes_module: "app_server",
|
|
9635
9639
|
source_type: "platform"
|