@putkoff/abstract-logger 0.0.35 โ†’ 0.0.38

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.
Files changed (47) hide show
  1. package/dist/cjs/index.js +389 -269
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/config.d.ts +4 -0
  4. package/dist/cjs/types/imports/constants.d.ts +8 -0
  5. package/dist/cjs/types/imports/functions.d.ts +16 -0
  6. package/dist/cjs/types/imports/index.d.ts +5 -0
  7. package/dist/cjs/types/imports/init_imports.d.ts +1 -0
  8. package/dist/cjs/types/imports/nodeLogger.d.ts +3 -0
  9. package/dist/cjs/types/imports/utils/detect.d.ts +10 -0
  10. package/dist/cjs/types/imports/utils/index.d.ts +2 -0
  11. package/dist/cjs/types/imports/utils/utils.d.ts +8 -0
  12. package/dist/cjs/types/index.d.ts +1 -1
  13. package/dist/cjs/types/logger/blocker.d.ts +4 -0
  14. package/dist/cjs/types/logger/logger.d.ts +1 -18
  15. package/dist/cjs/types/types/index.d.ts +1 -0
  16. package/dist/cjs/types/types/types.d.ts +10 -0
  17. package/dist/esm/index.js +377 -270
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/types/config.d.ts +4 -0
  20. package/dist/esm/types/imports/constants.d.ts +8 -0
  21. package/dist/esm/types/imports/functions.d.ts +16 -0
  22. package/dist/esm/types/imports/index.d.ts +5 -0
  23. package/dist/esm/types/imports/init_imports.d.ts +1 -0
  24. package/dist/esm/types/imports/nodeLogger.d.ts +3 -0
  25. package/dist/esm/types/imports/utils/detect.d.ts +10 -0
  26. package/dist/esm/types/imports/utils/index.d.ts +2 -0
  27. package/dist/esm/types/imports/utils/utils.d.ts +8 -0
  28. package/dist/esm/types/index.d.ts +1 -1
  29. package/dist/esm/types/logger/blocker.d.ts +4 -0
  30. package/dist/esm/types/logger/logger.d.ts +1 -18
  31. package/dist/esm/types/types/index.d.ts +1 -0
  32. package/dist/esm/types/types/types.d.ts +10 -0
  33. package/dist/types/config.d.ts +4 -0
  34. package/dist/types/imports/constants.d.ts +8 -0
  35. package/dist/types/imports/functions.d.ts +16 -0
  36. package/dist/types/imports/index.d.ts +5 -0
  37. package/dist/types/imports/init_imports.d.ts +1 -0
  38. package/dist/types/imports/nodeLogger.d.ts +3 -0
  39. package/dist/types/imports/utils/detect.d.ts +10 -0
  40. package/dist/types/imports/utils/index.d.ts +2 -0
  41. package/dist/types/imports/utils/utils.d.ts +8 -0
  42. package/dist/types/index.d.ts +51 -11
  43. package/dist/types/logger/blocker.d.ts +4 -0
  44. package/dist/types/logger/logger.d.ts +1 -18
  45. package/dist/types/types/index.d.ts +1 -0
  46. package/dist/types/types/types.d.ts +10 -0
  47. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -10,7 +10,210 @@ 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
