@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/testing.js
CHANGED
|
@@ -271,20 +271,32 @@ function formatEntry(entry) {
|
|
|
271
271
|
|
|
272
272
|
// src/logger/logger.ts
|
|
273
273
|
var LEVEL_RANK = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
274
|
+
var LOGGING_STATE_KEY = /* @__PURE__ */ Symbol.for("faapi.logger.state");
|
|
275
|
+
function createDefaultLoggingState() {
|
|
276
|
+
return {
|
|
277
|
+
level: null,
|
|
278
|
+
consoleLevel: null,
|
|
279
|
+
sink: null,
|
|
280
|
+
fileSink: null,
|
|
281
|
+
stdout: true,
|
|
282
|
+
accessLog: true,
|
|
283
|
+
disabled: false
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function getLoggingState() {
|
|
287
|
+
const g = globalThis;
|
|
288
|
+
let state2 = g[LOGGING_STATE_KEY];
|
|
289
|
+
if (!state2) {
|
|
290
|
+
state2 = createDefaultLoggingState();
|
|
291
|
+
g[LOGGING_STATE_KEY] = state2;
|
|
292
|
+
}
|
|
293
|
+
return state2;
|
|
294
|
+
}
|
|
283
295
|
function pipelineThreshold() {
|
|
284
|
-
return
|
|
296
|
+
return getLoggingState().level ?? void 0;
|
|
285
297
|
}
|
|
286
298
|
function consoleThreshold() {
|
|
287
|
-
return
|
|
299
|
+
return getLoggingState().consoleLevel ?? "info";
|
|
288
300
|
}
|
|
289
301
|
function belowThreshold(level, threshold) {
|
|
290
302
|
return threshold !== void 0 && LEVEL_RANK[level] < LEVEL_RANK[threshold];
|
|
@@ -301,15 +313,16 @@ function consoleDispatch(entry) {
|
|
|
301
313
|
console[CONSOLE_METHOD[entry.level]](formatEntry(entry));
|
|
302
314
|
}
|
|
303
315
|
function globalDispatch(entry) {
|
|
304
|
-
|
|
316
|
+
const state2 = getLoggingState();
|
|
317
|
+
if (state2.disabled) return;
|
|
305
318
|
const pipeThreshold = pipelineThreshold();
|
|
306
|
-
if (
|
|
307
|
-
if (!belowThreshold(entry.level, pipeThreshold))
|
|
319
|
+
if (state2.sink) {
|
|
320
|
+
if (!belowThreshold(entry.level, pipeThreshold)) state2.sink(entry);
|
|
308
321
|
return;
|
|
309
322
|
}
|
|
310
|
-
if (
|
|
311
|
-
if (!belowThreshold(entry.level, pipeThreshold))
|
|
312
|
-
if (
|
|
323
|
+
if (state2.fileSink) {
|
|
324
|
+
if (!belowThreshold(entry.level, pipeThreshold)) state2.fileSink.write(entry);
|
|
325
|
+
if (state2.stdout) consoleDispatch(entry);
|
|
313
326
|
return;
|
|
314
327
|
}
|
|
315
328
|
consoleDispatch(entry);
|
|
@@ -318,7 +331,8 @@ function writeLogEntry(entry) {
|
|
|
318
331
|
globalDispatch(entry);
|
|
319
332
|
}
|
|
320
333
|
function isAccessLogEnabled() {
|
|
321
|
-
|
|
334
|
+
const state2 = getLoggingState();
|
|
335
|
+
return !state2.disabled && state2.accessLog;
|
|
322
336
|
}
|
|
323
337
|
function createLogger(scope, options) {
|
|
324
338
|
const baseScope = scope;
|