@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.cjs
CHANGED
|
@@ -7247,7 +7247,7 @@ var require_tap = __commonJS({
|
|
|
7247
7247
|
var lift_1 = require_lift();
|
|
7248
7248
|
var OperatorSubscriber_1 = require_OperatorSubscriber();
|
|
7249
7249
|
var identity_1 = require_identity();
|
|
7250
|
-
function
|
|
7250
|
+
function tap2(observerOrNext, error, complete) {
|
|
7251
7251
|
var tapObserver = isFunction_1.isFunction(observerOrNext) || error || complete ? {
|
|
7252
7252
|
next: observerOrNext,
|
|
7253
7253
|
error,
|
|
@@ -7280,8 +7280,8 @@ var require_tap = __commonJS({
|
|
|
7280
7280
|
}));
|
|
7281
7281
|
}) : identity_1.identity;
|
|
7282
7282
|
}
|
|
7283
|
-
__name(
|
|
7284
|
-
exports2.tap =
|
|
7283
|
+
__name(tap2, "tap");
|
|
7284
|
+
exports2.tap = tap2;
|
|
7285
7285
|
}
|
|
7286
7286
|
});
|
|
7287
7287
|
|
|
@@ -9598,24 +9598,6 @@ url=${req.url}`, "HTTPTraceInterceptor");
|
|
|
9598
9598
|
const isError = statusCode >= 400;
|
|
9599
9599
|
const appLog = this.appLogger[isError ? "error" : "log"].bind(this.appLogger);
|
|
9600
9600
|
const traceLevel = isError ? "error" : "verbose";
|
|
9601
|
-
const responseData = {
|
|
9602
|
-
method,
|
|
9603
|
-
path,
|
|
9604
|
-
url: fullUrl,
|
|
9605
|
-
duration_ms: durationMs,
|
|
9606
|
-
request_body: req.body ?? {},
|
|
9607
|
-
error_message: isError ? finalResponseBody?.message ?? "" : ""
|
|
9608
|
-
};
|
|
9609
|
-
if (isJsonResponse) {
|
|
9610
|
-
responseData.response = JSON.parse(finalResponseBody);
|
|
9611
|
-
}
|
|
9612
|
-
const reportData = JSON.stringify(responseData);
|
|
9613
|
-
if (!isDev) {
|
|
9614
|
-
this.appLogger.log(reportData, {
|
|
9615
|
-
paas_attributes_module: "app_server",
|
|
9616
|
-
source_type: "platform"
|
|
9617
|
-
}, "HTTPTraceInterceptor");
|
|
9618
|
-
}
|
|
9619
9601
|
const shouldLogBody = this.config.logResponseBody && isJsonResponse && finalResponseBody !== void 0;
|
|
9620
9602
|
if (isError) {
|
|
9621
9603
|
if (shouldLogBody) {
|
|
@@ -9646,7 +9628,29 @@ duration_ms=${durationMs}`, "HTTPTraceInterceptor");
|
|
|
9646
9628
|
}
|
|
9647
9629
|
this.traceLogger.logStructured(traceLevel, isError ? "HTTP request failed" : "HTTP request completed", responseMeta, "HTTPTraceInterceptor");
|
|
9648
9630
|
});
|
|
9649
|
-
return next.handle().pipe((0, import_operators.
|
|
9631
|
+
return next.handle().pipe((0, import_operators.tap)({
|
|
9632
|
+
next: /* @__PURE__ */ __name((data) => {
|
|
9633
|
+
const statusCode = res.statusCode;
|
|
9634
|
+
const durationMs = Date.now() - startedAt;
|
|
9635
|
+
const isError = statusCode > 400;
|
|
9636
|
+
const responseData = {
|
|
9637
|
+
method,
|
|
9638
|
+
path,
|
|
9639
|
+
url: fullUrl,
|
|
9640
|
+
duration_ms: durationMs,
|
|
9641
|
+
error_message: isError ? data?.message ?? "" : ""
|
|
9642
|
+
};
|
|
9643
|
+
if (req.body) responseData.request_body = req.body;
|
|
9644
|
+
if (data) responseData.response = data;
|
|
9645
|
+
const reportData = JSON.stringify(responseData);
|
|
9646
|
+
if (!isDev) {
|
|
9647
|
+
this.appLogger.log(reportData, {
|
|
9648
|
+
paas_attributes_module: "app_server",
|
|
9649
|
+
source_type: "platform"
|
|
9650
|
+
}, "HTTPTraceInterceptor");
|
|
9651
|
+
}
|
|
9652
|
+
}, "next")
|
|
9653
|
+
}), (0, import_operators.catchError)((error) => {
|
|
9650
9654
|
this.appLogger.error((0, import_util.format)("HTTP request exception\nmethod=%s url=%s\nerror=%o", req.method, req.url, error), {
|
|
9651
9655
|
paas_attributes_module: "app_server",
|
|
9652
9656
|
source_type: "platform"
|