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 +1 -0
- package/ana-logger.d.cts +6 -1
- package/browser/ana-logger.mjs +84 -5
- package/dist/analogger-browser.min.mjs +15 -15
- package/dist/html-to-image-plugin.min.mjs +15 -15
- package/esm/ana-logger.mjs +84 -5
- package/package.json +1 -1
- package/src/ana-logger.cjs +84 -5
package/src/ana-logger.cjs
CHANGED
|
@@ -734,6 +734,10 @@ class ____AnaLogger
|
|
|
734
734
|
// Accumulates test results recorded by the "test" context option.
|
|
735
735
|
// Each entry is { lid, passed, message }.
|
|
736
736
|
this._testResults = [];
|
|
737
|
+
|
|
738
|
+
// Ordered list of lid values seen so far.
|
|
739
|
+
// Used by the "breadcrumb" context option to print the history path.
|
|
740
|
+
this._breadcrumbHistory = [];
|
|
737
741
|
}
|
|
738
742
|
|
|
739
743
|
getName()
|
|
@@ -980,6 +984,7 @@ class ____AnaLogger
|
|
|
980
984
|
this.options.logToRemoteMaxSize = undefined;
|
|
981
985
|
this.options.logToRemoteMinSize = undefined;
|
|
982
986
|
this.options.logUidToRemote = undefined;
|
|
987
|
+
this.options.keepBreadcrumb = false;
|
|
983
988
|
this.remoteBuffer = [];
|
|
984
989
|
this.remoteTimer = null;
|
|
985
990
|
this.remoteWaitCount = 0;
|
|
@@ -1035,7 +1040,8 @@ class ____AnaLogger
|
|
|
1035
1040
|
port = undefined,
|
|
1036
1041
|
pathname = undefined,
|
|
1037
1042
|
binarypathname = undefined,
|
|
1038
|
-
loadHtmlToImage = false
|
|
1043
|
+
loadHtmlToImage = false,
|
|
1044
|
+
keepBreadcrumb = undefined
|
|
1039
1045
|
} = null)
|
|
1040
1046
|
{
|
|
1041
1047
|
this.options.contextLenMax = contextLenMax;
|
|
@@ -1105,6 +1111,7 @@ class ____AnaLogger
|
|
|
1105
1111
|
{logToRemote},
|
|
1106
1112
|
{logToLocalStorage},
|
|
1107
1113
|
{logUidToRemote},
|
|
1114
|
+
{keepBreadcrumb},
|
|
1108
1115
|
].forEach((feature) =>
|
|
1109
1116
|
{
|
|
1110
1117
|
const key = Object.keys(feature)[0];
|
|
@@ -2717,6 +2724,68 @@ class ____AnaLogger
|
|
|
2717
2724
|
return reset;
|
|
2718
2725
|
}
|
|
2719
2726
|
|
|
2727
|
+
/**
|
|
2728
|
+
* Reset the breadcrumb history so the trail starts fresh.
|
|
2729
|
+
*/
|
|
2730
|
+
resetBreadcrumb()
|
|
2731
|
+
{
|
|
2732
|
+
this._breadcrumbHistory = [];
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
/**
|
|
2736
|
+
* Handle the "breadcrumb" context option.
|
|
2737
|
+
*
|
|
2738
|
+
* When context.breadcrumb is true the method:
|
|
2739
|
+
* 1. Appends the current context.lid (if any) to the history.
|
|
2740
|
+
* 2. Prints the full trail as: lid1 => lid2 => ... => lidN
|
|
2741
|
+
* 3. Returns true to signal that normal log output should be skipped.
|
|
2742
|
+
*
|
|
2743
|
+
* For every other log call (no breadcrumb flag) the lid is silently
|
|
2744
|
+
* appended to the history so the trail always stays up-to-date.
|
|
2745
|
+
*
|
|
2746
|
+
* @param {object} context
|
|
2747
|
+
* @returns {boolean} true when the call was a breadcrumb display call.
|
|
2748
|
+
*/
|
|
2749
|
+
#handleBreadcrumb(context)
|
|
2750
|
+
{
|
|
2751
|
+
const lid = context.lid !== undefined && context.lid !== null && context.lid !== ""
|
|
2752
|
+
? String(context.lid)
|
|
2753
|
+
: null;
|
|
2754
|
+
|
|
2755
|
+
if (!context.breadcrumb)
|
|
2756
|
+
{
|
|
2757
|
+
// Regular log call — just record the lid if the feature is enabled.
|
|
2758
|
+
if (lid && this.options.keepBreadcrumb)
|
|
2759
|
+
{
|
|
2760
|
+
this._breadcrumbHistory.push(lid);
|
|
2761
|
+
}
|
|
2762
|
+
return false;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
// breadcrumb: true — append the current lid (if any) and print the trail.
|
|
2766
|
+
// Works even if keepBreadcrumb was just enabled: we record the current lid
|
|
2767
|
+
// so it at least appears in the trail.
|
|
2768
|
+
if (lid && this.options.keepBreadcrumb)
|
|
2769
|
+
{
|
|
2770
|
+
this._breadcrumbHistory.push(lid);
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
const trail = this._breadcrumbHistory.join(" => ") || "(empty)";
|
|
2774
|
+
const label = "Breadcrumb: ";
|
|
2775
|
+
|
|
2776
|
+
if (this.isBrowser())
|
|
2777
|
+
{
|
|
2778
|
+
____AnaLogger.Console.log(`%c${label}${trail}`, "color: #888; font-style: italic");
|
|
2779
|
+
}
|
|
2780
|
+
else
|
|
2781
|
+
{
|
|
2782
|
+
const styled = toAnsi.getTextFromColor(`${label}${trail}`, {fg: "#888888"});
|
|
2783
|
+
____AnaLogger.Console.log(styled);
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
return true;
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2720
2789
|
/**
|
|
2721
2790
|
* Evaluate the "test" context option and record the result.
|
|
2722
2791
|
* - If test is a function, it is called with no arguments and its return value is used.
|
|
@@ -2954,6 +3023,16 @@ class ____AnaLogger
|
|
|
2954
3023
|
}
|
|
2955
3024
|
this.applySymbolByName(context);
|
|
2956
3025
|
|
|
3026
|
+
// Handle the "breadcrumb" option — track lid history and, when
|
|
3027
|
+
// breadcrumb:true, print the trail then skip normal output.
|
|
3028
|
+
// Must run before any filtering (target, logLevel, only) so that:
|
|
3029
|
+
// a) lids are always recorded regardless of active filters, and
|
|
3030
|
+
// b) a breadcrumb display call is never silently suppressed.
|
|
3031
|
+
if (this.#handleBreadcrumb(context))
|
|
3032
|
+
{
|
|
3033
|
+
return;
|
|
3034
|
+
}
|
|
3035
|
+
|
|
2957
3036
|
this.checkOnLogging(context, context, argsWithoutContext, "onContext");
|
|
2958
3037
|
if (!this.isTargetAllowed(context.target))
|
|
2959
3038
|
{
|
|
@@ -3054,12 +3133,12 @@ class ____AnaLogger
|
|
|
3054
3133
|
return;
|
|
3055
3134
|
}
|
|
3056
3135
|
|
|
3057
|
-
if (this.options.logToRemote)
|
|
3136
|
+
if (this.options.logToRemote && context.logToRemote !== false)
|
|
3058
3137
|
{
|
|
3059
3138
|
this.writeLogToRemote(context, ...args);
|
|
3060
3139
|
}
|
|
3061
3140
|
|
|
3062
|
-
if (this.options.logToLocalStorage)
|
|
3141
|
+
if (this.options.logToLocalStorage && context.logToLocalStorage !== false)
|
|
3063
3142
|
{
|
|
3064
3143
|
this.writeLogToLocalStorage(context, ...args);
|
|
3065
3144
|
}
|
|
@@ -3069,7 +3148,7 @@ class ____AnaLogger
|
|
|
3069
3148
|
{
|
|
3070
3149
|
context.environnment = ____AnaLogger.ENVIRONMENT_TYPE.BROWSER;
|
|
3071
3150
|
/* istanbul ignore next */
|
|
3072
|
-
if (this.options.logToDom)
|
|
3151
|
+
if (this.options.logToDom && context.logToDom !== false)
|
|
3073
3152
|
{
|
|
3074
3153
|
/* istanbul ignore next */
|
|
3075
3154
|
this.writeLogToDom(context, text, {message, args,});
|
|
@@ -3088,7 +3167,7 @@ class ____AnaLogger
|
|
|
3088
3167
|
isReversed : context.reversed
|
|
3089
3168
|
});
|
|
3090
3169
|
|
|
3091
|
-
if (this.options.logToFile)
|
|
3170
|
+
if (this.options.logToFile && context.logToFile !== false)
|
|
3092
3171
|
{
|
|
3093
3172
|
this.writeLogToFile(text);
|
|
3094
3173
|
}
|