analogger 2.11.0 → 2.12.1

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)_ |
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(): {
@@ -337,6 +338,10 @@ declare class ____AnaLogger {
337
338
  * anaLogger.resetMaxSeen(); // reset every lid counter
338
339
  */
339
340
  resetMaxSeen(lids: string | string[]): string[];
341
+ /**
342
+ * Reset the breadcrumb history so the trail starts fresh.
343
+ */
344
+ resetBreadcrumb(): void;
340
345
  /**
341
346
  * Print a summary of all test results collected via the "test" context option.
342
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];
@@ -2716,6 +2723,68 @@ class ____AnaLogger
2716
2723
  return reset;
2717
2724
  }
2718
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
+
2719
2788
  /**
2720
2789
  * Evaluate the "test" context option and record the result.
2721
2790
  * - If test is a function, it is called with no arguments and its return value is used.
@@ -2953,6 +3022,16 @@ class ____AnaLogger
2953
3022
  }
2954
3023
  this.applySymbolByName(context);
2955
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
+
2956
3035
  this.checkOnLogging(context, context, argsWithoutContext, "onContext");
2957
3036
  if (!this.isTargetAllowed(context.target))
2958
3037
  {
@@ -3053,12 +3132,12 @@ class ____AnaLogger
3053
3132
  return;
3054
3133
  }
3055
3134
 
3056
- if (this.options.logToRemote)
3135
+ if (this.options.logToRemote && context.logToRemote !== false)
3057
3136
  {
3058
3137
  this.writeLogToRemote(context, ...args);
3059
3138
  }
3060
3139
 
3061
- if (this.options.logToLocalStorage)
3140
+ if (this.options.logToLocalStorage && context.logToLocalStorage !== false)
3062
3141
  {
3063
3142
  this.writeLogToLocalStorage(context, ...args);
3064
3143
  }
@@ -3068,7 +3147,7 @@ class ____AnaLogger
3068
3147
  {
3069
3148
  context.environnment = ____AnaLogger.ENVIRONMENT_TYPE.BROWSER;
3070
3149
  /* istanbul ignore next */
3071
- if (this.options.logToDom)
3150
+ if (this.options.logToDom && context.logToDom !== false)
3072
3151
  {
3073
3152
  /* istanbul ignore next */
3074
3153
  this.writeLogToDom(context, text, {message, args,});
@@ -3087,7 +3166,7 @@ class ____AnaLogger
3087
3166
  isReversed : context.reversed
3088
3167
  });
3089
3168
 
3090
- if (this.options.logToFile)
3169
+ if (this.options.logToFile && context.logToFile !== false)
3091
3170
  {
3092
3171
  this.writeLogToFile(text);
3093
3172
  }