@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.cjs
CHANGED
|
@@ -14450,13 +14450,7 @@ var LogLevelState = class LogLevelState2 {
|
|
|
14450
14450
|
static {
|
|
14451
14451
|
__name(this, "LogLevelState");
|
|
14452
14452
|
}
|
|
14453
|
-
levels = /* @__PURE__ */ new Set(
|
|
14454
|
-
"log",
|
|
14455
|
-
"error",
|
|
14456
|
-
"warn",
|
|
14457
|
-
"debug",
|
|
14458
|
-
"verbose"
|
|
14459
|
-
]);
|
|
14453
|
+
levels = /* @__PURE__ */ new Set();
|
|
14460
14454
|
set(levels) {
|
|
14461
14455
|
this.levels = new Set(levels);
|
|
14462
14456
|
}
|
|
@@ -14487,6 +14481,61 @@ var LogLevelState = class LogLevelState2 {
|
|
|
14487
14481
|
}
|
|
14488
14482
|
return "fatal";
|
|
14489
14483
|
}
|
|
14484
|
+
/**
|
|
14485
|
+
* 根据 Pino 级别转换为 NestJS LogLevel 数组
|
|
14486
|
+
*/
|
|
14487
|
+
static fromPinoLevel(pinoLevel) {
|
|
14488
|
+
switch (pinoLevel) {
|
|
14489
|
+
case "trace":
|
|
14490
|
+
return [
|
|
14491
|
+
"verbose",
|
|
14492
|
+
"debug",
|
|
14493
|
+
"log",
|
|
14494
|
+
"warn",
|
|
14495
|
+
"error",
|
|
14496
|
+
"fatal"
|
|
14497
|
+
];
|
|
14498
|
+
case "debug":
|
|
14499
|
+
return [
|
|
14500
|
+
"debug",
|
|
14501
|
+
"log",
|
|
14502
|
+
"warn",
|
|
14503
|
+
"error",
|
|
14504
|
+
"fatal"
|
|
14505
|
+
];
|
|
14506
|
+
case "info":
|
|
14507
|
+
return [
|
|
14508
|
+
"log",
|
|
14509
|
+
"warn",
|
|
14510
|
+
"error",
|
|
14511
|
+
"fatal"
|
|
14512
|
+
];
|
|
14513
|
+
case "warn":
|
|
14514
|
+
return [
|
|
14515
|
+
"warn",
|
|
14516
|
+
"error",
|
|
14517
|
+
"fatal"
|
|
14518
|
+
];
|
|
14519
|
+
case "error":
|
|
14520
|
+
return [
|
|
14521
|
+
"error",
|
|
14522
|
+
"fatal"
|
|
14523
|
+
];
|
|
14524
|
+
case "fatal":
|
|
14525
|
+
return [
|
|
14526
|
+
"fatal"
|
|
14527
|
+
];
|
|
14528
|
+
case "silent":
|
|
14529
|
+
return [];
|
|
14530
|
+
default:
|
|
14531
|
+
return [
|
|
14532
|
+
"log",
|
|
14533
|
+
"warn",
|
|
14534
|
+
"error",
|
|
14535
|
+
"fatal"
|
|
14536
|
+
];
|
|
14537
|
+
}
|
|
14538
|
+
}
|
|
14490
14539
|
};
|
|
14491
14540
|
var BasePinoLogger = class _BasePinoLogger {
|
|
14492
14541
|
static {
|
|
@@ -14498,7 +14547,9 @@ var BasePinoLogger = class _BasePinoLogger {
|
|
|
14498
14547
|
constructor(logger, contextStore) {
|
|
14499
14548
|
this.logger = logger;
|
|
14500
14549
|
this.contextStore = contextStore;
|
|
14501
|
-
|
|
14550
|
+
const pinoLevel = this.logger.level;
|
|
14551
|
+
const nestLevels = LogLevelState.fromPinoLevel(pinoLevel);
|
|
14552
|
+
this.levelState.set(nestLevels);
|
|
14502
14553
|
}
|
|
14503
14554
|
setLogLevels(levels) {
|
|
14504
14555
|
this.levelState.set(levels);
|
|
@@ -14733,7 +14784,7 @@ function normalizeLevel(level) {
|
|
|
14733
14784
|
}
|
|
14734
14785
|
__name(normalizeLevel, "normalizeLevel");
|
|
14735
14786
|
var logger_config_default = (0, import_config.registerAs)("logger", () => {
|
|
14736
|
-
const level = normalizeLevel(process.env.LOGGER_LEVEL || (process.env.NODE_ENV === "production" ? "info" : "
|
|
14787
|
+
const level = normalizeLevel(process.env.LOGGER_LEVEL || (process.env.NODE_ENV === "production" ? "info" : "trace"));
|
|
14737
14788
|
const maxBodyLengthEnv = process.env.LOG_MAX_BODY_LENGTH;
|
|
14738
14789
|
const maxBodyLength = maxBodyLengthEnv ? Number(maxBodyLengthEnv) : null;
|
|
14739
14790
|
return {
|
|
@@ -14742,7 +14793,7 @@ var logger_config_default = (0, import_config.registerAs)("logger", () => {
|
|
|
14742
14793
|
logRequestBody: process.env.LOG_REQUEST_BODY === "true",
|
|
14743
14794
|
logResponseBody: process.env.LOG_RESPONSE_BODY === "true",
|
|
14744
14795
|
maxBodyLength,
|
|
14745
|
-
sensitiveFields: (process.env.LOG_SENSITIVE_FIELDS || "
|
|
14796
|
+
sensitiveFields: (process.env.LOG_SENSITIVE_FIELDS || "").split(",").map((f) => f.trim())
|
|
14746
14797
|
};
|
|
14747
14798
|
});
|
|
14748
14799
|
|
|
@@ -15053,7 +15104,7 @@ LoggerModule = _ts_decorate5([
|
|
|
15053
15104
|
provide: PINO_ROOT_LOGGER,
|
|
15054
15105
|
useFactory: /* @__PURE__ */ __name((config) => {
|
|
15055
15106
|
return createPinoLogger({
|
|
15056
|
-
level:
|
|
15107
|
+
level: config.level,
|
|
15057
15108
|
filePath: `${config.logDir}/app.log`
|
|
15058
15109
|
});
|
|
15059
15110
|
}, "useFactory"),
|
|
@@ -15064,7 +15115,7 @@ LoggerModule = _ts_decorate5([
|
|
|
15064
15115
|
{
|
|
15065
15116
|
provide: TRACE_LOGGER,
|
|
15066
15117
|
useFactory: /* @__PURE__ */ __name((requestContext, config) => new PinoLoggerService(createPinoLogger({
|
|
15067
|
-
level:
|
|
15118
|
+
level: config.level,
|
|
15068
15119
|
filePath: `${config.logDir}/trace.log`
|
|
15069
15120
|
}), requestContext), "useFactory"),
|
|
15070
15121
|
inject: [
|