@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.
package/dist/cjs/index.js CHANGED
@@ -12,6 +12,7 @@ var require$$1 = require('tty');
12
12
  var require$$1$1 = require('string_decoder');
13
13
  var require$$0$7 = require('http');
14
14
  var require$$1$3 = require('https');
15
+ require('dotenv/config');
15
16
 
16
17
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17
18
 
@@ -14469,30 +14470,27 @@ const IS_BROWSER = typeof window !== "undefined" &&
14469
14470
  const IS_NODE = typeof process !== "undefined" &&
14470
14471
  process.release?.name === "node";
14471
14472
 
14472
- const LOG_CONFIG = {
14473
- condensed: process.env.LOG_CONDENSED !== "false",
14474
- expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
14475
- showDetails: process.env.LOG_SHOW_DETAILS !== "false",
14476
- maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
14477
- /**
14478
- * Function-level filtering
14479
- * - empty allowlist = allow all
14480
- * - blocklist always wins
14481
- */
14482
- showDetailslist: process.env.LOG_DETAILS_ALLOWLIST
14483
- ? process.env.LOG_DETAILS_ALLOWLIST.split(",").map(s => s.trim())
14484
- : [],
14485
- functionAllowlist: process.env.LOG_FUNCTION_ALLOWLIST
14486
- ? process.env.LOG_FUNCTION_ALLOWLIST.split(",").map(s => s.trim())
14487
- : [],
14488
- functionBlocklist: process.env.LOG_FUNCTION_BLOCKLIST
14489
- ? process.env.LOG_FUNCTION_BLOCKLIST.split(",").map(s => s.trim())
14490
- : [],
14491
- };
14473
+ function parseList(value) {
14474
+ return value
14475
+ ? value.split(",").map(s => s.trim()).filter(Boolean)
14476
+ : [];
14477
+ }
14478
+ function getLogConfig() {
14479
+ return {
14480
+ condensed: process.env.LOG_CONDENSED !== "false",
14481
+ expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
14482
+ showDetails: process.env.LOG_SHOW_DETAILS !== "false",
14483
+ maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
14484
+ showDetailslist: parseList(process.env.LOG_DETAILS_ALLOWLIST),
14485
+ functionAllowlist: parseList(process.env.LOG_FUNCTION_ALLOWLIST),
14486
+ functionBlocklist: parseList(process.env.LOG_FUNCTION_BLOCKLIST),
14487
+ };
14488
+ }
14492
14489
 
14493
- /* ------------------------------------------------------------------ */
14494
- /* Winston logger (Node only) */
14495
- /* ------------------------------------------------------------------ */
14490
+ console.log("ENV CHECK:", {
14491
+ LOG_SHOW_DETAILS: process.env.LOG_SHOW_DETAILS,
14492
+ LOG_DETAILS_ALLOWLIST: process.env.LOG_DETAILS_ALLOWLIST,
14493
+ });
14496
14494
  let nodeLogger = null;
14497
14495
  if (IS_NODE) {
14498
14496
  nodeLogger = winston.createLogger({
@@ -14508,12 +14506,14 @@ if (IS_NODE) {
14508
14506
  });
14509
14507
  }
14510
14508
  function shouldCondense(logType) {
14509
+ const LOG_CONFIG = getLogConfig();
14511
14510
  if (LOG_CONFIG.expandOnDebug && logType === "debug") {
14512
14511
  return false;
14513
14512
  }
14514
14513
  return LOG_CONFIG.condensed;
14515
14514
  }
14516
14515
  function shouldShowDetails(logType) {
14516
+ const LOG_CONFIG = getLogConfig();
14517
14517
  const allow = LOG_CONFIG.showDetailslist;
14518
14518
  // If allowlist exists, it RESTRICTS
14519
14519
  if (allow.length > 0) {
@@ -14687,6 +14687,7 @@ function getLogString(messageOrOptions, logType = null, details = null, function
14687
14687
  let line = `${emoji} [${timestamp}] [${resolvedFunctionName}] ${message}`;
14688
14688
  // ---------------- Details serialization ----------------
14689
14689
  if (showDetails && resolvedDetails !== null && resolvedDetails !== undefined) {
14690
+ const LOG_CONFIG = getLogConfig();
14690
14691
  const serialized = serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength);
14691
14692
  line += ` | ${serialized}`;
14692
14693
  }
@@ -14731,7 +14732,7 @@ function getLogString(messageOrOptions, logType = null, details = null, function
14731
14732
 
14732
14733
  exports.IS_BROWSER = IS_BROWSER;
14733
14734
  exports.IS_NODE = IS_NODE;
14734
- exports.LOG_CONFIG = LOG_CONFIG;
14735
+ exports.getLogConfig = getLogConfig;
14735
14736
  exports.getLogString = getLogString;
14736
14737
  exports.logger = logger;
14737
14738
  exports.resolveValue = resolveValue;