@putkoff/abstract-logger 0.0.75 → 0.0.77

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 CHANGED
@@ -127,6 +127,7 @@ function getLogConfig() {
127
127
  expandOnDebug: getEnvValue({ key: "LOG_EXPAND_DEBUG" }) !== "false",
128
128
  showDetails: getEnvValue({ key: "LOG_SHOW_DETAILS" }) !== "false",
129
129
  showOnly: getEnvValue({ key: "LOG_SHOW_ONLY" }) === "true",
130
+ functionAllowlistStrict: getEnvValue({ key: "LOG_FUNCTION_ALLOWLIST_STRICT" }) === "true",
130
131
  showOnlyFunctions: parseList$1("LOG_SHOW_ONLY_FUNCTIONS"),
131
132
  showOnlyActivities: parseList$1("LOG_SHOW_ONLY_ACTIVITIES"),
132
133
  showOnlyTypes: parseList$1("LOG_SHOW_ONLY_TYPES"),
@@ -14968,17 +14969,10 @@ function shouldLog(opts, caller) {
14968
14969
  if (cfg.showOnlyTypes.length &&
14969
14970
  !cfg.showOnlyTypes.includes(type))
14970
14971
  return false;
14971
- return true; // 👈 NOTHING ELSE APPLIES
14972
- }
14973
- // ─────────────────────────────────────
14974
- // 1️⃣ Hard allowlist
14975
- // ─────────────────────────────────────
14976
- if (cfg.functionAllowlist.length > 0) {
14977
- if (!cfg.functionAllowlist.includes(fn))
14978
- return false;
14972
+ return true;
14979
14973
  }
14980
14974
  // ─────────────────────────────────────
14981
- // 2️⃣ Hard blocklists
14975
+ // 1️⃣ Hard blocklists (ALWAYS APPLY)
14982
14976
  // ─────────────────────────────────────
14983
14977
  if (cfg.functionBlocklist.includes(fn))
14984
14978
  return false;
@@ -14987,7 +14981,16 @@ function shouldLog(opts, caller) {
14987
14981
  if (cfg.logTypeBlocklist.includes(type))
14988
14982
  return false;
14989
14983
  // ─────────────────────────────────────
14990
- // 3️⃣ Burst protection (debug)
14984
+ // 2️⃣ Function allowlist (optional narrowing)
14985
+ // ─────────────────────────────────────
14986
+ if (cfg.functionAllowlist.length > 0) {
14987
+ const allowed = cfg.functionAllowlist.includes(fn);
14988
+ if (!allowed && cfg.functionAllowlistStrict) {
14989
+ return false;
14990
+ }
14991
+ }
14992
+ // ─────────────────────────────────────
14993
+ // 3️⃣ Burst protection (debug only)
14991
14994
  // ─────────────────────────────────────
14992
14995
  if (type === "debug") {
14993
14996
  const key = fn + ":" + message;
@@ -15146,6 +15149,21 @@ function logEvent(props) {
15146
15149
  stats.totalNs += elapsed;
15147
15150
  recordLatency(elapsed);
15148
15151
  }
15152
+ function resolveEnvLogMode() {
15153
+ const env = process.env.LOG_MODE?.toLowerCase();
15154
+ switch (env) {
15155
+ case "full":
15156
+ return exports.LogMode.FULL;
15157
+ case "console":
15158
+ return exports.LogMode.CONSOLE;
15159
+ case "count":
15160
+ return exports.LogMode.COUNT;
15161
+ case "off":
15162
+ return exports.LogMode.OFF;
15163
+ default:
15164
+ return null;
15165
+ }
15166
+ }
15149
15167
  function setLogs(mode = null, interval = false, window_ms = null) {
15150
15168
  const modes = [
15151
15169
  exports.LogMode.FULL,
@@ -15153,25 +15171,36 @@ function setLogs(mode = null, interval = false, window_ms = null) {
15153
15171
  exports.LogMode.COUNT,
15154
15172
  exports.LogMode.OFF,
15155
15173
  ];
15156
- if (window_ms != false) {
15157
- if (window_ms === true || window_ms == null) {
15158
- window_ms = 30_000;
15159
- }
15160
- }
15161
- if (interval != true) {
15162
- mode = mode ?? 3;
15163
- setLogMode(modes[mode]);
15174
+ // ─────────────────────────────────────
15175
+ // 0️⃣ ENV OVERRIDE (ABSOLUTE)
15176
+ // ─────────────────────────────────────
15177
+ const envMode = resolveEnvLogMode();
15178
+ if (envMode !== null) {
15179
+ setLogMode(envMode);
15164
15180
  resetLogStats();
15181
+ return; // 👈 NOTHING ELSE APPLIES
15165
15182
  }
15166
- else {
15183
+ // ─────────────────────────────────────
15184
+ // 1️⃣ Interval rotation mode
15185
+ // ─────────────────────────────────────
15186
+ if (interval === true) {
15167
15187
  let i = 0;
15188
+ if (window_ms === true || window_ms == null) {
15189
+ window_ms = 30_000;
15190
+ }
15168
15191
  setInterval(() => {
15169
- window_ms ||= 30_000;
15170
15192
  recordBenchSnapshot(window_ms);
15171
15193
  resetLogStats();
15172
15194
  setLogMode(modes[++i % modes.length]);
15173
15195
  }, window_ms);
15196
+ return;
15174
15197
  }
15198
+ // ─────────────────────────────────────
15199
+ // 2️⃣ Manual / default mode
15200
+ // ─────────────────────────────────────
15201
+ const resolvedIndex = mode ?? 3; // default OFF
15202
+ setLogMode(modes[resolvedIndex]);
15203
+ resetLogStats();
15175
15204
  }
15176
15205
 
15177
15206
  const LOG_DIR = process.env.LOG_BENCH_DIR ??