@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 +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9476,6 +9476,16 @@ import { Inject as Inject2, Injectable as Injectable2 } from "@nestjs/common";
|
|
|
9476
9476
|
import { ConfigType } from "@nestjs/config";
|
|
9477
9477
|
import { format } from "util";
|
|
9478
9478
|
import { RequestContextService as RequestContextService2 } from "@lark-apaas/nestjs-common";
|
|
9479
|
+
|
|
9480
|
+
// src/utils/formatDuration.ts
|
|
9481
|
+
var formatDuration = /* @__PURE__ */ __name((ms) => {
|
|
9482
|
+
if (ms < 0.01) {
|
|
9483
|
+
return Number(ms.toPrecision(1));
|
|
9484
|
+
}
|
|
9485
|
+
return Number(ms.toFixed(2));
|
|
9486
|
+
}, "formatDuration");
|
|
9487
|
+
|
|
9488
|
+
// src/interceptor/logging.interceptor.ts
|
|
9479
9489
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
9480
9490
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9481
9491
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9571,7 +9581,7 @@ url=${req.url}`, "HTTPTraceInterceptor");
|
|
|
9571
9581
|
const responseMeta = {
|
|
9572
9582
|
...baseMeta,
|
|
9573
9583
|
status_code: statusCode,
|
|
9574
|
-
duration_ms: durationMs
|
|
9584
|
+
duration_ms: formatDuration(durationMs)
|
|
9575
9585
|
};
|
|
9576
9586
|
const finalResponseBody = res.__finalResponseBody;
|
|
9577
9587
|
const contentType = res.getHeader("content-type");
|
|
@@ -9621,7 +9631,7 @@ duration_ms=${durationMs}`, "HTTPTraceInterceptor");
|
|
|
9621
9631
|
method,
|
|
9622
9632
|
path,
|
|
9623
9633
|
url: fullUrl,
|
|
9624
|
-
duration_ms: durationMs,
|
|
9634
|
+
duration_ms: formatDuration(durationMs),
|
|
9625
9635
|
error_message: isError ? data?.message ?? "" : ""
|
|
9626
9636
|
};
|
|
9627
9637
|
if (req.body) responseData.request_body = req.body;
|