@putkoff/abstract-logger 0.0.20 → 0.0.21

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.
@@ -2,4 +2,11 @@ export declare const LOG_CONFIG: {
2
2
  condensed: boolean;
3
3
  expandOnDebug: boolean;
4
4
  maxDetailsLength: number;
5
+ /**
6
+ * Function-level filtering
7
+ * - empty allowlist = allow all
8
+ * - blocklist always wins
9
+ */
10
+ functionAllowlist: string[];
11
+ functionBlocklist: string[];
5
12
  };
package/dist/esm/index.js CHANGED
@@ -14471,6 +14471,17 @@ const LOG_CONFIG = {
14471
14471
  condensed: process.env.LOG_CONDENSED !== "false",
14472
14472
  expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
14473
14473
  maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
14474
+ /**
14475
+ * Function-level filtering
14476
+ * - empty allowlist = allow all
14477
+ * - blocklist always wins
14478
+ */
14479
+ functionAllowlist: process.env.LOG_FUNCTION_ALLOWLIST
14480
+ ? process.env.LOG_FUNCTION_ALLOWLIST.split(",").map(s => s.trim())
14481
+ : [],
14482
+ functionBlocklist: process.env.LOG_FUNCTION_BLOCKLIST
14483
+ ? process.env.LOG_FUNCTION_BLOCKLIST.split(",").map(s => s.trim())
14484
+ : [],
14474
14485
  };
14475
14486
 
14476
14487
  /* ------------------------------------------------------------------ */
@@ -14626,8 +14637,15 @@ function getLogString(messageOrOptions, logType = null, details = null, function
14626
14637
  let { message, logType: resolvedLogType, details: resolvedDetails, function_name: resolvedFunctionName, file_location: resolvedFileLocation, consumerLogger: resolvedLoggerInput, } = opts;
14627
14638
  // ---------------- Resolve caller info ----------------
14628
14639
  const { functionName, file } = getCallerInfo();
14629
- resolvedFunctionName = resolveValue(functionName !== "unknown" ? functionName : null, resolvedFunctionName);
14630
- resolvedFileLocation = resolveValue(file !== "unknown" ? file : null, resolvedFileLocation);
14640
+ // ---------------- Resolve caller info ----------------
14641
+ if (!resolvedFunctionName || resolvedFunctionName === "unknown") {
14642
+ const { functionName } = getCallerInfo();
14643
+ resolvedFunctionName = resolveValue(functionName, resolvedFunctionName);
14644
+ }
14645
+ if (!resolvedFileLocation || resolvedFileLocation === "unknown") {
14646
+ const { file } = getCallerInfo();
14647
+ resolvedFileLocation = resolveValue(file, resolvedFileLocation);
14648
+ }
14631
14649
  const emojiMap = {
14632
14650
  info: "ℹ️",
14633
14651
  warn: "⚠️",
@@ -14638,7 +14656,7 @@ function getLogString(messageOrOptions, logType = null, details = null, function
14638
14656
  const emoji = emojiMap[finalLogType] ?? "ℹ️";
14639
14657
  const timestamp = new Date().toISOString();
14640
14658
  const condense = shouldCondense(finalLogType);
14641
- if (condense && typeof resolvedFileLocation === "string") {
14659
+ if (condense) {
14642
14660
  resolvedFileLocation = resolvedFileLocation.split("/").pop();
14643
14661
  }
14644
14662
  let line = `${emoji} [${timestamp}] [${resolvedFunctionName}] ${message}`;