@lark-apaas/nestjs-logger 1.0.2-alpha.26 → 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.cjs
CHANGED
|
@@ -14863,7 +14863,9 @@ var LoggingInterceptor = class {
|
|
|
14863
14863
|
requestMeta["query_params"] = this.sanitizeAndTruncate(req.query);
|
|
14864
14864
|
}
|
|
14865
14865
|
this.appLogger.log(`HTTP request started
|
|
14866
|
-
url=${req.url}`,
|
|
14866
|
+
url=${req.url}`, {
|
|
14867
|
+
source_type: "platform"
|
|
14868
|
+
}, "HTTPTraceInterceptor");
|
|
14867
14869
|
this.traceLogger.logStructured("verbose", "HTTP request started", requestMeta, "HTTPTraceInterceptor");
|
|
14868
14870
|
let logged = false;
|
|
14869
14871
|
res.on("finish", () => {
|
|
@@ -14887,38 +14889,25 @@ url=${req.url}`, "HTTPTraceInterceptor");
|
|
|
14887
14889
|
const isError = statusCode >= 400;
|
|
14888
14890
|
const appLog = this.appLogger[isError ? "error" : "log"].bind(this.appLogger);
|
|
14889
14891
|
const traceLevel = isError ? "error" : "verbose";
|
|
14890
|
-
const
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
}
|
|
14904
|
-
} else {
|
|
14905
|
-
if (shouldLogBody) {
|
|
14906
|
-
appLog(`HTTP request completed
|
|
14907
|
-
url=${req.url}
|
|
14908
|
-
status_code=${statusCode}
|
|
14909
|
-
duration_ms=${durationMs}
|
|
14910
|
-
response_body=${JSON.stringify(finalResponseBody ?? {})}`, "HTTPTraceInterceptor");
|
|
14911
|
-
} else {
|
|
14912
|
-
appLog(`HTTP request completed
|
|
14913
|
-
url=${req.url}
|
|
14914
|
-
status_code=${statusCode}
|
|
14915
|
-
duration_ms=${durationMs}`, "HTTPTraceInterceptor");
|
|
14916
|
-
}
|
|
14917
|
-
}
|
|
14892
|
+
const responseData = {
|
|
14893
|
+
method,
|
|
14894
|
+
path,
|
|
14895
|
+
url: req.url,
|
|
14896
|
+
duration_ms: durationMs,
|
|
14897
|
+
request_body: requestMeta["request_body"],
|
|
14898
|
+
response: responseMeta["response_body"],
|
|
14899
|
+
error_message: isError ? finalResponseBody?.message ?? null : null
|
|
14900
|
+
};
|
|
14901
|
+
const reportData = JSON.stringify(responseData);
|
|
14902
|
+
appLog(reportData, {
|
|
14903
|
+
source_type: "platform"
|
|
14904
|
+
}, "HTTPTraceInterceptor");
|
|
14918
14905
|
this.traceLogger.logStructured(traceLevel, isError ? "HTTP request failed" : "HTTP request completed", responseMeta, "HTTPTraceInterceptor");
|
|
14919
14906
|
});
|
|
14920
14907
|
return next.handle().pipe((0, import_operators.catchError)((error) => {
|
|
14921
|
-
this.appLogger.error((0, import_util.format)("HTTP request exception\nmethod=%s url=%s\nerror=%o", req.method, req.url, error),
|
|
14908
|
+
this.appLogger.error((0, import_util.format)("HTTP request exception\nmethod=%s url=%s\nerror=%o", req.method, req.url, error), {
|
|
14909
|
+
source_type: "platform"
|
|
14910
|
+
}, "HTTPTraceInterceptor");
|
|
14922
14911
|
throw error;
|
|
14923
14912
|
}));
|
|
14924
14913
|
}
|