@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.cjs
CHANGED
|
@@ -9017,6 +9017,47 @@ var OBSERVABLE_LOGGER_SERVICE = /* @__PURE__ */ Symbol("OBSERVABLE_LOGGER_SERVIC
|
|
|
9017
9017
|
|
|
9018
9018
|
// src/service/app-logger.service.ts
|
|
9019
9019
|
var import_nestjs_common = require("@lark-apaas/nestjs-common");
|
|
9020
|
+
|
|
9021
|
+
// src/utils/safeStringify.ts
|
|
9022
|
+
function safeStringify(obj) {
|
|
9023
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9024
|
+
try {
|
|
9025
|
+
return JSON.stringify(obj, (key, value) => {
|
|
9026
|
+
if (typeof value === "object" && value !== null) {
|
|
9027
|
+
if (seen.has(value)) {
|
|
9028
|
+
return "[Circular]";
|
|
9029
|
+
}
|
|
9030
|
+
seen.add(value);
|
|
9031
|
+
}
|
|
9032
|
+
if (typeof value === "bigint") {
|
|
9033
|
+
return value.toString();
|
|
9034
|
+
}
|
|
9035
|
+
if (value instanceof Date) {
|
|
9036
|
+
return value.toISOString();
|
|
9037
|
+
}
|
|
9038
|
+
if (value instanceof Map) {
|
|
9039
|
+
return Object.fromEntries(value);
|
|
9040
|
+
}
|
|
9041
|
+
if (value instanceof Set) {
|
|
9042
|
+
return Array.from(value);
|
|
9043
|
+
}
|
|
9044
|
+
if (typeof value === "undefined") {
|
|
9045
|
+
return "undefined";
|
|
9046
|
+
}
|
|
9047
|
+
if (typeof value === "symbol") {
|
|
9048
|
+
return value.toString();
|
|
9049
|
+
}
|
|
9050
|
+
return value;
|
|
9051
|
+
});
|
|
9052
|
+
} catch {
|
|
9053
|
+
return "";
|
|
9054
|
+
} finally {
|
|
9055
|
+
seen.clear();
|
|
9056
|
+
}
|
|
9057
|
+
}
|
|
9058
|
+
__name(safeStringify, "safeStringify");
|
|
9059
|
+
|
|
9060
|
+
// src/service/app-logger.service.ts
|
|
9020
9061
|
function _ts_decorate(decorators, target, key, desc) {
|
|
9021
9062
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9022
9063
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9253,7 +9294,7 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9253
9294
|
} else {
|
|
9254
9295
|
let finalMessage = messageText;
|
|
9255
9296
|
if (typeof message === "object" && message !== null) {
|
|
9256
|
-
finalMessage =
|
|
9297
|
+
finalMessage = safeStringify(message);
|
|
9257
9298
|
}
|
|
9258
9299
|
this.observableService.log(level, finalMessage ?? "", payload);
|
|
9259
9300
|
}
|
|
@@ -9489,6 +9530,10 @@ var LoggingInterceptor = class {
|
|
|
9489
9530
|
res.__finalResponseBody = body;
|
|
9490
9531
|
return originalSend(body);
|
|
9491
9532
|
};
|
|
9533
|
+
if (process.env.NODE_ENV === "development") {
|
|
9534
|
+
this.appLogger.log(`HTTP request started
|
|
9535
|
+
url=${req.url}`, "HTTPTraceInterceptor");
|
|
9536
|
+
}
|
|
9492
9537
|
const requestMeta = {
|
|
9493
9538
|
...baseMeta
|
|
9494
9539
|
};
|