@faapi/faapi 6.10.0 → 6.10.1
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/cli/index.js +45 -30
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +46 -30
- package/dist/index.js.map +1 -1
- package/dist/testing.js +32 -18
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -6497,42 +6497,63 @@ function assertLogLevel(value, source) {
|
|
|
6497
6497
|
);
|
|
6498
6498
|
}
|
|
6499
6499
|
}
|
|
6500
|
+
function createDefaultLoggingState() {
|
|
6501
|
+
return {
|
|
6502
|
+
level: null,
|
|
6503
|
+
consoleLevel: null,
|
|
6504
|
+
sink: null,
|
|
6505
|
+
fileSink: null,
|
|
6506
|
+
stdout: true,
|
|
6507
|
+
accessLog: true,
|
|
6508
|
+
disabled: false
|
|
6509
|
+
};
|
|
6510
|
+
}
|
|
6511
|
+
function getLoggingState() {
|
|
6512
|
+
const g = globalThis;
|
|
6513
|
+
let state2 = g[LOGGING_STATE_KEY];
|
|
6514
|
+
if (!state2) {
|
|
6515
|
+
state2 = createDefaultLoggingState();
|
|
6516
|
+
g[LOGGING_STATE_KEY] = state2;
|
|
6517
|
+
}
|
|
6518
|
+
return state2;
|
|
6519
|
+
}
|
|
6500
6520
|
function configureLogging(config) {
|
|
6521
|
+
const state2 = getLoggingState();
|
|
6501
6522
|
const objectConfig = typeof config === "object" ? config : {};
|
|
6502
6523
|
if (objectConfig.sink && objectConfig.dir) {
|
|
6503
6524
|
throw new Error(
|
|
6504
6525
|
"[faapi] config.log.sink and config.log.dir are mutually exclusive: pick one output pipeline (custom sink OR built-in file logs)."
|
|
6505
6526
|
);
|
|
6506
6527
|
}
|
|
6507
|
-
void
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6528
|
+
void state2.fileSink?.close();
|
|
6529
|
+
state2.disabled = config === false;
|
|
6530
|
+
state2.sink = objectConfig.sink ?? null;
|
|
6531
|
+
state2.accessLog = objectConfig.accessLog ?? true;
|
|
6532
|
+
state2.stdout = objectConfig.stdout ?? true;
|
|
6533
|
+
state2.fileSink = objectConfig.dir ? createFileLogSink({ dir: objectConfig.dir, splitByLevel: objectConfig.splitByLevel }) : null;
|
|
6513
6534
|
if (objectConfig.consoleLevel !== void 0) {
|
|
6514
6535
|
if (objectConfig.consoleLevel !== false) {
|
|
6515
6536
|
assertLogLevel(objectConfig.consoleLevel, "config.log.consoleLevel");
|
|
6516
6537
|
}
|
|
6517
|
-
|
|
6538
|
+
state2.consoleLevel = objectConfig.consoleLevel;
|
|
6518
6539
|
} else {
|
|
6519
|
-
|
|
6540
|
+
state2.consoleLevel = null;
|
|
6520
6541
|
}
|
|
6521
6542
|
if (objectConfig.level !== void 0) {
|
|
6522
6543
|
assertLogLevel(objectConfig.level, "config.log.level");
|
|
6523
|
-
|
|
6544
|
+
state2.level = objectConfig.level;
|
|
6524
6545
|
} else if (process.env.LOG_LEVEL !== void 0) {
|
|
6525
6546
|
assertLogLevel(process.env.LOG_LEVEL, "LOG_LEVEL env");
|
|
6526
|
-
|
|
6547
|
+
state2.level = process.env.LOG_LEVEL;
|
|
6527
6548
|
} else {
|
|
6528
|
-
|
|
6549
|
+
state2.level = null;
|
|
6529
6550
|
}
|
|
6530
6551
|
}
|
|
6531
6552
|
function pipelineThreshold() {
|
|
6532
|
-
return
|
|
6553
|
+
return getLoggingState().level ?? void 0;
|
|
6533
6554
|
}
|
|
6534
6555
|
function consoleThreshold() {
|
|
6535
|
-
return
|
|
6556
|
+
return getLoggingState().consoleLevel ?? "info";
|
|
6536
6557
|
}
|
|
6537
6558
|
function belowThreshold(level, threshold) {
|
|
6538
6559
|
return threshold !== void 0 && LEVEL_RANK[level] < LEVEL_RANK[threshold];
|
|
@@ -6546,15 +6567,16 @@ function consoleDispatch(entry) {
|
|
|
6546
6567
|
console[CONSOLE_METHOD[entry.level]](formatEntry(entry));
|
|
6547
6568
|
}
|
|
6548
6569
|
function globalDispatch(entry) {
|
|
6549
|
-
|
|
6570
|
+
const state2 = getLoggingState();
|
|
6571
|
+
if (state2.disabled) return;
|
|
6550
6572
|
const pipeThreshold = pipelineThreshold();
|
|
6551
|
-
if (
|
|
6552
|
-
if (!belowThreshold(entry.level, pipeThreshold))
|
|
6573
|
+
if (state2.sink) {
|
|
6574
|
+
if (!belowThreshold(entry.level, pipeThreshold)) state2.sink(entry);
|
|
6553
6575
|
return;
|
|
6554
6576
|
}
|
|
6555
|
-
if (
|
|
6556
|
-
if (!belowThreshold(entry.level, pipeThreshold))
|
|
6557
|
-
if (
|
|
6577
|
+
if (state2.fileSink) {
|
|
6578
|
+
if (!belowThreshold(entry.level, pipeThreshold)) state2.fileSink.write(entry);
|
|
6579
|
+
if (state2.stdout) consoleDispatch(entry);
|
|
6558
6580
|
return;
|
|
6559
6581
|
}
|
|
6560
6582
|
consoleDispatch(entry);
|
|
@@ -6563,7 +6585,8 @@ function writeLogEntry(entry) {
|
|
|
6563
6585
|
globalDispatch(entry);
|
|
6564
6586
|
}
|
|
6565
6587
|
function isAccessLogEnabled() {
|
|
6566
|
-
|
|
6588
|
+
const state2 = getLoggingState();
|
|
6589
|
+
return !state2.disabled && state2.accessLog;
|
|
6567
6590
|
}
|
|
6568
6591
|
function createLogger(scope, options) {
|
|
6569
6592
|
const baseScope = scope;
|
|
@@ -6595,7 +6618,7 @@ function createLogger(scope, options) {
|
|
|
6595
6618
|
});
|
|
6596
6619
|
return makeLogger(void 0);
|
|
6597
6620
|
}
|
|
6598
|
-
var LEVEL_RANK, VALID_LEVELS,
|
|
6621
|
+
var LEVEL_RANK, VALID_LEVELS, LOGGING_STATE_KEY, CONSOLE_METHOD;
|
|
6599
6622
|
var init_logger = __esm({
|
|
6600
6623
|
"src/logger/logger.ts"() {
|
|
6601
6624
|
"use strict";
|
|
@@ -6603,15 +6626,7 @@ var init_logger = __esm({
|
|
|
6603
6626
|
init_fileSink();
|
|
6604
6627
|
LEVEL_RANK = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
6605
6628
|
VALID_LEVELS = ["debug", "info", "warn", "error"];
|
|
6606
|
-
|
|
6607
|
-
level: null,
|
|
6608
|
-
consoleLevel: null,
|
|
6609
|
-
sink: null,
|
|
6610
|
-
fileSink: null,
|
|
6611
|
-
stdout: true,
|
|
6612
|
-
accessLog: true,
|
|
6613
|
-
disabled: false
|
|
6614
|
-
};
|
|
6629
|
+
LOGGING_STATE_KEY = /* @__PURE__ */ Symbol.for("faapi.logger.state");
|
|
6615
6630
|
CONSOLE_METHOD = {
|
|
6616
6631
|
debug: "debug",
|
|
6617
6632
|
info: "info",
|