@lark-apaas/nestjs-logger 1.0.9-alpha.3 → 1.0.9-alpha.5
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 +21 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -9269,9 +9269,11 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9269
9269
|
}
|
|
9270
9270
|
const pinoLevel = mapLogLevelToPino(level);
|
|
9271
9271
|
const sanitizedPayload = sanitizeValue(payload);
|
|
9272
|
-
const
|
|
9272
|
+
const isTriggerLog = firstParam?.module === "trigger";
|
|
9273
|
+
const platformModule = isTriggerLog ? "trigger" : firstParam?.paas_attributes_module;
|
|
9274
|
+
const parentSpan = firstParam?.paas_parent_span_context;
|
|
9273
9275
|
if (process.env.NODE_ENV === "development") {
|
|
9274
|
-
if (platformModule &&
|
|
9276
|
+
if (platformModule && !isTriggerLog) {
|
|
9275
9277
|
return;
|
|
9276
9278
|
}
|
|
9277
9279
|
if (messageText) {
|
|
@@ -9288,13 +9290,13 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9288
9290
|
this.observableService.log(level, finalMessage ?? "", {
|
|
9289
9291
|
...payload,
|
|
9290
9292
|
module: platformModule
|
|
9291
|
-
});
|
|
9293
|
+
}, parentSpan);
|
|
9292
9294
|
} else {
|
|
9293
9295
|
const reportMessage = this.processLogParams([
|
|
9294
9296
|
message,
|
|
9295
9297
|
...optionalParams
|
|
9296
9298
|
]);
|
|
9297
|
-
this.observableService.log(level, reportMessage, {});
|
|
9299
|
+
this.observableService.log(level, reportMessage, {}, parentSpan);
|
|
9298
9300
|
}
|
|
9299
9301
|
}
|
|
9300
9302
|
}
|
|
@@ -9474,6 +9476,16 @@ import { Inject as Inject2, Injectable as Injectable2 } from "@nestjs/common";
|
|
|
9474
9476
|
import { ConfigType } from "@nestjs/config";
|
|
9475
9477
|
import { format } from "util";
|
|
9476
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
|
|
9477
9489
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
9478
9490
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9479
9491
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9523,7 +9535,7 @@ var LoggingInterceptor = class {
|
|
|
9523
9535
|
method,
|
|
9524
9536
|
path
|
|
9525
9537
|
});
|
|
9526
|
-
const startedAt =
|
|
9538
|
+
const startedAt = process.hrtime();
|
|
9527
9539
|
const baseMeta = {
|
|
9528
9540
|
method,
|
|
9529
9541
|
path,
|
|
@@ -9564,12 +9576,12 @@ url=${req.url}`, "HTTPTraceInterceptor");
|
|
|
9564
9576
|
return;
|
|
9565
9577
|
}
|
|
9566
9578
|
logged = true;
|
|
9567
|
-
const durationMs =
|
|
9579
|
+
const durationMs = process.hrtime(startedAt)[1] / 1e6;
|
|
9568
9580
|
const statusCode = res.statusCode;
|
|
9569
9581
|
const responseMeta = {
|
|
9570
9582
|
...baseMeta,
|
|
9571
9583
|
status_code: statusCode,
|
|
9572
|
-
duration_ms: durationMs
|
|
9584
|
+
duration_ms: formatDuration(durationMs)
|
|
9573
9585
|
};
|
|
9574
9586
|
const finalResponseBody = res.__finalResponseBody;
|
|
9575
9587
|
const contentType = res.getHeader("content-type");
|
|
@@ -9613,13 +9625,13 @@ duration_ms=${durationMs}`, "HTTPTraceInterceptor");
|
|
|
9613
9625
|
return next.handle().pipe((0, import_operators.tap)({
|
|
9614
9626
|
next: /* @__PURE__ */ __name((data) => {
|
|
9615
9627
|
const statusCode = res.statusCode;
|
|
9616
|
-
const durationMs =
|
|
9628
|
+
const durationMs = process.hrtime(startedAt)[1] / 1e6;
|
|
9617
9629
|
const isError = statusCode > 400;
|
|
9618
9630
|
const responseData = {
|
|
9619
9631
|
method,
|
|
9620
9632
|
path,
|
|
9621
9633
|
url: fullUrl,
|
|
9622
|
-
duration_ms: durationMs,
|
|
9634
|
+
duration_ms: formatDuration(durationMs),
|
|
9623
9635
|
error_message: isError ? data?.message ?? "" : ""
|
|
9624
9636
|
};
|
|
9625
9637
|
if (req.body) responseData.request_body = req.body;
|