@putkoff/abstract-logger 0.0.51 → 0.0.58
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/cjs/index.js +20 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/config.d.ts +4 -1
- package/dist/esm/index.js +20 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/config.d.ts +4 -1
- package/dist/index.d.ts +83 -0
- package/dist/types/config.d.ts +4 -1
- package/dist/types/index.d.ts +3 -80
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -292,13 +292,15 @@ function parseList(key) {
|
|
|
292
292
|
const v = getEnvValue({ key });
|
|
293
293
|
return v ? v.split(",").map(s => s.trim()).filter(Boolean) : [];
|
|
294
294
|
}
|
|
295
|
-
|
|
296
|
-
function buildLogConfig() {
|
|
295
|
+
function getLogConfig() {
|
|
297
296
|
return {
|
|
298
297
|
condensed: getEnvValue({ key: "LOG_CONDENSED" }) !== "false",
|
|
299
298
|
expandOnDebug: getEnvValue({ key: "LOG_EXPAND_DEBUG" }) !== "false",
|
|
300
299
|
showDetails: getEnvValue({ key: "LOG_SHOW_DETAILS" }) !== "false",
|
|
301
|
-
|
|
300
|
+
showOnly: getEnvValue({ key: "LOG_SHOW_ONLY" }) === "true",
|
|
301
|
+
showOnlyFunctions: parseList("LOG_SHOW_ONLY_FUNCTIONS"),
|
|
302
|
+
showOnlyActivities: parseList("LOG_SHOW_ONLY_ACTIVITIES"),
|
|
303
|
+
showOnlyTypes: parseList("LOG_SHOW_ONLY_TYPES"),
|
|
302
304
|
maxDetailsLength: Number(getEnvValue({ key: "LOG_DETAILS_MAX" }) ?? 500),
|
|
303
305
|
sampleRate: Number(getEnvValue({ key: "LOG_SAMPLE_RATE" }) ?? 1),
|
|
304
306
|
prettyDetails: getEnvValue({ key: "LOG_PRETTY_DETAILS" }) === "true",
|
|
@@ -309,16 +311,6 @@ function buildLogConfig() {
|
|
|
309
311
|
functionBlocklist: parseList("LOG_FUNCTION_BLOCKLIST"),
|
|
310
312
|
};
|
|
311
313
|
}
|
|
312
|
-
function getLogConfig() {
|
|
313
|
-
if (!cachedConfig) {
|
|
314
|
-
const params = buildLogConfig();
|
|
315
|
-
if (!params.envlockdown) {
|
|
316
|
-
cachedConfig = params;
|
|
317
|
-
}
|
|
318
|
-
return params;
|
|
319
|
-
}
|
|
320
|
-
return cachedConfig;
|
|
321
|
-
}
|
|
322
314
|
function debugLogConfig() {
|
|
323
315
|
if (getEnvValue({ key: "LOG_DEBUG_CONFIG" }) === "true") {
|
|
324
316
|
console.log("LOG CONFIG ENV:", {
|
|
@@ -14883,12 +14875,26 @@ function hash(str) {
|
|
|
14883
14875
|
}
|
|
14884
14876
|
function shouldLog(opts, caller) {
|
|
14885
14877
|
const cfg = getLogConfig();
|
|
14886
|
-
// logType is already normalized upstream
|
|
14887
14878
|
const type = opts.logType;
|
|
14888
14879
|
const fn = caller.functionName;
|
|
14889
14880
|
const activity = opts.activity;
|
|
14890
14881
|
const message = opts.message;
|
|
14891
14882
|
// ─────────────────────────────────────
|
|
14883
|
+
// 🟥 0️⃣ SHOW-ONLY OVERRIDE (ABSOLUTE)
|
|
14884
|
+
// ─────────────────────────────────────
|
|
14885
|
+
if (cfg.showOnly) {
|
|
14886
|
+
if (cfg.showOnlyFunctions.length &&
|
|
14887
|
+
!cfg.showOnlyFunctions.includes(fn))
|
|
14888
|
+
return false;
|
|
14889
|
+
if (cfg.showOnlyActivities.length &&
|
|
14890
|
+
(!activity || !cfg.showOnlyActivities.includes(activity)))
|
|
14891
|
+
return false;
|
|
14892
|
+
if (cfg.showOnlyTypes.length &&
|
|
14893
|
+
!cfg.showOnlyTypes.includes(type))
|
|
14894
|
+
return false;
|
|
14895
|
+
return true; // 👈 NOTHING ELSE APPLIES
|
|
14896
|
+
}
|
|
14897
|
+
// ─────────────────────────────────────
|
|
14892
14898
|
// 1️⃣ Hard allowlist
|
|
14893
14899
|
// ─────────────────────────────────────
|
|
14894
14900
|
if (cfg.functionAllowlist.length > 0) {
|