@lark-apaas/nestjs-logger 1.0.9-alpha.2 → 1.0.9-alpha.4

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
@@ -9493,6 +9493,16 @@ var import_config2 = require("@nestjs/config");
9493
9493
  var import_operators = __toESM(require_operators(), 1);
9494
9494
  var import_util = require("util");
9495
9495
  var import_nestjs_common2 = require("@lark-apaas/nestjs-common");
9496
+
9497
+ // src/utils/formatDuration.ts
9498
+ var formatDuration = /* @__PURE__ */ __name((ms) => {
9499
+ if (ms < 0.01) {
9500
+ return Number(ms.toPrecision(1));
9501
+ }
9502
+ return Number(ms.toFixed(2));
9503
+ }, "formatDuration");
9504
+
9505
+ // src/interceptor/logging.interceptor.ts
9496
9506
  function _ts_decorate2(decorators, target, key, desc) {
9497
9507
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9498
9508
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -9588,7 +9598,7 @@ url=${req.url}`, "HTTPTraceInterceptor");
9588
9598
  const responseMeta = {
9589
9599
  ...baseMeta,
9590
9600
  status_code: statusCode,
9591
- duration_ms: durationMs
9601
+ duration_ms: formatDuration(durationMs)
9592
9602
  };
9593
9603
  const finalResponseBody = res.__finalResponseBody;
9594
9604
  const contentType = res.getHeader("content-type");
@@ -9638,7 +9648,7 @@ duration_ms=${durationMs}`, "HTTPTraceInterceptor");
9638
9648
  method,
9639
9649
  path,
9640
9650
  url: fullUrl,
9641
- duration_ms: durationMs,
9651
+ duration_ms: formatDuration(durationMs),
9642
9652
  error_message: isError ? data?.message ?? "" : ""
9643
9653
  };
9644
9654
  if (req.body) responseData.request_body = req.body;