@lark-apaas/nestjs-logger 1.0.2-alpha.32 → 1.0.2-alpha.33
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 +46 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9000,6 +9000,47 @@ var OBSERVABLE_LOGGER_SERVICE = /* @__PURE__ */ Symbol("OBSERVABLE_LOGGER_SERVIC
|
|
|
9000
9000
|
|
|
9001
9001
|
// src/service/app-logger.service.ts
|
|
9002
9002
|
import { RequestContextService, ObservableService } from "@lark-apaas/nestjs-common";
|
|
9003
|
+
|
|
9004
|
+
// src/utils/safeStringify.ts
|
|
9005
|
+
function safeStringify(obj) {
|
|
9006
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9007
|
+
try {
|
|
9008
|
+
return JSON.stringify(obj, (key, value) => {
|
|
9009
|
+
if (typeof value === "object" && value !== null) {
|
|
9010
|
+
if (seen.has(value)) {
|
|
9011
|
+
return "[Circular]";
|
|
9012
|
+
}
|
|
9013
|
+
seen.add(value);
|
|
9014
|
+
}
|
|
9015
|
+
if (typeof value === "bigint") {
|
|
9016
|
+
return value.toString();
|
|
9017
|
+
}
|
|
9018
|
+
if (value instanceof Date) {
|
|
9019
|
+
return value.toISOString();
|
|
9020
|
+
}
|
|
9021
|
+
if (value instanceof Map) {
|
|
9022
|
+
return Object.fromEntries(value);
|
|
9023
|
+
}
|
|
9024
|
+
if (value instanceof Set) {
|
|
9025
|
+
return Array.from(value);
|
|
9026
|
+
}
|
|
9027
|
+
if (typeof value === "undefined") {
|
|
9028
|
+
return "undefined";
|
|
9029
|
+
}
|
|
9030
|
+
if (typeof value === "symbol") {
|
|
9031
|
+
return value.toString();
|
|
9032
|
+
}
|
|
9033
|
+
return value;
|
|
9034
|
+
});
|
|
9035
|
+
} catch {
|
|
9036
|
+
return "";
|
|
9037
|
+
} finally {
|
|
9038
|
+
seen.clear();
|
|
9039
|
+
}
|
|
9040
|
+
}
|
|
9041
|
+
__name(safeStringify, "safeStringify");
|
|
9042
|
+
|
|
9043
|
+
// src/service/app-logger.service.ts
|
|
9003
9044
|
function _ts_decorate(decorators, target, key, desc) {
|
|
9004
9045
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9005
9046
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9236,7 +9277,7 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9236
9277
|
} else {
|
|
9237
9278
|
let finalMessage = messageText;
|
|
9238
9279
|
if (typeof message === "object" && message !== null) {
|
|
9239
|
-
finalMessage =
|
|
9280
|
+
finalMessage = safeStringify(message);
|
|
9240
9281
|
}
|
|
9241
9282
|
this.observableService.log(level, finalMessage ?? "", payload);
|
|
9242
9283
|
}
|
|
@@ -9472,6 +9513,10 @@ var LoggingInterceptor = class {
|
|
|
9472
9513
|
res.__finalResponseBody = body;
|
|
9473
9514
|
return originalSend(body);
|
|
9474
9515
|
};
|
|
9516
|
+
if (process.env.NODE_ENV === "development") {
|
|
9517
|
+
this.appLogger.log(`HTTP request started
|
|
9518
|
+
url=${req.url}`, "HTTPTraceInterceptor");
|
|
9519
|
+
}
|
|
9475
9520
|
const requestMeta = {
|
|
9476
9521
|
...baseMeta
|
|
9477
9522
|
};
|