@lark-apaas/nestjs-logger 0.1.0-alpha.5 → 0.1.0-alpha.6
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 +63 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14439,13 +14439,7 @@ var LogLevelState = class LogLevelState2 {
|
|
|
14439
14439
|
static {
|
|
14440
14440
|
__name(this, "LogLevelState");
|
|
14441
14441
|
}
|
|
14442
|
-
levels = /* @__PURE__ */ new Set(
|
|
14443
|
-
"log",
|
|
14444
|
-
"error",
|
|
14445
|
-
"warn",
|
|
14446
|
-
"debug",
|
|
14447
|
-
"verbose"
|
|
14448
|
-
]);
|
|
14442
|
+
levels = /* @__PURE__ */ new Set();
|
|
14449
14443
|
set(levels) {
|
|
14450
14444
|
this.levels = new Set(levels);
|
|
14451
14445
|
}
|
|
@@ -14476,6 +14470,61 @@ var LogLevelState = class LogLevelState2 {
|
|
|
14476
14470
|
}
|
|
14477
14471
|
return "fatal";
|
|
14478
14472
|
}
|
|
14473
|
+
/**
|
|
14474
|
+
* 根据 Pino 级别转换为 NestJS LogLevel 数组
|
|
14475
|
+
*/
|
|
14476
|
+
static fromPinoLevel(pinoLevel) {
|
|
14477
|
+
switch (pinoLevel) {
|
|
14478
|
+
case "trace":
|
|
14479
|
+
return [
|
|
14480
|
+
"verbose",
|
|
14481
|
+
"debug",
|
|
14482
|
+
"log",
|
|
14483
|
+
"warn",
|
|
14484
|
+
"error",
|
|
14485
|
+
"fatal"
|
|
14486
|
+
];
|
|
14487
|
+
case "debug":
|
|
14488
|
+
return [
|
|
14489
|
+
"debug",
|
|
14490
|
+
"log",
|
|
14491
|
+
"warn",
|
|
14492
|
+
"error",
|
|
14493
|
+
"fatal"
|
|
14494
|
+
];
|
|
14495
|
+
case "info":
|
|
14496
|
+
return [
|
|
14497
|
+
"log",
|
|
14498
|
+
"warn",
|
|
14499
|
+
"error",
|
|
14500
|
+
"fatal"
|
|
14501
|
+
];
|
|
14502
|
+
case "warn":
|
|
14503
|
+
return [
|
|
14504
|
+
"warn",
|
|
14505
|
+
"error",
|
|
14506
|
+
"fatal"
|
|
14507
|
+
];
|
|
14508
|
+
case "error":
|
|
14509
|
+
return [
|
|
14510
|
+
"error",
|
|
14511
|
+
"fatal"
|
|
14512
|
+
];
|
|
14513
|
+
case "fatal":
|
|
14514
|
+
return [
|
|
14515
|
+
"fatal"
|
|
14516
|
+
];
|
|
14517
|
+
case "silent":
|
|
14518
|
+
return [];
|
|
14519
|
+
default:
|
|
14520
|
+
return [
|
|
14521
|
+
"log",
|
|
14522
|
+
"warn",
|
|
14523
|
+
"error",
|
|
14524
|
+
"fatal"
|
|
14525
|
+
];
|
|
14526
|
+
}
|
|
14527
|
+
}
|
|
14479
14528
|
};
|
|
14480
14529
|
var BasePinoLogger = class _BasePinoLogger {
|
|
14481
14530
|
static {
|
|
@@ -14487,7 +14536,9 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
14487
14536
|
constructor(logger, contextStore) {
|
|
14488
14537
|
this.logger = logger;
|
|
14489
14538
|
this.contextStore = contextStore;
|
|
14490
|
-
|
|
14539
|
+
const pinoLevel = this.logger.level;
|
|
14540
|
+
const nestLevels = LogLevelState.fromPinoLevel(pinoLevel);
|
|
14541
|
+
this.levelState.set(nestLevels);
|
|
14491
14542
|
}
|
|
14492
14543
|
setLogLevels(levels) {
|
|
14493
14544
|
this.levelState.set(levels);
|
|
@@ -14722,7 +14773,7 @@ function normalizeLevel(level) {
|
|
|
14722
14773
|
}
|
|
14723
14774
|
__name(normalizeLevel, "normalizeLevel");
|
|
14724
14775
|
var logger_config_default = (0, import_config.registerAs)("logger", () => {
|
|
14725
|
-
const level = normalizeLevel(process.env.LOGGER_LEVEL || (process.env.NODE_ENV === "production" ? "info" : "
|
|
14776
|
+
const level = normalizeLevel(process.env.LOGGER_LEVEL || (process.env.NODE_ENV === "production" ? "info" : "trace"));
|
|
14726
14777
|
const maxBodyLengthEnv = process.env.LOG_MAX_BODY_LENGTH;
|
|
14727
14778
|
const maxBodyLength = maxBodyLengthEnv ? Number(maxBodyLengthEnv) : null;
|
|
14728
14779
|
return {
|
|
@@ -14731,7 +14782,7 @@ var logger_config_default = (0, import_config.registerAs)("logger", () => {
|
|
|
14731
14782
|
logRequestBody: process.env.LOG_REQUEST_BODY === "true",
|
|
14732
14783
|
logResponseBody: process.env.LOG_RESPONSE_BODY === "true",
|
|
14733
14784
|
maxBodyLength,
|
|
14734
|
-
sensitiveFields: (process.env.LOG_SENSITIVE_FIELDS || "
|
|
14785
|
+
sensitiveFields: (process.env.LOG_SENSITIVE_FIELDS || "").split(",").map((f) => f.trim())
|
|
14735
14786
|
};
|
|
14736
14787
|
});
|
|
14737
14788
|
|
|
@@ -15042,7 +15093,7 @@ LoggerModule = _ts_decorate5([
|
|
|
15042
15093
|
provide: PINO_ROOT_LOGGER,
|
|
15043
15094
|
useFactory: /* @__PURE__ */ __name((config) => {
|
|
15044
15095
|
return createPinoLogger({
|
|
15045
|
-
level:
|
|
15096
|
+
level: config.level,
|
|
15046
15097
|
filePath: `${config.logDir}/app.log`
|
|
15047
15098
|
});
|
|
15048
15099
|
}, "useFactory"),
|
|
@@ -15053,7 +15104,7 @@ LoggerModule = _ts_decorate5([
|
|
|
15053
15104
|
{
|
|
15054
15105
|
provide: TRACE_LOGGER,
|
|
15055
15106
|
useFactory: /* @__PURE__ */ __name((requestContext, config) => new PinoLoggerService(createPinoLogger({
|
|
15056
|
-
level:
|
|
15107
|
+
level: config.level,
|
|
15057
15108
|
filePath: `${config.logDir}/trace.log`
|
|
15058
15109
|
}), requestContext), "useFactory"),
|
|
15059
15110
|
inject: [
|