analogger 2.10.0 → 2.12.0

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/README.md CHANGED
@@ -397,6 +397,7 @@ Display the browser native message box if run from it; otherwise, it displays th
397
397
  | hideError | false | boolean | _Hide errors from console_ |
398
398
  | hideHookMessage | false | boolean | _Hide the automatic message shown when some native console methods are overridden_ |
399
399
  | hidePassingTests | false | boolean | _Hide Live test results_ |
400
+ | keepBreadcrumb | false | boolean | _Show brief history graph_ |
400
401
  | logToDom | false | string (DOM Selector) | _display log in a DOM container_ |
401
402
  | logToFile | false | string (File path) | _write log to a file if running from Node_ |
402
403
  | logToRemote | undefined | string (URL) | _Send log to a remote (more info in the next version)_ |
@@ -418,6 +419,7 @@ Display the browser native message box if run from it; otherwise, it displays th
418
419
  | addArchiveTimestamp | true | boolean | _Appends a consistent timestamp to rotated files_ |
419
420
  | forceLidOn | false | boolean | _Automatically generates a short hash LID if one isn't provided_ |
420
421
  | only | undefined | string/Regex/Array | Filter logs to show only those matching specific IDs or patterns |
422
+ | resetMaxSeen | undefined | array | Resets maxSeen counters |
421
423
  | resetOrder | undefined | boolean | Resets the internal tracking for the order sequence |
422
424
  | order | undefined | number | _Enforce call order — emits a console warning if a log with a lower order value appears after one with a higher value_ |
423
425
  | maxSeen | undefined | number | _Emits a console warning when the same lid is logged more times than this limit_ |
package/ana-logger.d.cts CHANGED
@@ -83,6 +83,7 @@ declare class ____AnaLogger {
83
83
  };
84
84
  _seenCount: {};
85
85
  _testResults: any[];
86
+ _breadcrumbHistory: any[];
86
87
  getName(): string;
87
88
  getId(): string;
88
89
  /**
@@ -131,7 +132,7 @@ declare class ____AnaLogger {
131
132
  resetLogger(): void;
132
133
  remoteWaitCount: any;
133
134
  resetOptions(): void;
134
- setOptions({ timeLenMax, contextLenMax, idLenMax, lidLenMax, only, symbolLenMax, enableTrace, messageLenMax, hideLog, hideError, hideHookMessage, hidePassingTests, logToDom, logToFile, logMaxSize, logMaxArchives, logIndexArchive, addArchiveTimestamp, addArchiveIndex, compressArchives, compressionLevel, logToRemote, logToRemoteUrl, logToRemoteBinaryUrl, loopback, requiredLogLevel, oneConsolePerContext, silent, enableDate, enableMillisec, logToLocalStorage, logToLocalStorageMax, logToLocalStorageSize, logToRemoteMaxEntries, logToRemoteDebounce, logToRemoteMaxSize, logToRemoteMinSize, logUidToRemote, protocol, host, port, pathname, binarypathname, loadHtmlToImage }?: any): void;
135
+ setOptions({ timeLenMax, contextLenMax, idLenMax, lidLenMax, only, symbolLenMax, enableTrace, messageLenMax, hideLog, hideError, hideHookMessage, hidePassingTests, logToDom, logToFile, logMaxSize, logMaxArchives, logIndexArchive, addArchiveTimestamp, addArchiveIndex, compressArchives, compressionLevel, logToRemote, logToRemoteUrl, logToRemoteBinaryUrl, loopback, requiredLogLevel, oneConsolePerContext, silent, enableDate, enableMillisec, logToLocalStorage, logToLocalStorageMax, logToLocalStorageSize, logToRemoteMaxEntries, logToRemoteDebounce, logToRemoteMaxSize, logToRemoteMinSize, logUidToRemote, protocol, host, port, pathname, binarypathname, loadHtmlToImage, keepBreadcrumb }?: any): void;
135
136
  EOL: string;
136
137
  updateOptions(options: any): void;
137
138
  getOptions(): {
@@ -323,6 +324,24 @@ declare class ____AnaLogger {
323
324
  * Resets the order tracking.
324
325
  */
