@lark-apaas/nestjs-logger 0.1.0-alpha.11 → 0.1.0-alpha.12
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 +6 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14855,7 +14855,6 @@ var LoggingInterceptor = class {
|
|
|
14855
14855
|
ip: req.ip ?? null,
|
|
14856
14856
|
pid: process.pid
|
|
14857
14857
|
};
|
|
14858
|
-
this.appLogger.logStructured("log", "HTTP request started", baseMeta, "HTTPTraceInterceptor");
|
|
14859
14858
|
const requestMeta = {
|
|
14860
14859
|
...baseMeta
|
|
14861
14860
|
};
|
|
@@ -14865,15 +14864,12 @@ var LoggingInterceptor = class {
|
|
|
14865
14864
|
if (this.config.logRequestBody && Object.keys(req.query || {}).length > 0) {
|
|
14866
14865
|
requestMeta["query_params"] = this.sanitizeAndTruncate(req.query);
|
|
14867
14866
|
}
|
|
14867
|
+
this.appLogger.log("HTTP request started \n url=%s \n request_query=%o \n request_body=%o", req.url, requestMeta["query_params"], requestMeta["request_body"]);
|
|
14868
14868
|
this.traceLogger.logStructured("verbose", "HTTP request started", requestMeta, "HTTPTraceInterceptor");
|
|
14869
14869
|
return next.handle().pipe((0, import_operators.tap)((responseData) => {
|
|
14870
14870
|
const durationMs = Date.now() - startedAt;
|
|
14871
14871
|
const statusCode = res.statusCode;
|
|
14872
|
-
this.appLogger.
|
|
14873
|
-
...baseMeta,
|
|
14874
|
-
status_code: statusCode,
|
|
14875
|
-
duration_ms: durationMs
|
|
14876
|
-
}, "HTTPTraceInterceptor");
|
|
14872
|
+
const appLog = res.statusCode >= 400 ? this.appLogger.error : this.appLogger.log;
|
|
14877
14873
|
const responseMeta = {
|
|
14878
14874
|
...baseMeta,
|
|
14879
14875
|
status_code: statusCode,
|
|
@@ -14883,6 +14879,7 @@ var LoggingInterceptor = class {
|
|
|
14883
14879
|
responseMeta["response_body"] = this.sanitizeAndTruncate(responseData);
|
|
14884
14880
|
}
|
|
14885
14881
|
const traceLevel = res.statusCode >= 400 ? "error" : "verbose";
|
|
14882
|
+
appLog("HTTP request completed\n url=%s status_code=%d \n duration_ms=%d \nresponse_body=%o", req.url, statusCode, durationMs, responseMeta.response_body);
|
|
14886
14883
|
this.traceLogger.logStructured(traceLevel, "HTTP request completed", responseMeta, "HTTPTraceInterceptor");
|
|
14887
14884
|
}), (0, import_operators.catchError)((error) => {
|
|
14888
14885
|
const durationMs = Date.now() - startedAt;
|
|
@@ -14895,7 +14892,6 @@ var LoggingInterceptor = class {
|
|
|
14895
14892
|
if (error instanceof Error) {
|
|
14896
14893
|
linkMeta["error_message"] = error.message;
|
|
14897
14894
|
}
|
|
14898
|
-
this.appLogger.logStructured("log", "HTTP request failed", linkMeta, "HTTPTraceInterceptor");
|
|
14899
14895
|
const meta = {
|
|
14900
14896
|
...baseMeta,
|
|
14901
14897
|
status_code: statusCode,
|
|
@@ -14909,7 +14905,8 @@ var LoggingInterceptor = class {
|
|
|
14909
14905
|
} else {
|
|
14910
14906
|
meta["error"] = String(error);
|
|
14911
14907
|
}
|
|
14912
|
-
this.
|
|
14908
|
+
this.appLogger.error("HTTP request failed\n url=%s status_code=%d \n duration_ms=%d \nerror=%o", req.url, statusCode, durationMs, meta.error);
|
|
14909
|
+
this.traceLogger.logStructured("error", "HTTP request failed", meta, "HTTPTraceInterceptor");
|
|
14913
14910
|
throw error;
|
|
14914
14911
|
}));
|
|
14915
14912
|
}
|
|
@@ -14988,7 +14985,7 @@ function createPinoLogger(config) {
|
|
|
14988
14985
|
}
|
|
14989
14986
|
__name(createPinoLogger, "createPinoLogger");
|
|
14990
14987
|
function createFileDestination(pathname) {
|
|
14991
|
-
const target = pathname && pathname.length > 0 ? pathname : "logs/
|
|
14988
|
+
const target = pathname && pathname.length > 0 ? pathname : "logs/server.log";
|
|
14992
14989
|
const resolved = (0, import_path.isAbsolute)(target) ? target : (0, import_path.join)(process.cwd(), target);
|
|
14993
14990
|
const dir = (0, import_path.dirname)(resolved);
|
|
14994
14991
|
if (!(0, import_fs.existsSync)(dir)) {
|