+ /* ------------------------------------------------------------------ */
15
+ /* Stack inspection */
16
+ /* ------------------------------------------------------------------ */
17
+ function padRight(str, width) {
18
+ return str.length >= width ? str : str + " ".repeat(width - str.length);
19
+ }
20
+ function padLeft(str, width) {
21
+ return str.length >= width ? str : " ".repeat(width - str.length) + str;
22
+ }
23
+ /**
24
+ * Normalizes inputs by treating "unknown" and empty values as null.
25
+ * Returns "unknown" ONLY if all inputs are invalid.
26
+ */
27
+ function resolveValue(...values) {
28
+ let sawInput = false;
29
+ for (const value of values) {
30
+ if (value === undefined || value === null)
31
+ continue;
32
+ sawInput = true;
33
+ if (typeof value === "string") {
34
+ const v = value.trim();
35
+ if (!v || v.toLowerCase() === "unknown")
36
+ continue;
37
+ return value;
38
+ }
39
+ return value;
40
+ }
41
+ return sawInput ? "unknown" : "unknown";
42
+ }
43
+ function parseList(value) {
44
+ return value
45
+ ? value.split(",").map(s => s.trim()).filter(Boolean)
46
+ : [];
47
+ }
48
+
49
+ /** ---------------------------------------------------------
50
+ * Detect Environment
51
+ * --------------------------------------------------------- */
52
+ const IS_BROWSER = typeof window !== "undefined" &&
53
+ typeof window.document !== "undefined";
54
+ const IS_NODE = typeof process !== "undefined" &&
55
+ process.release?.name === "node";
56
+ /* ------------------------------------------------------------------ */
57
+ /* Stack inspection */
58
+ /* ------------------------------------------------------------------ */
59
+ function extractFile(frame) {
60
+ // file:///path/to/file.ts:line:col
61
+ const esmMatch = frame.match(/file:\/\/(.+?):\d+:\d+/);
62
+ if (esmMatch)
63
+ return esmMatch[1];
64
+ // (path/to/file.ts:line:col)
65
+ const cjsMatch = frame.match(/\((.+?):\d+:\d+\)/);
66
+ if (cjsMatch)
67
+ return cjsMatch[1];
68
+ // at path/to/file.ts:line:col
69
+ const bareMatch = frame.match(/at\s+(.+?):\d+:\d+/);
70
+ if (bareMatch)
71
+ return bareMatch[1];
72
+ return "unknown";
73
+ }
74
+ function getCallerInfo(func) {
75
+ if (!IS_NODE) {
76
+ return { functionName: "browser", file: "browser" };
77
+ }
78
+ const obj = {};
79
+ Error.captureStackTrace(obj, func);
80
+ const stack = obj.stack?.split("\n") ?? [];
81
+ const frame = stack
82
+ .slice(1)
83
+ .find((line) => !line.includes("node:internal") &&
84
+ !line.includes("processTicksAndRejections"));
85
+ if (!frame) {
86
+ return { functionName: "unknown", file: "unknown" };
87
+ }
88
+ const fnMatch = frame.match(/at\s+async\s+([^\s(]+)/) ||
89
+ frame.match(/at\s+([^\s(]+)/);
90
+ return {
91
+ functionName: fnMatch?.[1] && fnMatch[1] !== "Object.<anonymous>"
92
+ ? fnMatch[1]
93
+ : "unknown",
94
+ file: extractFile(frame),
95
+ };
96
+ }
97
+
98
+ const activityEmojiMap = {
99
+ emitting: "๐Ÿ“ค",
100
+ ingesting: "๐Ÿ“ฅ",
101
+ streaming: "๐ŸŒŠ",
102
+ forwarding: "โžก๏ธ",
103
+ receiving: "๐Ÿ“ก",
104
+ relaying: "๐Ÿ”",
105
+ syncing: "๐Ÿ”„",
106
+ buffering: "โณ",
107
+ batching: "๐Ÿ“ฆ",
108
+ dispatching: "๐Ÿš€",
109
+ settings: "โš™๏ธ",
110
+ computing: "๐Ÿง ",
111
+ running: "๐Ÿƒ",
112
+ working: "๐Ÿ”ง",
113
+ building: "๐Ÿ—๏ธ",
114
+ compiling: "๐Ÿงฉ",
115
+ crunching: "๐Ÿงฎ",
116
+ optimizing: "๐Ÿ“ˆ",
117
+ queued: "๐Ÿ•’",
118
+ waiting: "โณ",
119
+ active: "โ–ถ๏ธ",
120
+ paused: "โธ๏ธ",
121
+ sleeping: "๐Ÿ’ค",
122
+ resumed: "๐Ÿ”„",
123
+ completed: "โœ…",
124
+ cancelled: "โŒ",
125
+ expired: "โŒ›",
126
+ warning: "โš ๏ธ",
127
+ error: "โŒ",
128
+ critical: "๐Ÿšจ",
129
+ retrying: "๐Ÿ”",
130
+ skipped: "โญ๏ธ",
131
+ fallback: "๐Ÿ›Ÿ",
132
+ degraded: "๐Ÿ“‰",
133
+ saved: "๐Ÿ’พ",
134
+ loading: "๐Ÿ“‚",
135
+ exporting: "๐Ÿ“ค",
136
+ importing: "๐Ÿ“ฅ",
137
+ archived: "๐Ÿ—„๏ธ",
138
+ deleted: "๐Ÿ—‘๏ธ",
139
+ cached: "๐ŸงŠ",
140
+ persisted: "๐Ÿ“Œ",
141
+ locked: "๐Ÿ”’",
142
+ unlocked: "๐Ÿ”“",
143
+ secure: "๐Ÿ›ก๏ธ",
144
+ insecure: "โš ๏ธ",
145
+ verified: "โœ”๏ธ",
146
+ blocked: "โ›”",
147
+ allowed: "๐ŸŸข",
148
+ connected: "๐Ÿ”—",
149
+ disconnected: "โŒ",
150
+ online: "๐ŸŸข",
151
+ offline: "๐Ÿ”ด",
152
+ latency: "๐Ÿ“ถ",
153
+ proxying: "๐Ÿงญ",
154
+ broadcasting: "๐Ÿ“ฃ",
155
+ thinking: "๐Ÿค”",
156
+ learning: "๐Ÿง ",
157
+ predicting: "๐Ÿ”ฎ",
158
+ scanning: "๐Ÿ”",
159
+ crawling: "๐Ÿ•ท๏ธ",
160
+ responding: "๐Ÿ’ฌ",
161
+ generating: "โœจ",
162
+ debug: "๐Ÿž",
163
+ trace: "๐Ÿงต",
164
+ inspect: "๐Ÿ”Ž",
165
+ test: "๐Ÿงช",
166
+ mock: "๐ŸŽญ",
167
+ sandbox: "๐Ÿ–๏ธ",
168
+ experiment: "โš—๏ธ",
169
+ success: "โœ…",
170
+ processing: "๐Ÿ”„",
171
+ listening: "๐Ÿ“ก",
172
+ prune: "๐Ÿงน",
173
+ connect: "๐Ÿ”Œ",
174
+ info: "โ„น๏ธ",
175
+ warn: "โš ๏ธ"
176
+ };
177
+ const COLS = {
178
+ emoji: 2,
179
+ timestamp: 24,
180
+ function: 28,
181
+ message: 0, // flexible
182
+ file: 16,
183
+ };
184
+
185
+ /* ------------------------------------------------------------------ */
186
+ /* Winston logger (Node only) */
187
+ /* ------------------------------------------------------------------ */
188
+ console.log("ENV CHECK:", {
189
+ LOG_SHOW_DETAILS: process.env.LOG_SHOW_DETAILS,
190
+ LOG_DETAILS_ALLOWLIST: process.env.LOG_DETAILS_ALLOWLIST,
191
+ });
192
+ function getLogConfig() {
193
+ return {
194
+ condensed: process.env.LOG_CONDENSED !== "false",
195
+ expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
196
+ showDetails: process.env.LOG_SHOW_DETAILS !== "false",
197
+ maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
198
+ activityBlocklist: parse$1(process.env.LOG_ACTIVITY_BLOCKLIST),
199
+ logTypeBlocklist: parse$1(process.env.LOG_TYPE_BLOCKLIST),
200
+ sampleRate: Number(process.env.LOG_SAMPLE_RATE ?? 1), // 0โ€“1
201
+ // ๐Ÿ‘‡ NEW
202
+ prettyDetails: process.env.LOG_PRETTY_DETAILS === "true",
203
+ showDetailslist: process.env.LOG_DETAILS_ALLOWLIST
204
+ ? process.env.LOG_DETAILS_ALLOWLIST.split(",").map(s => s.trim())
205
+ : [],
206
+ functionAllowlist: process.env.LOG_FUNCTION_ALLOWLIST
207
+ ? process.env.LOG_FUNCTION_ALLOWLIST.split(",").map(s => s.trim())
208
+ : [],
209
+ functionBlocklist: process.env.LOG_FUNCTION_BLOCKLIST
210
+ ? process.env.LOG_FUNCTION_BLOCKLIST.split(",").map(s => s.trim())
211
+ : [],
212
+ };
213
+ }
214
+ function parse$1(v) {
215
+ return v ? v.split(",").map(s => s.trim()) : [];
216
+ }
14
217
 
15
218
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
16
219
 
@@ -3219,14 +3422,14 @@ var fecha = {
3219
3422
  };
3220
3423
 
3221
3424
  var fecha$1 = /*#__PURE__*/Object.freeze({
3222
- __proto__: null,
3223
- assign: assign,
3224
- default: fecha,
3225
- defaultI18n: defaultI18n,
3226
- format: format$1,
3227
- parse: parse,
3228
- setGlobalDateI18n: setGlobalDateI18n,
3229
- setGlobalDateMasks: setGlobalDateMasks
3425
+ __proto__: null,
3426
+ assign: assign,
3427
+ default: fecha,
3428
+ defaultI18n: defaultI18n,
3429
+ format: format$1,
3430
+ parse: parse,
3431
+ setGlobalDateI18n: setGlobalDateI18n,
3432
+ setGlobalDateMasks: setGlobalDateMasks
3230
3433
  });
3231
3434
 
3232
3435
  var require$$0 = /*@__PURE__*/getAugmentedNamespace(fecha$1);
@@ -14460,137 +14663,70 @@ var container = class Container {
14460
14663
  warn.forProperties(exports$1, 'deprecated', ['emitErrs', 'levelLength']);
14461
14664
  } (winston));
14462
14665
 
14463
- /** ---------------------------------------------------------
14464
- * Detect Environment
14465
- * --------------------------------------------------------- */
14466
- const IS_BROWSER = typeof window !== "undefined" &&
14467
- typeof window.document !== "undefined";
14468
- const IS_NODE = typeof process !== "undefined" &&
14469
- process.release?.name === "node";
14470
-
14471
- function getLogConfig() {
14472
- return {
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
- showDetailslist: process.env.LOG_DETAILS_ALLOWLIST
14478
- ? process.env.LOG_DETAILS_ALLOWLIST.split(",").map(s => s.trim())
14479
- : [],
14480
- functionAllowlist: process.env.LOG_FUNCTION_ALLOWLIST
14481
- ? process.env.LOG_FUNCTION_ALLOWLIST.split(",").map(s => s.trim())
14482
- : [],
14483
- functionBlocklist: process.env.LOG_FUNCTION_BLOCKLIST
14484
- ? process.env.LOG_FUNCTION_BLOCKLIST.split(",").map(s => s.trim())
14485
- : [],
14486
- };
14487
- }
14488
-
14666
+ /* ------------------------------------------------------------------ */
14667
+ /* Winston logger (Node only) */
14668
+ /* ------------------------------------------------------------------ */
14489
14669
  console.log("ENV CHECK:", {
14490
14670
  LOG_SHOW_DETAILS: process.env.LOG_SHOW_DETAILS,
14491
14671
  LOG_DETAILS_ALLOWLIST: process.env.LOG_DETAILS_ALLOWLIST,
14492
14672
  });
14493
- let nodeLogger = null;
14494
- if (IS_NODE) {
14495
- nodeLogger = winston.createLogger({
14496
- level: "info",
14497
- format: winston.format.combine(winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), winston.format.errors({ stack: true }), winston.format.printf(({ timestamp, level, message, stack }) => {
14498
- return `${timestamp} [${level}] ${message}${stack ? "\n" + stack : ""}`;
14499
- })),
14500
- transports: [
14501
- new winston.transports.Console(),
14502
- new winston.transports.File({ filename: "logs/error.log", level: "error" }),
14503
- new winston.transports.File({ filename: "logs/combined.log" }),
14504
- ],
14505
- });
14506
- }
14507
- function shouldCondense(logType) {
14508
- const LOG_CONFIG = getLogConfig();
14509
- if (LOG_CONFIG.expandOnDebug && logType === "debug") {
14510
- return false;
14673
+ function getNodeLogger() {
14674
+ let nodeLogger = null;
14675
+ if (IS_NODE) {
14676
+ nodeLogger = winston.createLogger({
14677
+ level: "info",
14678
+ format: winston.format.combine(winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), winston.format.errors({ stack: true }), winston.format.printf(({ timestamp, level, message, stack }) => {
14679
+ return `${timestamp} [${level}] ${message}${stack ? "\n" + stack : ""}`;
14680
+ })),
14681
+ transports: [
14682
+ new winston.transports.Console(),
14683
+ new winston.transports.File({ filename: "logs/error.log", level: "error" }),
14684
+ new winston.transports.File({ filename: "logs/combined.log" }),
14685
+ ],
14686
+ });
14511
14687
  }
14512
- return LOG_CONFIG.condensed;
14688
+ return nodeLogger;
14513
14689
  }
14514
- function shouldShowDetails(logType) {
14515
- const cfg = getLogConfig();
14516
- if (cfg.showDetailslist.length > 0) {
14517
- return cfg.showDetailslist.includes(logType);
14690
+ const logger = getNodeLogger();
14691
+ function getFinalLine(line, finalLogType, resolvedLoggerInput) {
14692
+ // ---------------- Browser ----------------
14693
+ if (IS_BROWSER) {
14694
+ console[finalLogType === "error"
14695
+ ? "error"
14696
+ : finalLogType === "warn"
14697
+ ? "warn"
14698
+ : finalLogType === "debug"
14699
+ ? "debug"
14700
+ : "log"](line);
14701
+ return line;
14518
14702
  }
14519
- return cfg.showDetails;
14520
- }
14521
- /** Exported logger */
14522
- const logger = nodeLogger;
14523
- /**
14524
- * Normalizes inputs by treating "unknown" and empty values as null.
14525
- * Returns "unknown" ONLY if all inputs are invalid.
14526
- */
14527
- function resolveValue(...values) {
14528
- let sawInput = false;
14529
- for (const value of values) {
14530
- if (value === undefined || value === null)
14531
- continue;
14532
- sawInput = true;
14533
- if (typeof value === "string") {
14534
- const v = value.trim();
14535
- if (!v || v.toLowerCase() === "unknown")
14536
- continue;
14537
- return value;
14538
- }
14539
- return value;
14703
+ // ---------------- Node ----------------
14704
+ const activeLogger = resolveLogger(resolvedLoggerInput);
14705
+ if (!activeLogger) {
14706
+ console.log(line);
14707
+ return line;
14540
14708
  }
14541
- return sawInput ? "unknown" : "unknown";
14542
- }
14543
- /* ------------------------------------------------------------------ */
14544
- /* Stack inspection */
14545
- /* ------------------------------------------------------------------ */
14546
- function padRight(str, width) {
14547
- return str.length >= width ? str : str + " ".repeat(width - str.length);
14548
- }
14549
- const COLS = {
14550
- timestamp: 24,
14551
- file: 16,
14552
- };
14553
- /* ------------------------------------------------------------------ */
14554
- /* Stack inspection */
14555
- /* ------------------------------------------------------------------ */
14556
- function extractFile(frame) {
14557
- // file:///path/to/file.ts:line:col
14558
- const esmMatch = frame.match(/file:\/\/(.+?):\d+:\d+/);
14559
- if (esmMatch)
14560
- return esmMatch[1];
14561
- // (path/to/file.ts:line:col)
14562
- const cjsMatch = frame.match(/\((.+?):\d+:\d+\)/);
14563
- if (cjsMatch)
14564
- return cjsMatch[1];
14565
- // at path/to/file.ts:line:col
14566
- const bareMatch = frame.match(/at\s+(.+?):\d+:\d+/);
14567
- if (bareMatch)
14568
- return bareMatch[1];
14569
- return "unknown";
14570
- }
14571
- function getCallerInfo() {
14572
- if (!IS_NODE) {
14573
- return { functionName: "browser", file: "browser" };
14709
+ try {
14710
+ switch (finalLogType) {
14711
+ case "error":
14712
+ activeLogger.error(line);
14713
+ break;
14714
+ case "warn":
14715
+ activeLogger.warn(line);
14716
+ break;
14717
+ case "debug":
14718
+ activeLogger.debug(line);
14719
+ break;
14720
+ default:
14721
+ activeLogger.info(line);
14722
+ }
14574
14723
  }
14575
- const obj = {};
14576
- Error.captureStackTrace(obj, getLogString);
14577
- const stack = obj.stack?.split("\n") ?? [];
14578
- const frame = stack
14579
- .slice(1)
14580
- .find((line) => !line.includes("node:internal") &&
14581
- !line.includes("processTicksAndRejections"));
14582
- if (!frame) {
14583
- return { functionName: "unknown", file: "unknown" };
14724
+ catch {
14725
+ console.log(line);
14584
14726
  }
14585
- const fnMatch = frame.match(/at\s+async\s+([^\s(]+)/) ||
14586
- frame.match(/at\s+([^\s(]+)/);
14587
- return {
14588
- functionName: fnMatch?.[1] && fnMatch[1] !== "Object.<anonymous>"
14589
- ? fnMatch[1]
14590
- : "unknown",
14591
- file: extractFile(frame),
14592
- };
14727
+ return line;
14593
14728
  }
14729
+
14594
14730
  /* ------------------------------------------------------------------ */
14595
14731
  /* Safe logger resolver */
14596
14732
  /* ------------------------------------------------------------------ */
@@ -14607,7 +14743,22 @@ function resolveLogger(candidate) {
14607
14743
  }
14608
14744
  return null;
14609
14745
  }
14610
- function serializeDetails(value, condensed, maxLength) {
14746
+ function shouldCondense(logType) {
14747
+ const LOG_CONFIG = getLogConfig();
14748
+ if (LOG_CONFIG.expandOnDebug && logType === "debug") {
14749
+ return false;
14750
+ }
14751
+ return LOG_CONFIG.condensed;
14752
+ }
14753
+ function shouldShowDetails(logType) {
14754
+ const cfg = getLogConfig();
14755
+ if (cfg.showDetailslist.length > 0) {
14756
+ return cfg.showDetailslist.includes(logType);
14757
+ }
14758
+ return cfg.showDetails;
14759
+ }
14760
+ function serializeDetails(value, condensed, maxLength, pretty // ๐Ÿ‘ˆ new
14761
+ ) {
14611
14762
  try {
14612
14763
  const seen = new WeakSet();
14613
14764
  const json = JSON.stringify(value, (key, val) => {
@@ -14621,7 +14772,8 @@ function serializeDetails(value, condensed, maxLength) {
14621
14772
  seen.add(val);
14622
14773
  }
14623
14774
  return val;
14624
- }, condensed ? 0 : 2);
14775
+ }, pretty && !condensed ? 2 : 0 // ๐Ÿ‘ˆ HERE
14776
+ );
14625
14777
  if (condensed && json.length > maxLength) {
14626
14778
  return json.slice(0, maxLength) + "โ€ฆ";
14627
14779
  }
@@ -14631,6 +14783,71 @@ function serializeDetails(value, condensed, maxLength) {
14631
14783
  return "[unserializable details]";
14632
14784
  }
14633
14785
  }
14786
+ function formatLogLine({ emoji, timestamp, functionName, message, details, file, condense, maxDetailsLength, pretty }) {
14787
+ let line = `${padRight(emoji, 3)}` +
14788
+ `[${padRight(timestamp, COLS.timestamp)}] ` +
14789
+ `[${functionName}] ` +
14790
+ `${message}`;
14791
+ if (details !== undefined) {
14792
+ const serialized = serializeDetails(details, condense, maxDetailsLength, pretty);
14793
+ line += ` | ${serialized}`;
14794
+ }
14795
+ line += ` | ${padRight(file, COLS.file)}`;
14796
+ return line;
14797
+ }
14798
+
14799
+ const seen = new Map();
14800
+ function hash(str) {
14801
+ let h = 0;
14802
+ for (let i = 0; i < str.length; i++) {
14803
+ h = (h << 5) - h + str.charCodeAt(i);
14804
+ h |= 0;
14805
+ }
14806
+ return Math.abs(h);
14807
+ }
14808
+ function shouldLog(opts, caller) {
14809
+ const cfg = getLogConfig();
14810
+ const fn = caller.functionName;
14811
+ const type = opts.logType ?? "info";
14812
+ const activity = opts.activity;
14813
+ const message = opts.message;
14814
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
14815
+ // 1๏ธโƒฃ Hard allowlist (strongest gate)
14816
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
14817
+ if (cfg.functionAllowlist.length > 0) {
14818
+ if (!cfg.functionAllowlist.includes(fn))
14819
+ return false;
14820
+ }
14821
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
14822
+ // 2๏ธโƒฃ Hard blocklists
14823
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
14824
+ if (cfg.functionBlocklist.includes(fn))
14825
+ return false;
14826
+ if (activity && cfg.activityBlocklist.includes(activity))
14827
+ return false;
14828
+ if (cfg.logTypeBlocklist.includes(type))
14829
+ return false;
14830
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
14831
+ // 3๏ธโƒฃ Burst protection (debug spam)
14832
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
14833
+ if (type === "debug") {
14834
+ const key = fn + ":" + message;
14835
+ const count = (seen.get(key) ?? 0) + 1;
14836
+ seen.set(key, count);
14837
+ if (count > 5)
14838
+ return false; // drop after 5 identical logs
14839
+ }
14840
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
14841
+ // 4๏ธโƒฃ Deterministic sampling
14842
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
14843
+ if (cfg.sampleRate < 1) {
14844
+ const pct = (hash(fn) % 100) / 100;
14845
+ if (pct > cfg.sampleRate)
14846
+ return false;
14847
+ }
14848
+ return true;
14849
+ }
14850
+
14634
14851
  /* ------------------------------------------------------------------ */
14635
14852
  /* IMPLEMENTATION */
14636
14853
  /* ------------------------------------------------------------------ */
@@ -14654,154 +14871,44 @@ function getLogString(messageOrOptions, logType = null, details = null, function
14654
14871
  }
14655
14872
  let { message, logType: resolvedLogType, details: resolvedDetails, function_name: resolvedFunctionName, file_location: resolvedFileLocation, consumerLogger: resolvedLoggerInput, } = opts;
14656
14873
  // ---------------- Resolve caller info ----------------
14657
- const { functionName, file } = getCallerInfo();
14658
- // ---------------- Resolve caller info ----------------
14659
- if (!resolvedFunctionName || resolvedFunctionName === "unknown") {
14660
- const { functionName } = getCallerInfo();
14661
- resolvedFunctionName = resolveValue(functionName, resolvedFunctionName);
14662
- }
14663
- if (!resolvedFileLocation || resolvedFileLocation === "unknown") {
14664
- const { file } = getCallerInfo();
14665
- resolvedFileLocation = resolveValue(file, resolvedFileLocation);
14874
+ const caller = getCallerInfo(getLogString);
14875
+ if (!shouldLog(opts, caller)) {
14876
+ return ""; // ๐Ÿ”• blocked โ€” nothing emitted
14666
14877
  }
14667
- const emojiMap = {
14668
- emitting: "๐Ÿ“ค",
14669
- ingesting: "๐Ÿ“ฅ",
14670
- streaming: "๐ŸŒŠ",
14671
- forwarding: "โžก๏ธ",
14672
- receiving: "๐Ÿ“ก",
14673
- relaying: "๐Ÿ”",
14674
- syncing: "๐Ÿ”„",
14675
- buffering: "โณ",
14676
- batching: "๐Ÿ“ฆ",
14677
- dispatching: "๐Ÿš€",
14678
- settings: "โš™๏ธ",
14679
- computing: "๐Ÿง ",
14680
- running: "๐Ÿƒ",
14681
- working: "๐Ÿ”ง",
14682
- building: "๐Ÿ—๏ธ",
14683
- compiling: "๐Ÿงฉ",
14684
- crunching: "๐Ÿงฎ",
14685
- optimizing: "๐Ÿ“ˆ",
14686
- queued: "๐Ÿ•’",
14687
- waiting: "โณ",
14688
- active: "โ–ถ๏ธ",
14689
- paused: "โธ๏ธ",
14690
- sleeping: "๐Ÿ’ค",
14691
- resumed: "๐Ÿ”„",
14692
- completed: "โœ…",
14693
- cancelled: "โŒ",
14694
- expired: "โŒ›",
14695
- warning: "โš ๏ธ",
14696
- error: "โŒ",
14697
- critical: "๐Ÿšจ",
14698
- retrying: "๐Ÿ”",
14699
- skipped: "โญ๏ธ",
14700
- fallback: "๐Ÿ›Ÿ",
14701
- degraded: "๐Ÿ“‰",
14702
- saved: "๐Ÿ’พ",
14703
- loading: "๐Ÿ“‚",
14704
- exporting: "๐Ÿ“ค",
14705
- importing: "๐Ÿ“ฅ",
14706
- archived: "๐Ÿ—„๏ธ",
14707
- deleted: "๐Ÿ—‘๏ธ",
14708
- cached: "๐ŸงŠ",
14709
- persisted: "๐Ÿ“Œ",
14710
- locked: "๐Ÿ”’",
14711
- unlocked: "๐Ÿ”“",
14712
- secure: "๐Ÿ›ก๏ธ",
14713
- insecure: "โš ๏ธ",
14714
- verified: "โœ”๏ธ",
14715
- blocked: "โ›”",
14716
- allowed: "๐ŸŸข",
14717
- connected: "๐Ÿ”—",
14718
- disconnected: "โŒ",
14719
- online: "๐ŸŸข",
14720
- offline: "๐Ÿ”ด",
14721
- latency: "๐Ÿ“ถ",
14722
- proxying: "๐Ÿงญ",
14723
- broadcasting: "๐Ÿ“ฃ",
14724
- thinking: "๐Ÿค”",
14725
- learning: "๐Ÿง ",
14726
- predicting: "๐Ÿ”ฎ",
14727
- scanning: "๐Ÿ”",
14728
- crawling: "๐Ÿ•ท๏ธ",
14729
- responding: "๐Ÿ’ฌ",
14730
- generating: "โœจ",
14731
- debug: "๐Ÿž",
14732
- trace: "๐Ÿงต",
14733
- inspect: "๐Ÿ”Ž",
14734
- test: "๐Ÿงช",
14735
- mock: "๐ŸŽญ",
14736
- sandbox: "๐Ÿ–๏ธ",
14737
- experiment: "โš—๏ธ",
14738
- success: "โœ…",
14739
- processing: "๐Ÿ”„",
14740
- listening: "๐Ÿ“ก",
14741
- prune: "๐Ÿงน",
14742
- connect: "๐Ÿ”Œ",
14743
- info: "โ„น๏ธ",
14744
- warn: "โš ๏ธ"
14745
- };
14878
+ // ---------------- Resolve caller info ----------------
14879
+ resolvedFunctionName = resolveValue(resolvedFunctionName, caller.functionName);
14880
+ resolvedFileLocation = resolveValue(resolvedFileLocation, caller.file);
14746
14881
  const finalLogType = resolvedLogType ?? "info";
14747
- const emoji = emojiMap[finalLogType] ?? "โ„น๏ธ";
14748
- const timestamp = new Date().toISOString();
14882
+ const emoji = activityEmojiMap[opts.activity ?? ""] ??
14883
+ "โ„น๏ธ";
14884
+ const LOG_CONFIG = getLogConfig();
14749
14885
  const condense = shouldCondense(finalLogType);
14750
14886
  const showDetails = shouldShowDetails(finalLogType);
14887
+ // ๐Ÿ‘‡ ADD THIS
14888
+ const pretty = LOG_CONFIG.prettyDetails &&
14889
+ !condense;
14890
+ const timestamp = new Date().toISOString();
14751
14891
  if (condense) {
14752
14892
  resolvedFileLocation = resolvedFileLocation.split("/").pop();
14753
14893
  }
14754
- const emojiCol = padRight(emoji, 3);
14755
- const ts = padRight(timestamp, COLS.timestamp);
14756
- const fn = resolvedFunctionName;
14757
- const fileName = padRight(resolvedFileLocation.trim(), COLS.file);
14758
- let line = `${emojiCol}` +
14759
- `[${ts}] ` +
14760
- `[${fn}] ` +
14761
- `${message}`;
14894
+ padRight(emoji, 3);
14895
+ padRight(timestamp, COLS.timestamp);
14896
+ padRight(resolvedFileLocation.trim(), COLS.file);
14762
14897
  if (showDetails && resolvedDetails !== null && resolvedDetails !== undefined) {
14763
- const LOG_CONFIG = getLogConfig();
14764
- const serialized = serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength);
14765
- line += ` | ${serialized}`;
14898
+ serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength, pretty);
14766
14899
  }
14767
- line += ` | ${fileName}`;
14768
- // ---------------- Browser ----------------
14769
- if (IS_BROWSER) {
14770
- console[finalLogType === "error"
14771
- ? "error"
14772
- : finalLogType === "warn"
14773
- ? "warn"
14774
- : finalLogType === "debug"
14775
- ? "debug"
14776
- : "log"](line);
14777
- return line;
14778
- }
14779
- // ---------------- Node ----------------
14780
- const activeLogger = resolveLogger(resolvedLoggerInput);
14781
- if (!activeLogger) {
14782
- console.log(line);
14783
- return line;
14784
- }
14785
- try {
14786
- switch (finalLogType) {
14787
- case "error":
14788
- activeLogger.error(line);
14789
- break;
14790
- case "warn":
14791
- activeLogger.warn(line);
14792
- break;
14793
- case "debug":
14794
- activeLogger.debug(line);
14795
- break;
14796
- default:
14797
- activeLogger.info(line);
14798
- }
14799
- }
14800
- catch {
14801
- console.log(line);
14802
- }
14803
- return line;
14900
+ return getFinalLine(formatLogLine({
14901
+ emoji,
14902
+ timestamp,
14903
+ functionName: resolvedFunctionName,
14904
+ message,
14905
+ details: showDetails ? resolvedDetails : undefined,
14906
+ file: resolvedFileLocation,
14907
+ condense,
14908
+ maxDetailsLength: LOG_CONFIG.maxDetailsLength,
14909
+ pretty, // ๐Ÿ‘ˆ THIS IS THE MISSING WIRE
14910
+ }), finalLogType, resolvedLoggerInput);
14804
14911
  }
14805
14912
 
14806
- export { IS_BROWSER, IS_NODE, getLogConfig, getLogString, logger, resolveValue, serializeDetails };
14913
+ export { COLS, IS_BROWSER, IS_NODE, activityEmojiMap, extractFile, formatLogLine, getCallerInfo, getFinalLine, getLogConfig, getLogString, getNodeLogger, logger, padLeft, padRight, parseList, resolveLogger, resolveValue, serializeDetails, shouldCondense, shouldShowDetails };
14807
14914
  //# sourceMappingURL=index.js.map