@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.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);
@@ -9228,6 +9269,9 @@ var BasePinoLogger = class _BasePinoLogger {
9228
9269
  const pinoLevel = mapLogLevelToPino(level);
9229
9270
  const sanitizedPayload = sanitizeValue(payload);
9230
9271
  if (process.env.NODE_ENV === "development") {
9272
+ if (sanitizedPayload.source_type === "platform") {
9273
+ return;
9274
+ }
9231
9275
  if (messageText) {
9232
9276
  this.logger[pinoLevel](sanitizedPayload, messageText);
9233
9277
  } else {
@@ -9236,7 +9280,7 @@ var BasePinoLogger = class _BasePinoLogger {
9236
9280
  } else {
9237
9281
  let finalMessage = messageText;
9238
9282
  if (typeof message === "object" && message !== null) {
9239
- finalMessage = JSON.stringify(message);
9283
+ finalMessage = safeStringify(message);
9240
9284
  }
9241
9285
  this.observableService.log(level, finalMessage ?? "", payload);
9242
9286
  }
@@ -9472,6 +9516,10 @@ var LoggingInterceptor = class {
9472
9516
  res.__finalResponseBody = body;
9473
9517
  return originalSend(body);
9474
9518
  };
9519
+ if (process.env.NODE_ENV === "development") {
9520
+ this.appLogger.log(`HTTP request started
9521
+ url=${req.url}`, "HTTPTraceInterceptor");
9522
+ }
9475
9523
  const requestMeta = {
9476
9524
  ...baseMeta
9477
9525
  };
@@ -9509,14 +9557,16 @@ var LoggingInterceptor = class {
9509
9557
  path,
9510
9558
  url: fullUrl,
9511
9559
  duration_ms: durationMs,
9512
- request_body: requestMeta["request_body"] ?? {},
9560
+ request_body: req.body ?? {},
9513
9561
  response: responseMeta["response_body"] ?? {},
9514
9562
  error_message: isError ? finalResponseBody?.message ?? "" : ""
9515
9563
  };
9516
9564
  const reportData = JSON.stringify(responseData);
9517
- appLog(reportData, {
9518
- source_type: "platform"
9519
- }, "HTTPTraceInterceptor");
9565
+ if (process.env.NODE_ENV === "runtime") {
9566
+ appLog(reportData, {
9567
+ source_type: "platform"
9568
+ }, "HTTPTraceInterceptor");
9569
+ }
9520
9570
  this.traceLogger.logStructured(traceLevel, isError ? "HTTP request failed" : "HTTP request completed", responseMeta, "HTTPTraceInterceptor");
9521
9571
  });
9522
9572
  return next.handle().pipe((0, import_operators.catchError)((error) => {