@lark-apaas/nestjs-logger 1.0.2-alpha.38 → 1.0.2-alpha.39
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 +34 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -25,6 +25,7 @@ declare abstract class BasePinoLogger implements LoggerService {
|
|
|
25
25
|
*/
|
|
26
26
|
logStructured(level: LogLevel, message: string, meta: Record<string, unknown>, context?: string): void;
|
|
27
27
|
protected write(level: LogLevel, message: unknown, optionalParams: unknown[], treatStack?: boolean): void;
|
|
28
|
+
private processLogParams;
|
|
28
29
|
private extractOptionalParams;
|
|
29
30
|
private buildMessagePayload;
|
|
30
31
|
private static looksLikeStack;
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare abstract class BasePinoLogger implements LoggerService {
|
|
|
25
25
|
*/
|
|
26
26
|
logStructured(level: LogLevel, message: string, meta: Record<string, unknown>, context?: string): void;
|
|
27
27
|
protected write(level: LogLevel, message: unknown, optionalParams: unknown[], treatStack?: boolean): void;
|
|
28
|
+
private processLogParams;
|
|
28
29
|
private extractOptionalParams;
|
|
29
30
|
private buildMessagePayload;
|
|
30
31
|
private static looksLikeStack;
|
package/dist/index.js
CHANGED
|
@@ -9224,6 +9224,7 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9224
9224
|
const { context, stack, extras } = this.extractOptionalParams(optionalParams, treatStack);
|
|
9225
9225
|
const requestState = this.contextStore.getContext();
|
|
9226
9226
|
const traceId = requestState?.requestId ?? null;
|
|
9227
|
+
const firstParam = optionalParams[0];
|
|
9227
9228
|
const flatObject = /* @__PURE__ */ __name((extra) => {
|
|
9228
9229
|
let res = {};
|
|
9229
9230
|
try {
|
|
@@ -9268,8 +9269,10 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9268
9269
|
}
|
|
9269
9270
|
const pinoLevel = mapLogLevelToPino(level);
|
|
9270
9271
|
const sanitizedPayload = sanitizeValue(payload);
|
|
9272
|
+
const isTriggerLog = firstParam?.module === "trigger";
|
|
9273
|
+
const platformModule = isTriggerLog ? "trigger" : firstParam?.paas_attributes_module;
|
|
9271
9274
|
if (process.env.NODE_ENV === "development") {
|
|
9272
|
-
if (
|
|
9275
|
+
if (platformModule) {
|
|
9273
9276
|
return;
|
|
9274
9277
|
}
|
|
9275
9278
|
if (messageText) {
|
|
@@ -9279,12 +9282,37 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
9279
9282
|
}
|
|
9280
9283
|
} else {
|
|
9281
9284
|
let finalMessage = messageText;
|
|
9282
|
-
if (
|
|
9283
|
-
|
|
9285
|
+
if (platformModule) {
|
|
9286
|
+
if (typeof message !== "string") {
|
|
9287
|
+
finalMessage = safeStringify(message);
|
|
9288
|
+
}
|
|
9289
|
+
this.observableService.log(level, finalMessage ?? "", {
|
|
9290
|
+
...payload,
|
|
9291
|
+
module: platformModule
|
|
9292
|
+
});
|
|
9293
|
+
} else {
|
|
9294
|
+
const reportMessage = this.processLogParams([
|
|
9295
|
+
message,
|
|
9296
|
+
...optionalParams
|
|
9297
|
+
]);
|
|
9298
|
+
this.observableService.log(level, reportMessage, {});
|
|
9284
9299
|
}
|
|
9285
|
-
this.observableService.log(level, finalMessage ?? "", payload);
|
|
9286
9300
|
}
|
|
9287
9301
|
}
|
|
9302
|
+
processLogParams(args) {
|
|
9303
|
+
if (args.length === 1) {
|
|
9304
|
+
const firstParam = args[0];
|
|
9305
|
+
if (typeof firstParam !== "string") {
|
|
9306
|
+
return safeStringify(firstParam);
|
|
9307
|
+
}
|
|
9308
|
+
return firstParam;
|
|
9309
|
+
}
|
|
9310
|
+
const obj = {};
|
|
9311
|
+
for (let i = 0; i < args.length; i++) {
|
|
9312
|
+
obj[i.toString()] = args[i];
|
|
9313
|
+
}
|
|
9314
|
+
return safeStringify(obj);
|
|
9315
|
+
}
|
|
9288
9316
|
extractOptionalParams(optionalParams, treatStack) {
|
|
9289
9317
|
const params = [
|
|
9290
9318
|
...optionalParams
|
|
@@ -9567,6 +9595,7 @@ url=${req.url}`, "HTTPTraceInterceptor");
|
|
|
9567
9595
|
const reportData = JSON.stringify(responseData);
|
|
9568
9596
|
if (!isDev) {
|
|
9569
9597
|
this.appLogger.log(reportData, {
|
|
9598
|
+
paas_attributes_module: "app_server",
|
|
9570
9599
|
source_type: "platform"
|
|
9571
9600
|
}, "HTTPTraceInterceptor");
|
|
9572
9601
|
}
|
|
@@ -9602,6 +9631,7 @@ duration_ms=${durationMs}`, "HTTPTraceInterceptor");
|
|
|
9602
9631
|
});
|
|
9603
9632
|
return next.handle().pipe((0, import_operators.catchError)((error) => {
|
|
9604
9633
|
this.appLogger.error(format("HTTP request exception\nmethod=%s url=%s\nerror=%o", req.method, req.url, error), {
|
|
9634
|
+
paas_attributes_module: "app_server",
|
|
9605
9635
|
source_type: "platform"
|
|
9606
9636
|
}, "HTTPTraceInterceptor");
|
|
9607
9637
|
throw error;
|