@lark-apaas/nestjs-logger 1.0.9-alpha.3 → 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 +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.cjs
CHANGED
|
@@ -9286,9 +9286,11 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9286
9286
|
}
|
|
9287
9287
|
const pinoLevel = mapLogLevelToPino(level);
|
|
9288
9288
|
const sanitizedPayload = sanitizeValue(payload);
|
|
9289
|
-
const
|
|
9289
|
+
const isTriggerLog = firstParam?.module === "trigger";
|
|
9290
|
+
const platformModule = isTriggerLog ? "trigger" : firstParam?.paas_attributes_module;
|
|
9291
|
+
const parentSpan = firstParam?.paas_parent_span_context;
|
|
9290
9292
|
if (process.env.NODE_ENV === "development") {
|
|
9291
|
-
if (platformModule &&
|
|
9293
|
+
if (platformModule && !isTriggerLog) {
|
|
9292
9294
|
return;
|
|
9293
9295
|
}
|
|
9294
9296
|
if (messageText) {
|
|
@@ -9305,13 +9307,13 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9305
9307
|
this.observableService.log(level, finalMessage ?? "", {
|
|
9306
9308
|
...payload,
|
|
9307
9309
|
module: platformModule
|
|
9308
|
-
});
|
|
9310
|
+
}, parentSpan);
|
|
9309
9311
|
} else {
|
|
9310
9312
|
const reportMessage = this.processLogParams([
|
|
9311
9313
|
message,
|
|
9312
9314
|
...optionalParams
|
|
9313
9315
|
]);
|
|
9314
|
-
this.observableService.log(level, reportMessage, {});
|
|
9316
|
+
this.observableService.log(level, reportMessage, {}, parentSpan);
|
|
9315
9317
|
}
|
|
9316
9318
|
}
|
|
9317
9319
|
}
|
|
@@ -9491,6 +9493,16 @@ var import_config2 = require("@nestjs/config");
|
|
|
9491
9493
|
var import_operators = __toESM(require_operators(), 1);
|
|
9492
9494
|
var import_util = require("util");
|
|
9493
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
|
|
9494
9506
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
9495
9507
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9496
9508
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9540,7 +9552,7 @@ var LoggingInterceptor = class {
|
|
|
9540
9552
|
method,
|
|
9541
9553
|
path
|
|
9542
9554
|
});
|
|
9543
|
-
const startedAt =
|
|
9555
|
+
const startedAt = process.hrtime();
|
|
9544
9556
|
const baseMeta = {
|
|
9545
9557
|
method,
|
|
9546
9558
|
path,
|
|
@@ -9581,12 +9593,12 @@ url=${req.url}`, "HTTPTraceInterceptor");
|
|
|
9581
9593
|
return;
|
|
9582
9594
|
}
|
|
9583
9595
|
logged = true;
|
|
9584
|
-
const durationMs =
|
|
9596
|
+
const durationMs = process.hrtime(startedAt)[1] / 1e6;
|
|
9585
9597
|
const statusCode = res.statusCode;
|
|
9586
9598
|
const responseMeta = {
|
|
9587
9599
|
...baseMeta,
|
|
9588
9600
|
status_code: statusCode,
|
|
9589
|
-
duration_ms: durationMs
|
|
9601
|
+
duration_ms: formatDuration(durationMs)
|
|
9590
9602
|
};
|
|
9591
9603
|
const finalResponseBody = res.__finalResponseBody;
|
|
9592
9604
|
const contentType = res.getHeader("content-type");
|
|
@@ -9630,13 +9642,13 @@ duration_ms=${durationMs}`, "HTTPTraceInterceptor");
|
|
|
9630
9642
|
return next.handle().pipe((0, import_operators.tap)({
|
|
9631
9643
|
next: /* @__PURE__ */ __name((data) => {
|
|
9632
9644
|
const statusCode = res.statusCode;
|
|
9633
|
-
const durationMs =
|
|
9645
|
+
const durationMs = process.hrtime(startedAt)[1] / 1e6;
|
|
9634
9646
|
const isError = statusCode > 400;
|
|
9635
9647
|
const responseData = {
|
|
9636
9648
|
method,
|
|
9637
9649
|
path,
|
|
9638
9650
|
url: fullUrl,
|
|
9639
|
-
duration_ms: durationMs,
|
|
9651
|
+
duration_ms: formatDuration(durationMs),
|
|
9640
9652
|
error_message: isError ? data?.message ?? "" : ""
|
|
9641
9653
|
};
|
|
9642
9654
|
if (req.body) responseData.request_body = req.body;
|