325
326
  resetOrder(): void;
327
+ /**
328
+ * Reset the maxSeen counter for one or more lids so they can be logged
329
+ * up to their maxSeen limit again from scratch.
330
+ *
331
+ * @param {string|string[]} lids - A single lid string or an array of lid strings to reset.
332
+ * Pass nothing (or an empty array) to reset ALL lid counters.
333
+ * @returns {string[]} The list of lids that were actually reset.
334
+ *
335
+ * @example
336
+ * anaLogger.resetMaxSeen(["API_1"]); // reset one lid
337
+ * anaLogger.resetMaxSeen(["API_1", "API_3"]); // reset several lids
338
+ * anaLogger.resetMaxSeen(); // reset every lid counter
339
+ */
340
+ resetMaxSeen(lids: string | string[]): string[];
341
+ /**
342
+ * Reset the breadcrumb history so the trail starts fresh.
343
+ */
344
+ resetBreadcrumb(): void;
326
345
  /**
327
346
  * Print a summary of all test results collected via the "test" context option.
328
347
  * If any test failed the banner and counts are printed in bold red (Node) or
@@ -738,6 +738,10 @@ class ____AnaLogger
738
738
  // Accumulates test results recorded by the "test" context option.
739
739
  // Each entry is { lid, passed, message }.
740
740
  this._testResults = [];
741
+
742
+ // Ordered list of lid values seen so far.
743
+ // Used by the "breadcrumb" context option to print the history path.
744
+ this._breadcrumbHistory = [];
741
745
  }
742
746
 
743
747
  getName()
@@ -984,6 +988,7 @@ class ____AnaLogger
984
988
  this.options.logToRemoteMaxSize = undefined;
985
989
  this.options.logToRemoteMinSize = undefined;
986
990
  this.options.logUidToRemote = undefined;
991
+ this.options.keepBreadcrumb = false;
987
992
  this.remoteBuffer = [];
988
993
  this.remoteTimer = null;
989
994
  this.remoteWaitCount = 0;
@@ -1039,7 +1044,8 @@ class ____AnaLogger
1039
1044
  port = undefined,
1040
1045
  pathname = undefined,
1041
1046
  binarypathname = undefined,
1042
- loadHtmlToImage = false
1047
+ loadHtmlToImage = false,
1048
+ keepBreadcrumb = undefined
1043
1049
  } = null)
1044
1050
  {
1045
1051
  this.options.contextLenMax = contextLenMax;
@@ -1109,6 +1115,7 @@ class ____AnaLogger
1109
1115
  {logToRemote},
1110
1116
  {logToLocalStorage},
1111
1117
  {logUidToRemote},
1118
+ {keepBreadcrumb},
1112
1119
  ].forEach((feature) =>
1113
1120
  {
1114
1121
  const key = Object.keys(feature)[0];
@@ -2677,6 +2684,107 @@ class ____AnaLogger
2677
2684
  }
2678
2685
  }
2679
2686
 
2687
+ /**
2688
+ * Reset the maxSeen counter for one or more lids so they can be logged
2689
+ * up to their maxSeen limit again from scratch.
2690
+ *
2691
+ * @param {string|string[]} lids - A single lid string or an array of lid strings to reset.
2692
+ * Pass nothing (or an empty array) to reset ALL lid counters.
2693
+ * @returns {string[]} The list of lids that were actually reset.
2694
+ *
2695
+ * @example
2696
+ * anaLogger.resetMaxSeen(["API_1"]); // reset one lid
2697
+ * anaLogger.resetMaxSeen(["API_1", "API_3"]); // reset several lids
2698
+ * anaLogger.resetMaxSeen(); // reset every lid counter
2699
+ */
2700
+ resetMaxSeen(lids)
2701
+ {
2702
+ // Normalise: no argument → reset everything
2703
+ if (lids === undefined || lids === null)
2704
+ {
2705
+ const all = Object.keys(this._seenCount);
2706
+ this._seenCount = {};
2707
+ return all;
2708
+ }
2709
+
2710
+ // Accept a bare string as well as an array
2711
+ const targets = Array.isArray(lids) ? lids : [lids];
2712
+ const reset = [];
2713
+
2714
+ for (const lid of targets)
2715
+ {
2716
+ if (Object.prototype.hasOwnProperty.call(this._seenCount, lid))
2717
+ {
2718
+ delete this._seenCount[lid];
2719
+ reset.push(lid);
2720
+ }
2721
+ }
2722
+
2723
+ return reset;
2724
+ }
2725
+
2726
+ /**
2727
+ * Reset the breadcrumb history so the trail starts fresh.
2728
+ */
2729
+ resetBreadcrumb()
2730
+ {
2731
+ this._breadcrumbHistory = [];
2732
+ }
2733
+
2734
+ /**
2735
+ * Handle the "breadcrumb" context option.
2736
+ *
2737
+ * When context.breadcrumb is true the method:
2738
+ * 1. Appends the current context.lid (if any) to the history.
2739
+ * 2. Prints the full trail as: lid1 => lid2 => ... => lidN
2740
+ * 3. Returns true to signal that normal log output should be skipped.
2741
+ *
2742
+ * For every other log call (no breadcrumb flag) the lid is silently
2743
+ * appended to the history so the trail always stays up-to-date.
2744
+ *
2745
+ * @param {object} context
2746
+ * @returns {boolean} true when the call was a breadcrumb display call.
2747
+ */
2748
+ #handleBreadcrumb(context)
2749
+ {
2750
+ const lid = context.lid !== undefined && context.lid !== null && context.lid !== ""
2751
+ ? String(context.lid)
2752
+ : null;
2753
+
2754
+ if (!context.breadcrumb)
2755
+ {
2756
+ // Regular log call — just record the lid if the feature is enabled.
2757
+ if (lid && this.options.keepBreadcrumb)
2758
+ {
2759
+ this._breadcrumbHistory.push(lid);
2760
+ }
2761
+ return false;
2762
+ }
2763
+
2764
+ // breadcrumb: true — append the current lid (if any) and print the trail.
2765
+ // Works even if keepBreadcrumb was just enabled: we record the current lid
2766
+ // so it at least appears in the trail.
2767
+ if (lid && this.options.keepBreadcrumb)
2768
+ {
2769
+ this._breadcrumbHistory.push(lid);
2770
+ }
2771
+
2772
+ const trail = this._breadcrumbHistory.join(" => ") || "(empty)";
2773
+ const label = "Breadcrumb: ";
2774
+
2775
+ if (this.isBrowser())
2776
+ {
2777
+ ____AnaLogger.Console.log(`%c${label}${trail}`, "color: #888; font-style: italic");
2778
+ }
2779
+ else
2780
+ {
2781
+ const styled = toAnsi.getTextFromColor(`${label}${trail}`, {fg: "#888888"});
2782
+ ____AnaLogger.Console.log(styled);
2783
+ }
2784
+
2785
+ return true;
2786
+ }
2787
+
2680
2788
  /**
2681
2789
  * Evaluate the "test" context option and record the result.
2682
2790
  * - If test is a function, it is called with no arguments and its return value is used.
@@ -2914,6 +3022,16 @@ class ____AnaLogger
2914
3022
  }
2915
3023
  this.applySymbolByName(context);
2916
3024
 
3025
+ // Handle the "breadcrumb" option — track lid history and, when
3026
+ // breadcrumb:true, print the trail then skip normal output.
3027
+ // Must run before any filtering (target, logLevel, only) so that:
3028
+ // a) lids are always recorded regardless of active filters, and
3029
+ // b) a breadcrumb display call is never silently suppressed.
3030
+ if (this.#handleBreadcrumb(context))
3031
+ {
3032
+ return;
3033
+ }
3034
+
2917
3035
  this.checkOnLogging(context, context, argsWithoutContext, "onContext");
2918
3036
  if (!this.isTargetAllowed(context.target))
2919
3037
  {