@lark-apaas/nestjs-logger 1.0.2-alpha.27 → 1.0.2-alpha.28
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 +19 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14852,7 +14852,9 @@ var LoggingInterceptor = class {
|
|
|
14852
14852
|
requestMeta["query_params"] = this.sanitizeAndTruncate(req.query);
|
|
14853
14853
|
}
|
|
14854
14854
|
this.appLogger.log(`HTTP request started
|
|
14855
|
-
url=${req.url}`,
|
|
14855
|
+
url=${req.url}`, {
|
|
14856
|
+
source_type: "platform"
|
|
14857
|
+
}, "HTTPTraceInterceptor");
|
|
14856
14858
|
this.traceLogger.logStructured("verbose", "HTTP request started", requestMeta, "HTTPTraceInterceptor");
|
|
14857
14859
|
let logged = false;
|
|
14858
14860
|
res.on("finish", () => {
|
|
@@ -14876,38 +14878,25 @@ url=${req.url}`, "HTTPTraceInterceptor");
|
|
|
14876
14878
|
const isError = statusCode >= 400;
|
|
14877
14879
|
const appLog = this.appLogger[isError ? "error" : "log"].bind(this.appLogger);
|
|
14878
14880
|
const traceLevel = isError ? "error" : "verbose";
|
|
14879
|
-
const
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
}
|
|
14893
|
-
} else {
|
|
14894
|
-
if (shouldLogBody) {
|
|
14895
|
-
appLog(`HTTP request completed
|
|
14896
|
-
url=${req.url}
|
|
14897
|
-
status_code=${statusCode}
|
|
14898
|
-
duration_ms=${durationMs}
|
|
14899
|
-
response_body=${JSON.stringify(finalResponseBody ?? {})}`, "HTTPTraceInterceptor");
|
|
14900
|
-
} else {
|
|
14901
|
-
appLog(`HTTP request completed
|
|
14902
|
-
url=${req.url}
|
|
14903
|
-
status_code=${statusCode}
|
|
14904
|
-
duration_ms=${durationMs}`, "HTTPTraceInterceptor");
|
|
14905
|
-
}
|
|
14906
|
-
}
|
|
14881
|
+
const responseData = {
|
|
14882
|
+
method,
|
|
14883
|
+
path,
|
|
14884
|
+
url: req.url,
|
|
14885
|
+
duration_ms: durationMs,
|
|
14886
|
+
request_body: requestMeta["request_body"],
|
|
14887
|
+
response: responseMeta["response_body"],
|
|
14888
|
+
error_message: isError ? finalResponseBody?.message ?? null : null
|
|
14889
|
+
};
|
|
14890
|
+
const reportData = JSON.stringify(responseData);
|
|
14891
|
+
appLog(reportData, {
|
|
14892
|
+
source_type: "platform"
|
|
14893
|
+
}, "HTTPTraceInterceptor");
|
|
14907
14894
|
this.traceLogger.logStructured(traceLevel, isError ? "HTTP request failed" : "HTTP request completed", responseMeta, "HTTPTraceInterceptor");
|
|
14908
14895
|
});
|
|
14909
14896
|
return next.handle().pipe((0, import_operators.catchError)((error) => {
|
|
14910
|
-
this.appLogger.error(format("HTTP request exception\nmethod=%s url=%s\nerror=%o", req.method, req.url, error),
|
|
14897
|
+
this.appLogger.error(format("HTTP request exception\nmethod=%s url=%s\nerror=%o", req.method, req.url, error), {
|
|
14898
|
+
source_type: "platform"
|
|
14899
|
+
}, "HTTPTraceInterceptor");
|
|
14911
14900
|
throw error;
|
|
14912
14901
|
}));
|
|
14913
14902
|
}
|