@putkoff/abstract-logger 0.0.26 → 0.0.29

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.
@@ -1,13 +1,8 @@
1
- export declare const LOG_CONFIG: {
1
+ export declare function getLogConfig(): {
2
2
  condensed: boolean;
3
3
  expandOnDebug: boolean;
4
4
  showDetails: boolean;
5
5
  maxDetailsLength: number;
6
- /**
7
- * Function-level filtering
8
- * - empty allowlist = allow all
9
- * - blocklist always wins
10
- */
11
6
  showDetailslist: string[];
12
7
  functionAllowlist: string[];
13
8
  functionBlocklist: string[];
@@ -1,3 +1,4 @@
1
+ import "dotenv/config";
1
2
  export type LogType = "success" | "processing" | "listening" | "computing" | "waiting" | "emitting" | "ingesting" | "prune" | "connect" | "info" | "warn" | "error" | "debug" | null;
2
3
  /** Exported logger */
3
4
  export declare const logger: any;
package/dist/esm/index.js CHANGED
@@ -10,6 +10,7 @@ import require$$1 from 'tty';
10
10
  import require$$1$1 from 'string_decoder';
11
11
  import require$$0$7 from 'http';
12
12
  import require$$1$3 from 'https';
13
+ import 'dotenv/config';
13
14
 
14
15
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
15
16
 
@@ -14467,30 +14468,27 @@ const IS_BROWSER = typeof window !== "undefined" &&
14467
14468
  const IS_NODE = typeof process !== "undefined" &&
14468
14469
  process.release?.name === "node";
14469
14470
 
14470
- const LOG_CONFIG = {
14471
- condensed: process.env.LOG_CONDENSED !== "false",
14472
- expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
14473
- showDetails: process.env.LOG_SHOW_DETAILS !== "false",
14474
- maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
14475
- /**
14476
- * Function-level filtering
14477
- * - empty allowlist = allow all
14478
- * - blocklist always wins
14479
- */
14480
- showDetailslist: process.env.LOG_DETAILS_ALLOWLIST
14481
- ? process.env.LOG_DETAILS_ALLOWLIST.split(",").map(s => s.trim())
14482
- : [],
14483
- functionAllowlist: process.env.LOG_FUNCTION_ALLOWLIST
14484
- ? process.env.LOG_FUNCTION_ALLOWLIST.split(",").map(s => s.trim())
14485
- : [],
14486
- functionBlocklist: process.env.LOG_FUNCTION_BLOCKLIST
14487
- ? process.env.LOG_FUNCTION_BLOCKLIST.split(",").map(s => s.trim())
14488
- : [],
14489
- };
14471
+ function parseList(value) {
14472
+ return value
14473
+ ? value.split(",").map(s => s.trim()).filter(Boolean)
14474
+ : [];
14475
+ }
14476
+ function getLogConfig() {
14477
+ return {
14478
+ condensed: process.env.LOG_CONDENSED !== "false",
14479
+ expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
14480
+ showDetails: process.env.LOG_SHOW_DETAILS !== "false",
14481
+ maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
14482
+ showDetailslist: parseList(process.env.LOG_DETAILS_ALLOWLIST),
14483
+ functionAllowlist: parseList(process.env.LOG_FUNCTION_ALLOWLIST),
14484
+ functionBlocklist: parseList(process.env.LOG_FUNCTION_BLOCKLIST),
14485
+ };
14486
+ }
14490
14487
 
14491
- /* ------------------------------------------------------------------ */
14492
- /* Winston logger (Node only) */
14493
- /* ------------------------------------------------------------------ */
14488
+ console.log("ENV CHECK:", {
14489
+ LOG_SHOW_DETAILS: process.env.LOG_SHOW_DETAILS,
14490
+ LOG_DETAILS_ALLOWLIST: process.env.LOG_DETAILS_ALLOWLIST,
14491
+ });
14494
14492
  let nodeLogger = null;
14495
14493
  if (IS_NODE) {
14496
14494
  nodeLogger = winston.createLogger({
@@ -14506,12 +14504,14 @@ if (IS_NODE) {
14506
14504
  });
14507
14505
  }
14508
14506
  function shouldCondense(logType) {
14507
+ const LOG_CONFIG = getLogConfig();
14509
14508
  if (LOG_CONFIG.expandOnDebug && logType === "debug") {
14510
14509
  return false;
14511
14510
  }
14512
14511
  return LOG_CONFIG.condensed;
14513
14512
  }
14514
14513
  function shouldShowDetails(logType) {
14514
+ const LOG_CONFIG = getLogConfig();
14515
14515
  const allow = LOG_CONFIG.showDetailslist;
14516
14516
  // If allowlist exists, it RESTRICTS
14517
14517
  if (allow.length > 0) {
@@ -14685,6 +14685,7 @@ function getLogString(messageOrOptions, logType = null, details = null, function
14685
14685
  let line = `${emoji} [${timestamp}] [${resolvedFunctionName}] ${message}`;
14686
14686
  // ---------------- Details serialization ----------------
14687
14687
  if (showDetails && resolvedDetails !== null && resolvedDetails !== undefined) {
14688
+ const LOG_CONFIG = getLogConfig();
14688
14689
  const serialized = serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength);
14689
14690
  line += ` | ${serialized}`;
14690
14691
  }
@@ -14727,5 +14728,5 @@ function getLogString(messageOrOptions, logType = null, details = null, function
14727
14728
  return line;
14728
14729
  }
14729
14730
 
14730
- export { IS_BROWSER, IS_NODE, LOG_CONFIG, getLogString, logger, resolveValue, serializeDetails };
14731
+ export { IS_BROWSER, IS_NODE, getLogConfig, getLogString, logger, resolveValue, serializeDetails };
14731
14732
  //# sourceMappingURL=index.js.map