@lark-apaas/nestjs-logger 1.0.2-alpha.32 → 1.0.2-alpha.34

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 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);
@@ -9245,6 +9286,9 @@ var BasePinoLogger = class _BasePinoLogger {
9245
9286
  const pinoLevel = mapLogLevelToPino(level);
9246
9287
  const sanitizedPayload = sanitizeValue(payload);
9247
9288
  if (process.env.NODE_ENV === "development") {
9289
+ if (sanitizedPayload.source_type === "platform") {
9290
+ return;
9291
+ }
9248
9292
  if (messageText) {
9249
9293
  this.logger[pinoLevel](sanitizedPayload, messageText);
9250
9294
  } else {
@@ -9253,7 +9297,7 @@ var BasePinoLogger = class _BasePinoLogger {
9253
9297
  } else {
9254
9298
  let finalMessage = messageText;
9255
9299
  if (typeof message === "object" && message !== null) {
9256
- finalMessage = JSON.stringify(message);
9300
+ finalMessage = safeStringify(message);
9257
9301
  }
9258
9302
  this.observableService.log(level, finalMessage ?? "", payload);
9259
9303
  }
@@ -9489,6 +9533,10 @@ var LoggingInterceptor = class {
9489
9533
  res.__finalResponseBody = body;
9490
9534
  return originalSend(body);
9491
9535
  };
9536
+ if (process.env.NODE_ENV === "development") {
9537
+ this.appLogger.log(`HTTP request started
9538
+ url=${req.url}`, "HTTPTraceInterceptor");
9539
+ }
9492
9540
  const requestMeta = {
9493
9541
  ...baseMeta
9494
9542
  };
@@ -9526,14 +9574,16 @@ var LoggingInterceptor = class {
9526
9574
  path,
9527
9575
  url: fullUrl,
9528
9576
  duration_ms: durationMs,
9529
- request_body: requestMeta["request_body"] ?? {},
9577
+ request_body: req.body ?? {},
9530
9578
  response: responseMeta["response_body"] ?? {},
9531
9579
  error_message: isError ? finalResponseBody?.message ?? "" : ""
9532
9580
  };
9533
9581
  const reportData = JSON.stringify(responseData);
9534
- appLog(reportData, {
9535
- source_type: "platform"
9536
- }, "HTTPTraceInterceptor");
9582
+ if (process.env.NODE_ENV === "runtime") {
9583
+ appLog(reportData, {
9584
+ source_type: "platform"
9585
+ }, "HTTPTraceInterceptor");
9586
+ }
9537
9587
  this.traceLogger.logStructured(traceLevel, isError ? "HTTP request failed" : "HTTP request completed", responseMeta, "HTTPTraceInterceptor");
9538
9588
  });
9539
9589
  return next.handle().pipe((0, import_operators.catchError)((error) => {