analogger 1.29.3 → 1.29.4
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/ana-logger.d.cts +5 -16
- package/browser/ana-logger.mjs +38 -35
- package/dist/analogger-browser.min.mjs +4 -4
- package/dist/html-to-image-plugin.min.mjs +4 -4
- package/esm/ana-logger.mjs +37 -34
- package/package.json +1 -1
- package/src/ana-logger.cjs +38 -35
package/ana-logger.d.cts
CHANGED
|
@@ -6,6 +6,7 @@ declare const __AnaLogger: typeof ____AnaLogger;
|
|
|
6
6
|
*/
|
|
7
7
|
declare class ____AnaLogger {
|
|
8
8
|
static "__#1@#instances": any[];
|
|
9
|
+
static Console: any;
|
|
9
10
|
static ALIGN: {
|
|
10
11
|
LEFT: string;
|
|
11
12
|
RIGHT: string;
|
|
@@ -54,22 +55,10 @@ declare class ____AnaLogger {
|
|
|
54
55
|
originalFormatFunction: string;
|
|
55
56
|
errorTargetHandler: any;
|
|
56
57
|
errorUserTargetHandler: any;
|
|
57
|
-
rawLog:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
rawInfo: {
|
|
62
|
-
(...data: any[]): void;
|
|
63
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
64
|
-
};
|
|
65
|
-
rawWarn: {
|
|
66
|
-
(...data: any[]): void;
|
|
67
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
68
|
-
};
|
|
69
|
-
rawError: {
|
|
70
|
-
(...data: any[]): void;
|
|
71
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
72
|
-
};
|
|
58
|
+
rawLog: any;
|
|
59
|
+
rawInfo: any;
|
|
60
|
+
rawWarn: any;
|
|
61
|
+
rawError: any;
|
|
73
62
|
ALIGN: {
|
|
74
63
|
LEFT: string;
|
|
75
64
|
RIGHT: string;
|
package/browser/ana-logger.mjs
CHANGED
|
@@ -420,20 +420,13 @@ class ____AnaLogger
|
|
|
420
420
|
hideHookMessage: false
|
|
421
421
|
};
|
|
422
422
|
|
|
423
|
-
|
|
424
|
-
#realConsoleInfo = console.info;
|
|
425
|
-
#realConsoleWarn = console.warn;
|
|
426
|
-
#realConsoleError = console.error;
|
|
427
|
-
#realConsoleDebug = console.debug;
|
|
428
|
-
#realConsoleTable = console.table;
|
|
423
|
+
static Console = null;
|
|
429
424
|
|
|
430
425
|
#overridenMap = {
|
|
431
426
|
log : false,
|
|
432
427
|
info : false,
|
|
433
428
|
warn : false,
|
|
434
429
|
error: false,
|
|
435
|
-
debug: false,
|
|
436
|
-
table: false,
|
|
437
430
|
};
|
|
438
431
|
|
|
439
432
|
static ALIGN = {
|
|
@@ -472,10 +465,21 @@ class ____AnaLogger
|
|
|
472
465
|
|
|
473
466
|
this.setOptions(this.options);
|
|
474
467
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
468
|
+
if (!____AnaLogger.Console) {
|
|
469
|
+
____AnaLogger.Console = {
|
|
470
|
+
log: console.log,
|
|
471
|
+
info: console.info,
|
|
472
|
+
warn: console.warn,
|
|
473
|
+
error: console.error,
|
|
474
|
+
debug: console.debug,
|
|
475
|
+
table: console.table
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
this.rawLog = ____AnaLogger.Console.log;
|
|
480
|
+
this.rawInfo = ____AnaLogger.Console.info;
|
|
481
|
+
this.rawWarn = ____AnaLogger.Console.warn;
|
|
482
|
+
this.rawError = ____AnaLogger.Console.error;
|
|
479
483
|
|
|
480
484
|
this.ALIGN = ____AnaLogger.ALIGN;
|
|
481
485
|
this.ENVIRONMENT_TYPE = ____AnaLogger.ENVIRONMENT_TYPE;
|
|
@@ -774,7 +778,7 @@ class ____AnaLogger
|
|
|
774
778
|
|
|
775
779
|
}
|
|
776
780
|
|
|
777
|
-
|
|
781
|
+
____AnaLogger.Console.log("LogToFile is not supported in this environment. ")
|
|
778
782
|
|
|
779
783
|
}
|
|
780
784
|
|
|
@@ -1757,23 +1761,23 @@ class ____AnaLogger
|
|
|
1757
1761
|
const contextLevel = context.contextLevel || DEFAULT_LOG_LEVELS.LOG;
|
|
1758
1762
|
if (contextLevel >= DEFAULT_LOG_LEVELS.ERROR)
|
|
1759
1763
|
{
|
|
1760
|
-
|
|
1764
|
+
____AnaLogger.Console.error(...res);
|
|
1761
1765
|
}
|
|
1762
1766
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.WARN)
|
|
1763
1767
|
{
|
|
1764
|
-
|
|
1768
|
+
____AnaLogger.Console.warn(...res);
|
|
1765
1769
|
}
|
|
1766
1770
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.INFO)
|
|
1767
1771
|
{
|
|
1768
|
-
|
|
1772
|
+
____AnaLogger.Console.info(...res);
|
|
1769
1773
|
}
|
|
1770
1774
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.LOG)
|
|
1771
1775
|
{
|
|
1772
|
-
|
|
1776
|
+
____AnaLogger.Console.log(...res);
|
|
1773
1777
|
}
|
|
1774
1778
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.DEBUG)
|
|
1775
1779
|
{
|
|
1776
|
-
|
|
1780
|
+
____AnaLogger.Console.debug(...res);
|
|
1777
1781
|
}
|
|
1778
1782
|
|
|
1779
1783
|
}
|
|
@@ -2124,7 +2128,7 @@ class ____AnaLogger
|
|
|
2124
2128
|
|
|
2125
2129
|
if (context.raw)
|
|
2126
2130
|
{
|
|
2127
|
-
|
|
2131
|
+
____AnaLogger.Console.log(...args);
|
|
2128
2132
|
return;
|
|
2129
2133
|
}
|
|
2130
2134
|
|
|
@@ -2160,7 +2164,7 @@ class ____AnaLogger
|
|
|
2160
2164
|
{
|
|
2161
2165
|
if (!this.options.hideHookMessage)
|
|
2162
2166
|
{
|
|
2163
|
-
|
|
2167
|
+
____AnaLogger.Console.log("AnaLogger: Hook placed on console.error");
|
|
2164
2168
|
}
|
|
2165
2169
|
this.#overridenMap.error = true;
|
|
2166
2170
|
console.error = this.onDisplayError.bind(this);
|
|
@@ -2170,12 +2174,12 @@ class ____AnaLogger
|
|
|
2170
2174
|
{
|
|
2171
2175
|
try
|
|
2172
2176
|
{
|
|
2173
|
-
console.rawLog =
|
|
2174
|
-
console.raw =
|
|
2177
|
+
console.rawLog = ____AnaLogger.Console.log;
|
|
2178
|
+
console.raw = ____AnaLogger.Console.log;
|
|
2175
2179
|
|
|
2176
|
-
console.rawInfo =
|
|
2177
|
-
console.rawWarn =
|
|
2178
|
-
console.rawError =
|
|
2180
|
+
console.rawInfo = ____AnaLogger.Console.info;
|
|
2181
|
+
console.rawWarn = ____AnaLogger.Console.warn;
|
|
2182
|
+
console.rawError = ____AnaLogger.Console.error;
|
|
2179
2183
|
|
|
2180
2184
|
console.logHistory = this.logHistory;
|
|
2181
2185
|
|
|
@@ -2202,7 +2206,7 @@ class ____AnaLogger
|
|
|
2202
2206
|
{
|
|
2203
2207
|
if (!this.options.hideHookMessage)
|
|
2204
2208
|
{
|
|
2205
|
-
|
|
2209
|
+
____AnaLogger.Console.log("AnaLogger: Hook placed on console.log");
|
|
2206
2210
|
}
|
|
2207
2211
|
|
|
2208
2212
|
[{log}, {info}, {warn},].forEach(function (methodObj)
|
|
@@ -2225,7 +2229,7 @@ class ____AnaLogger
|
|
|
2225
2229
|
|
|
2226
2230
|
removeOverrideError()
|
|
2227
2231
|
{
|
|
2228
|
-
console.error =
|
|
2232
|
+
console.error = ____AnaLogger.Console.error;
|
|
2229
2233
|
this.#overridenMap.error = false;
|
|
2230
2234
|
}
|
|
2231
2235
|
|
|
@@ -2233,19 +2237,19 @@ class ____AnaLogger
|
|
|
2233
2237
|
{
|
|
2234
2238
|
if (log)
|
|
2235
2239
|
{
|
|
2236
|
-
console.log =
|
|
2240
|
+
console.log = ____AnaLogger.Console.log;
|
|
2237
2241
|
this.#overridenMap.log = false;
|
|
2238
2242
|
}
|
|
2239
2243
|
|
|
2240
2244
|
if (info)
|
|
2241
2245
|
{
|
|
2242
|
-
console.info =
|
|
2246
|
+
console.info = ____AnaLogger.Console.info;
|
|
2243
2247
|
this.#overridenMap.info = false;
|
|
2244
2248
|
}
|
|
2245
2249
|
|
|
2246
2250
|
if (warn)
|
|
2247
2251
|
{
|
|
2248
|
-
console.warn =
|
|
2252
|
+
console.warn = ____AnaLogger.Console.warn;
|
|
2249
2253
|
this.#overridenMap.warn = false;
|
|
2250
2254
|
}
|
|
2251
2255
|
|
|
@@ -2270,13 +2274,13 @@ class ____AnaLogger
|
|
|
2270
2274
|
{
|
|
2271
2275
|
if (!this.#overridenMap.log)
|
|
2272
2276
|
{
|
|
2273
|
-
|
|
2277
|
+
____AnaLogger.Console.table(...args);
|
|
2274
2278
|
return;
|
|
2275
2279
|
}
|
|
2276
2280
|
|
|
2277
2281
|
const currentLog = console.log;
|
|
2278
|
-
console.log =
|
|
2279
|
-
|
|
2282
|
+
console.log = ____AnaLogger.Console.log;
|
|
2283
|
+
____AnaLogger.Console.table(...args);
|
|
2280
2284
|
console.log = currentLog;
|
|
2281
2285
|
}
|
|
2282
2286
|
|
|
@@ -2423,8 +2427,7 @@ class ____AnaLogger
|
|
|
2423
2427
|
|
|
2424
2428
|
static generateInstance()
|
|
2425
2429
|
{
|
|
2426
|
-
|
|
2427
|
-
return analogger;
|
|
2430
|
+
return new ____AnaLogger();
|
|
2428
2431
|
}
|
|
2429
2432
|
|
|
2430
2433
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,Z={airplane:"\u2708",anchor:"\u2693",arrow_backward:"\u25C0",arrow_double_up:"\u23EB",arrow_double_down:"\u23EC",arrow_forward:"\u25B6",arrow_lower_right:"\u2198",arrow_lower_left:"\u2199",arrow_right_hook:"\u21AA",arrow_up_down:"\u2195",arrow_upper_left:"\u2196",arrow_upper_right:"\u2197",ballot_box_with_check:"\u2611",biohazard:"\u2623",black_circle:"\u23FA",black_medium_small_square:"\u25FE",black_medium_square:"\u25FC",black_nib:"\u2712",black_small_square:"\u25AA",black_square:"\u23F9",chains:"\u26D3",check:"\u2714",chess_pawn:"\u265F",cloud_and_rain:"\u26C8",clubs:"\u2663",coffee:"\u2615",copyright:"\xA9",cross:"\u274C",diamonds:"\u2666",divisions_ign:"\u2797",double_triangle_right:"\u23ED",double_triangle_left:"\u23EE",email:"\u2709",eject:"\u23CF",exclamation_mark:"\u2757",fast_forward:"\u23E9",female_sign:"\u2640",fist:"\u270A",fuel_pump:"\u26FD",gear:"\u2699",hammer_and_pick:"\u2692",hand:"\u270B",hearts:"\u2665",infinity:"\u267E",information:"\u2139",left_right_arrow:"\u2194",leftwards_arrow_with_hook:"\u21A9",male_sign:"\u2642",minus_sign:"\u2796",no_entry:"\u26D4",partly_sunny:"\u26C5",pencil:"\u270F",phone:"\u260E",plus_sign:"\u2795",question:"\u2754",radioactive:"\u2622",raised_hand:"\u270B",recycle:"\u267B",registered:"\xAE",relaxed:"\u263A",rewind:"\u23EA",scissors:"\u2702",snowman:"\u2603",spades:"\u2660",sparkles:"\u2728",star:"\u2B50",sunny:"\u2600",tent:"\u26FA",trademark:"\u2122",triangle_with_vertical_bar:"\u23EF",umbrella:"\u2614",vertical_bars:"\u23F8",watch:"\u231A",white_frowning_face:"\u2639",white_medium_square:"\u25FB",white_medium_small_square:"\u25FD",white_small_square:"\u25AB",wheelchair:"\u267F",white_circle:"\u26AA",writing_hand:"\u270D"};function lt(n){try{let t=path.extname(n),o=path.basename(n,t),r=path.dirname(n),s=n.slice(0,n.length-t.length);return{extension:t,filePath:s,basename:o,dirname:r}}catch(t){console.error("FILEPATH_EXT_FAILURE: ",t.message)}return{extension:".log",filePath:n}}function ct(){return new Date().toISOString().replace(/:/g,"-").replace(/\./g,"-")}function ft(n,t,o,r,s,i,a){fs.readdir(n,(l,h)=>{if(l){a(l,null);return}let u=[],d=0,p=(y,A)=>{if(!fs.existsSync(y)){A(null,null);return}fs.unlink(y,M=>{M?console.error(`DELETION_FAILURE: Error deleting file ${y}: ${M}`):u.push(y),d++,d===h.length&&A(null,u)})},E=y=>{if(y.startsWith(t+".")&&y.endsWith(o+r)){let A=path.join(n,y);s&&ht(A,s,i),p(A,a)}else d++,d===h.length&&a(null,u)};h.length===0?a(null,u):h.forEach(E,i)})}function ht(n,t,o=1){try{if(!fs.existsSync(n))return;if(!fs.existsSync(t)){let s=fs.mkdtempSync(path.join(os.tmpdir(),"tar-gz-init-"));try{let i=path.join(s,path.basename(n));fs.copyFileSync(n,i),c({sync:!0,gzip:{level:o},file:t,cwd:s,portable:!0},[path.basename(n)])}finally{fs.rmSync(s,{recursive:!0,force:!0})}return}let r=fs.mkdtempSync(path.join(os.tmpdir(),"tar-gz-append-"));try{x({file:t,cwd:r,sync:!0});let s=path.join(r,path.basename(n));fs.copyFileSync(n,s),c({gzip:!0,file:t,cwd:r,sync:!0,portable:!0},fs.readdirSync(r))}finally{fs.rmSync(r,{recursive:!0,force:!0})}}catch{console.error(`ARCHIVE_FAILURE: ${e.message}`)}}function De(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"?j.NODE:j.BROWSER}var dt=De();function ut(){return dt===j.NODE}var gt=["alert","assert","keepLogHistory","getLogHistory","truncateMessage","truncateMessage","rawLog","removeOverride","removeOverrideError","overrideConsole","overrideError","table","rawInfo","rawWarn","rawError","hasSeenLid","addToLogHistory","releaseLogHistory","resetLogHistory","setLogFormat","resetLogFormatter","getRawLogHistory"],q,w,F,N,b,C,_,D,ee,z,S,te,Me,oe,Ie,g=class{constructor({name:t="default"}={}){T(this,te);T(this,oe);m(this,"system","");m(this,"instanceId","");m(this,"instanceName","");m(this,"logIndex",0);m(this,"logCounter",0);T(this,w,[]);T(this,F,{});T(this,N,{});m(this,"activeTargets",[]);m(this,"indexColor",0);m(this,"format","");m(this,"keepLog",!1);m(this,"logHistory",[]);m(this,"$containers",null);m(this,"options",{hideHookMessage:!1});T(this,b,console.log);T(this,C,console.info);T(this,_,console.warn);T(this,D,console.error);T(this,ee,console.debug);T(this,z,console.table);T(this,S,{log:!1,info:!1,warn:!1,error:!1,debug:!1,table:!1});m(this,"originalFormatFunction");m(this,"removeDomOldEntries",t=>{if(t.childElementCount>de){let r=Math.ceil(de/10);for(let s=0;s<r;++s)t.removeChild(t.firstChild);return r}return 0});m(this,"scrollDivToBottom",t=>{let o=t.scrollHeight-(t.clientHeight+t.scrollTop),r=t.clientHeight||t.offsetHeight;o>r/2||(t.scrollTop=t.scrollHeight)});this.system=De(),this.format=this.onBuildLog.bind(this),this.originalFormatFunction=this.format,this.instanceName=t,this.instanceId=g.instanceCount+"-"+Date.now(),f(g,q)[g.instanceCount]=this,++g.instanceCount,this.errorTargetHandler=this.onError.bind(this),this.errorUserTargetHandler=this.onErrorForUserTarget.bind(this),this.setOptions(this.options),this.rawLog=f(this,b),this.rawInfo=f(this,C),this.rawWarn=f(this,_),this.rawError=f(this,D),this.ALIGN=g.ALIGN,this.ENVIRONMENT_TYPE=g.ENVIRONMENT_TYPE,ce(this,oe,Ie).call(this),this.resetLogHistory()}getName(){return this.instanceName}getId(){return this.instanceId}keepLogHistory(){this.keepLog=!0}releaseLogHistory(){this.keepLog=!1}resetLogHistory(){this.logHistory=[]}addToLogHistory(t){t=t||{},this.logHistory.push(Object.assign({},t))}getLogHistory(t=!0,o=at){let r=this.logHistory||[],s=[];return r.forEach(i=>{let{text:a}=i;s.push(a)}),t?s.join(o):s}getRawLogHistory(){return this.logHistory||[]}hasSeenLid(t){this.logHistory=this.logHistory||[];for(let o=0;o<this.logHistory.length;++o){let s=(this.logHistory[o]||{}).context||{};if(t===s.lid)return!0}return!1}forceEnvironment(t){this.forcedSystem=t}isNode(){return this&&this.forcedSystem?this.forcedSystem===j.NODE:ut()}isBrowser(){return!this.isNode()}resetLogger(){this.options={},this.options.timeLenMax=12,this.options.contextLenMax=10,this.options.idLenMax=5,this.options.lidLenMax=6,this.options.messageLenMax=void 0,this.options.symbolLenMax=60,this.options.hideHookMessage=void 0,this.options.hidePassingTests=void 0,this.options.hideLog=void 0,this.options.hideError=void 0,this.options.oneConsolePerContext=!0,this.options.logToDom=void 0,this.options.logToFile=void 0,this.options.logMaxSize=0,this.options.logMaxArchives=3,this.options.logIndexArchive=0,this.options.logToRemote=void 0,this.options.addArchiveTimestamp=!0,this.options.addArchiveIndex=!0,this.options.logToRemoteUrl=void 0,this.options.logToRemoteBinaryUrl=void 0,this.options.compressArchives=!1,this.options.compressionLevel=1,this.options.protocol=void 0,this.options.host=void 0,this.options.port=void 0,this.options.pathname=void 0,this.options.binarypathname=void 0,this.options.enableDate=void 0}resetOptions(){this.resetLogger()}setOptions({contextLenMax:t=10,idLenMax:o=5,lidLenMax:r=6,symbolLenMax:s=2,messageLenMax:i=void 0,hideLog:a=void 0,hideError:l=void 0,hideHookMessage:h=void 0,hidePassingTests:u=void 0,logToDom:d=void 0,logToFile:p=void 0,logMaxSize:E=0,logMaxArchives:y=3,logIndexArchive:A=0,addArchiveTimestamp:M=!0,addArchiveIndex:re=!0,compressArchives:se=!1,compressionLevel:ne=1,logToRemote:ke=void 0,logToRemoteUrl:He=void 0,logToRemoteBinaryUrl:Ue=void 0,loopback:Be=O.loopback,requiredLogLevel:Pe=L.LOG,oneConsolePerContext:Ge=void 0,silent:Le=void 0,enableDate:je=void 0,protocol:$e=void 0,host:qe=void 0,port:ze=void 0,pathname:We=void 0,binarypathname:Ye=void 0}=null){this.options.contextLenMax=t,this.options.idLenMax=o,this.options.lidLenMax=r,this.options.messageLenMax=i,this.options.symbolLenMax=s,this.options.logMaxSize=E,this.options.logMaxArchives=y,this.options.logIndexArchive=A,this.options.addArchiveTimestamp=M,this.options.addArchiveIndex=re,this.options.compressArchives=se,this.options.compressionLevel=ne,this.options.requiredLogLevel=Pe;let ie;Le!==void 0?ie=!!Le:a!==void 0&&(ie=!!a),[{hideLog:ie},{oneConsolePerContext:Ge},{hideError:l},{enableDate:je},{hideHookMessage:h},{hidePassingTests:u},{logToRemote:ke}].forEach(B=>{let P=Object.keys(B)[0],G=B[P];G!==void 0&&(this.options[P]=!!G)}),[{logToRemoteBinaryUrl:Ue},{logToRemoteUrl:He},{loopback:Be},{protocol:$e},{host:qe},{port:ze},{pathname:We},{binarypathname:Ye}].forEach(B=>{let P=Object.keys(B)[0],G=B[P];G!==void 0&&(this.options[P]=G)}),this.options.logToRemote&&!this.options.logToRemoteUrl&&(this.options.logToRemoteUrl=this.convertToUrl({protocol:this.options.protocol,host:this.options.host,port:this.options.port,pathname:this.options.pathname})),this.options.logToRemote&&!this.options.logToRemoteBinaryUrl&&(this.options.logToRemoteBinaryUrl=this.convertToUrl({protocol:this.options.protocol,host:this.options.host,port:this.options.port,pathname:this.options.binarypathname||O.binarypathname})),d===!1?this.options.logToDom=!1:d!==void 0&&(this.options.logToDom=d===!0?O.consoleDomId:d),p===!1?this.options.logToFile=!1:p!==void 0&&(this.isBrowser()||(this.options.logToFile=p||O.logFilename),f(this,b).call(this,"LogToFile is not supported in this environment. "))}getOptions(){return this.options}truncateMessage(t="",{fit:o=0,align:r=g.ALIGN.LEFT,ellipsis:s="..."}={}){return t=""+t,o&&t.length>o&&(t=t.substring(0,o-s.length)+s),t=r===g.ALIGN.LEFT?t.padEnd(o," "):t.padStart(o," "),t}onBuildLog({contextName:t,message:o="",lid:r="",symbol:s=""}={}){try{let i="",a=o.split(/\n/g);for(let l=0;l<a.length;++l){let h=a[l],u=new Date,d=("0"+u.getHours()).slice(-2)+":"+("0"+u.getMinutes()).slice(-2)+":"+("0"+u.getSeconds()).slice(-2);this.options.enableDate&&(d=u.getFullYear().toString().slice(-2)+"-"+(u.getMonth()+1).toString().padStart(2,"0")+"-"+u.getDate().toString().padStart(2,"0")+" "+d),d=this.truncateMessage(d,{fit:this.options.timeLenMax}),l>0&&(t="",r=""),t=this.truncateMessage(t,{fit:this.options.contextLenMax,align:g.ALIGN.RIGHT}),r=this.truncateMessage(r,{fit:this.options.lidLenMax}),this.options.messageLenMax!==void 0&&(h=this.truncateMessage(h,{fit:this.options.messageLenMax})),s=this.truncateMessage(s,{fit:this.options.symbolLenMax}),l<=0?i+=`[${d}] ${t}: (${r}) ${s} ${h}`:l<a.length-1?(i+=`
|
|
1
|
+
var je=Object.defineProperty;var $e=(s,t,o)=>t in s?je(s,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[t]=o;var p=(s,t,o)=>($e(s,typeof t!="symbol"?t+"":t,o),o),te=(s,t,o)=>{if(!t.has(s))throw TypeError("Cannot "+o)};var m=(s,t,o)=>(te(s,t,"read from private field"),o?o.call(s):t.get(s)),v=(s,t,o)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,o)},oe=(s,t,o,r)=>(te(s,t,"write to private field"),r?r.call(s,o):t.set(s,o),o);var re=(s,t,o)=>(te(s,t,"access private method"),o);var de={Foreground:38,Background:48},w="\x1B[1D",ue="\x1B[0m"+w,G={Bold:"\x1B[1m"+w,Underline:"\x1B[4m"+w,Reversed:"\x1B[7m"+w},qe={Bold:"\x1B[1m"+w,Underline:"\x1B[4m"+w,Reversed:"\x1B[7m"+w},ne={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function ze(s){return!!ne[s]}var ge=(s,t,o)=>s===t&&t===o?s<8?16:s>248?231:Math.round((s-8)/247*24)+232:16+36*Math.round(s/255*5)+6*Math.round(t/255*5)+Math.round(o/255*5),pe=s=>{let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;s=s.replace(t,function(r,n,i,l){return n+n+i+i+l+l});let o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(s);return o?{red:parseInt(o[1],16),blue:parseInt(o[2],16),green:parseInt(o[3],16)}:{}},me=function({red:s,green:t,blue:o}){let r=s<<16|t<<8|o<<0;return"#"+(16777216+r).toString(16).slice(1)},Le=function(s){let t=s.matchAll(/\d+/g),o=[];for(let r of t){let n=parseInt(r[0]);if(n>255)return null;o.push(n)}return o.length!==3?null:{red:o[0],green:o[1],blue:o[2]}},We=function(s){let t=Le(s);return t&&me(t)},j=function(t,o,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(o-t)*6*r:r<1/2?o:r<2/3?t+(o-t)*(2/3-r)*6:t},ye=({hue:s,saturation:t,lightness:o})=>{let r,n,i;if(t===0)r=n=i=o;else{let l=o<.5?o*(1+t):o+t-o*t,a=2*o-l;r=j(a,l,s+1/3),n=j(a,l,s),i=j(a,l,s-1/3)}return{red:Math.round(r*255),blue:Math.round(i*255),green:Math.round(n*255)}},Ee=s=>{let t=s.toLowerCase();return typeof ne[t]<"u"?ne[t]:""};function D({red:s,blue:t,green:o},r=!0){if(s===void 0||t===void 0||o===void 0)return"";let n=ge(s,t,o);return`\x1B[${r?de.Foreground:de.Background};5;`+n+"m "+w}function N(s,t=!0){let{red:o,green:r,blue:n}=pe(s);return D({red:o,green:r,blue:n},t)}function $({hue:s,saturation:t,lightness:o},r){let{red:n,green:i,blue:l}=ye({hue:s,saturation:t,lightness:o});return D({red:n,green:i,blue:l},r)}function se(s,t=!0){try{let o;return s=s||"",s?((typeof s=="string"||s instanceof String)&&(s=s.trim()),ze(s)?(o=Ee(s),N(o,t)):typeof s=="object"&&!!s.red&&!!s.blue&&!!s.green?D(s,t):typeof s=="object"&&!!s.hue&&!!s.saturation&&!!s.lightness?$(s,t):s.startsWith("#")?N(s,t):(s=s.toString(),/^[\da-fA-F]+$/.test(s)?N("#"+s,t):"")):""}catch(o){console.error("TO_ANSI_INVALID_ARGUMENT_ERROR",o.message)}}function q(s,{fg:t,bg:o,isUnderline:r=!1,isBold:n=!1,isReversed:i=!1}){let l=!1,a="";return t&&(l=!0,a=a+t),o&&(l=!0,a=a+o),r&&(l=!0,a=a+G.Underline),n&&(l=!0,a=a+G.Bold),i&&(l=!0,a=a+G.Reversed),l?a+s+ue:s}function Ye(s,{fg:t={},bg:o={},isUnderline:r=!1,isBold:n=!1,isReversed:i=!1}){return t&&(t=D({...t})),o&&(o=D({...o},!1)),q(s,{fg:t,bg:o,isUnderline:r,isBold:n,isReversed:i})}function Ve(s,{fg:t="",bg:o="",isUnderline:r=!1,isBold:n=!1,isReversed:i=!1}){return t&&(t=$({...t})),o&&(o=$({...o},!1)),q(s,{fg:t,bg:o,isUnderline:r,isBold:n,isReversed:i})}function Je(s,{fg:t="",bg:o="",isUnderline:r=!1,isBold:n=!1,isReversed:i=!1}){return t&&(t=N(t)),o&&(o=N(o,!1)),q(s,{fg:t,bg:o,isUnderline:r,isBold:n,isReversed:i})}function Xe(s,t=null){if(!t)return s;let{fg:o="",bg:r="",isUnderline:n=!1,isBold:i=!1,isReversed:l=!1}=t;return o&&(o=se(o)),r&&(r=se(r,!1)),q(s,{fg:o,bg:r,isUnderline:n,isBold:i,isReversed:l})}var z={fromRgb:D,fromHexa:N,fromHsl:$,fromColor:se,getTextFromRgb:Ye,getTextFromHsl:Ve,getTextFromHex:Je,getTextFromColor:Xe,colorNameToHex:Ee,hslToRgb:ye,hexToRgb:pe,rgbToHex:me,rgbToAnsi256:ge,rgbStringToRgb:Le,rgbStringToHex:We,hue2rgb:j,RESET:ue,FONT_STYLE:G,STYLE:qe};var Te={COLOR_TABLE:["#d2466e","#FFA07A","#FF7F50","#FF6347","#FFE4B5","#ADFF2F","#808000","#40E0D0","#1E90FF","#EE82EE","#708090","#DEB887","#FE642E","#210B61","#088A4B","#5E610B","#FA8258","#088A68","#B40431"],SYSTEM:{BROWSER:"BROWSER",NODE:"NODE"}},M=Te.COLOR_TABLE,U=Te.SYSTEM,ie=2e3,le="analogger-removed-notif",ae="analogger-header",ce="analogger-view",fe="analogger-footer",be="to-esm-line",W={TOP:"TOP",BOTTOM:"BOTTOM"},Oe="ANALOGGER",Y={DEFAULT_FORMAT:"FORMAT1"};var{parse:ut,stringify:Ke}=JSON,{keys:gt}=Object,Qe=String,Ze="string";var Ae="object",et=(s,t)=>t;var xe=(s,t,o)=>{let r=Qe(t.push(o)-1);return s.set(o,r),r};var ve=(s,t,o)=>{let r=t&&typeof t===Ae?(d,g)=>d===""||-1<t.indexOf(d)?g:void 0:t||et,n=new Map,i=[],l=[],a=+xe(n,i,r.call({"":s},"",s)),h=!a;for(;a<i.length;)h=!0,l[a]=Ke(i[a++],u,o);return"["+l.join(",")+"]";function u(d,g){if(h)return h=!h,g;let y=r.call(this,d,g);switch(typeof y){case Ae:if(y===null)return y;case Ze:return n.get(y)||xe(n,i,y)}return y}};var T={moduleName:"analogger",protocol:"http://",host:"localhost",port:12e3,pathname:"analogger",binarypathname:"uploaded",loopback:"localhost",consoleDomId:"#analogger",logFilename:"./analogger.log"},I={ALL:"ALL",USER:"USER"},L={FATAL:5e3,ERROR:4e3,WARN:3e3,INFO:2e3,LOG:1e3,DEBUG:500,ALL:200,OFF:0,INHERIT:-1},we={LOCAL:"local",GLOBAL:"global"},B={DEFAULT:{contextName:"DEFAULT",logLevel:L.LOG,symbol:"check"},LOG:{contextName:"LOG",logLevel:L.LOG,symbol:"check"},DEBUG:{contextName:"DEBUG",logLevel:L.DEBUG},INFO:{contextName:"INFO",logLevel:L.INFO,color:"#B18904",symbol:"diamonds"},WARN:{contextName:"WARN",logLevel:L.WARN,color:M[0],symbol:"cross"},ERROR:{contextName:"ERROR",logLevel:L.ERROR},CRITICAL:{contextName:"CRITICAL",logLevel:L.CRITICAL}},tt=`
|
|
2
|
+
`,V={airplane:"\u2708",anchor:"\u2693",arrow_backward:"\u25C0",arrow_double_up:"\u23EB",arrow_double_down:"\u23EC",arrow_forward:"\u25B6",arrow_lower_right:"\u2198",arrow_lower_left:"\u2199",arrow_right_hook:"\u21AA",arrow_up_down:"\u2195",arrow_upper_left:"\u2196",arrow_upper_right:"\u2197",ballot_box_with_check:"\u2611",biohazard:"\u2623",black_circle:"\u23FA",black_medium_small_square:"\u25FE",black_medium_square:"\u25FC",black_nib:"\u2712",black_small_square:"\u25AA",black_square:"\u23F9",chains:"\u26D3",check:"\u2714",chess_pawn:"\u265F",cloud_and_rain:"\u26C8",clubs:"\u2663",coffee:"\u2615",copyright:"\xA9",cross:"\u274C",diamonds:"\u2666",divisions_ign:"\u2797",double_triangle_right:"\u23ED",double_triangle_left:"\u23EE",email:"\u2709",eject:"\u23CF",exclamation_mark:"\u2757",fast_forward:"\u23E9",female_sign:"\u2640",fist:"\u270A",fuel_pump:"\u26FD",gear:"\u2699",hammer_and_pick:"\u2692",hand:"\u270B",hearts:"\u2665",infinity:"\u267E",information:"\u2139",left_right_arrow:"\u2194",leftwards_arrow_with_hook:"\u21A9",male_sign:"\u2642",minus_sign:"\u2796",no_entry:"\u26D4",partly_sunny:"\u26C5",pencil:"\u270F",phone:"\u260E",plus_sign:"\u2795",question:"\u2754",radioactive:"\u2622",raised_hand:"\u270B",recycle:"\u267B",registered:"\xAE",relaxed:"\u263A",rewind:"\u23EA",scissors:"\u2702",snowman:"\u2603",spades:"\u2660",sparkles:"\u2728",star:"\u2B50",sunny:"\u2600",tent:"\u26FA",trademark:"\u2122",triangle_with_vertical_bar:"\u23EF",umbrella:"\u2614",vertical_bars:"\u23F8",watch:"\u231A",white_frowning_face:"\u2639",white_medium_square:"\u25FB",white_medium_small_square:"\u25FD",white_small_square:"\u25AB",wheelchair:"\u267F",white_circle:"\u26AA",writing_hand:"\u270D"};function ot(s){try{let t=path.extname(s),o=path.basename(s,t),r=path.dirname(s),n=s.slice(0,s.length-t.length);return{extension:t,filePath:n,basename:o,dirname:r}}catch(t){console.error("FILEPATH_EXT_FAILURE: ",t.message)}return{extension:".log",filePath:s}}function rt(){return new Date().toISOString().replace(/:/g,"-").replace(/\./g,"-")}function nt(s,t,o,r,n,i,l){fs.readdir(s,(a,h)=>{if(a){l(a,null);return}let u=[],d=0,g=(E,O)=>{if(!fs.existsSync(E)){O(null,null);return}fs.unlink(E,F=>{F?console.error(`DELETION_FAILURE: Error deleting file ${E}: ${F}`):u.push(E),d++,d===h.length&&O(null,u)})},y=E=>{if(E.startsWith(t+".")&&E.endsWith(o+r)){let O=path.join(s,E);n&&st(O,n,i),g(O,l)}else d++,d===h.length&&l(null,u)};h.length===0?l(null,u):h.forEach(y,i)})}function st(s,t,o=1){try{if(!fs.existsSync(s))return;if(!fs.existsSync(t)){let n=fs.mkdtempSync(path.join(os.tmpdir(),"tar-gz-init-"));try{let i=path.join(n,path.basename(s));fs.copyFileSync(s,i),c({sync:!0,gzip:{level:o},file:t,cwd:n,portable:!0},[path.basename(s)])}finally{fs.rmSync(n,{recursive:!0,force:!0})}return}let r=fs.mkdtempSync(path.join(os.tmpdir(),"tar-gz-append-"));try{x({file:t,cwd:r,sync:!0});let n=path.join(r,path.basename(s));fs.copyFileSync(s,n),c({gzip:!0,file:t,cwd:r,sync:!0,portable:!0},fs.readdirSync(r))}finally{fs.rmSync(r,{recursive:!0,force:!0})}}catch{console.error(`ARCHIVE_FAILURE: ${e.message}`)}}function Se(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"?U.NODE:U.BROWSER}var it=Se();function lt(){return it===U.NODE}var at=["alert","assert","keepLogHistory","getLogHistory","truncateMessage","truncateMessage","rawLog","removeOverride","removeOverrideError","overrideConsole","overrideError","table","rawInfo","rawWarn","rawError","hasSeenLid","addToLogHistory","releaseLogHistory","resetLogHistory","setLogFormat","resetLogFormatter","getRawLogHistory"],P,S,R,C,A,J,Re,X,Ce,f=class{constructor({name:t="default"}={}){v(this,J);v(this,X);p(this,"system","");p(this,"instanceId","");p(this,"instanceName","");p(this,"logIndex",0);p(this,"logCounter",0);v(this,S,[]);v(this,R,{});v(this,C,{});p(this,"activeTargets",[]);p(this,"indexColor",0);p(this,"format","");p(this,"keepLog",!1);p(this,"logHistory",[]);p(this,"$containers",null);p(this,"options",{hideHookMessage:!1});v(this,A,{log:!1,info:!1,warn:!1,error:!1});p(this,"originalFormatFunction");p(this,"removeDomOldEntries",t=>{if(t.childElementCount>ie){let r=Math.ceil(ie/10);for(let n=0;n<r;++n)t.removeChild(t.firstChild);return r}return 0});p(this,"scrollDivToBottom",t=>{let o=t.scrollHeight-(t.clientHeight+t.scrollTop),r=t.clientHeight||t.offsetHeight;o>r/2||(t.scrollTop=t.scrollHeight)});this.system=Se(),this.format=this.onBuildLog.bind(this),this.originalFormatFunction=this.format,this.instanceName=t,this.instanceId=f.instanceCount+"-"+Date.now(),m(f,P)[f.instanceCount]=this,++f.instanceCount,this.errorTargetHandler=this.onError.bind(this),this.errorUserTargetHandler=this.onErrorForUserTarget.bind(this),this.setOptions(this.options),f.Console||(f.Console={log:console.log,info:console.info,warn:console.warn,error:console.error,debug:console.debug,table:console.table}),this.rawLog=f.Console.log,this.rawInfo=f.Console.info,this.rawWarn=f.Console.warn,this.rawError=f.Console.error,this.ALIGN=f.ALIGN,this.ENVIRONMENT_TYPE=f.ENVIRONMENT_TYPE,re(this,X,Ce).call(this),this.resetLogHistory()}getName(){return this.instanceName}getId(){return this.instanceId}keepLogHistory(){this.keepLog=!0}releaseLogHistory(){this.keepLog=!1}resetLogHistory(){this.logHistory=[]}addToLogHistory(t){t=t||{},this.logHistory.push(Object.assign({},t))}getLogHistory(t=!0,o=tt){let r=this.logHistory||[],n=[];return r.forEach(i=>{let{text:l}=i;n.push(l)}),t?n.join(o):n}getRawLogHistory(){return this.logHistory||[]}hasSeenLid(t){this.logHistory=this.logHistory||[];for(let o=0;o<this.logHistory.length;++o){let n=(this.logHistory[o]||{}).context||{};if(t===n.lid)return!0}return!1}forceEnvironment(t){this.forcedSystem=t}isNode(){return this&&this.forcedSystem?this.forcedSystem===U.NODE:lt()}isBrowser(){return!this.isNode()}resetLogger(){this.options={},this.options.timeLenMax=12,this.options.contextLenMax=10,this.options.idLenMax=5,this.options.lidLenMax=6,this.options.messageLenMax=void 0,this.options.symbolLenMax=60,this.options.hideHookMessage=void 0,this.options.hidePassingTests=void 0,this.options.hideLog=void 0,this.options.hideError=void 0,this.options.oneConsolePerContext=!0,this.options.logToDom=void 0,this.options.logToFile=void 0,this.options.logMaxSize=0,this.options.logMaxArchives=3,this.options.logIndexArchive=0,this.options.logToRemote=void 0,this.options.addArchiveTimestamp=!0,this.options.addArchiveIndex=!0,this.options.logToRemoteUrl=void 0,this.options.logToRemoteBinaryUrl=void 0,this.options.compressArchives=!1,this.options.compressionLevel=1,this.options.protocol=void 0,this.options.host=void 0,this.options.port=void 0,this.options.pathname=void 0,this.options.binarypathname=void 0,this.options.enableDate=void 0}resetOptions(){this.resetLogger()}setOptions({contextLenMax:t=10,idLenMax:o=5,lidLenMax:r=6,symbolLenMax:n=2,messageLenMax:i=void 0,hideLog:l=void 0,hideError:a=void 0,hideHookMessage:h=void 0,hidePassingTests:u=void 0,logToDom:d=void 0,logToFile:g=void 0,logMaxSize:y=0,logMaxArchives:E=3,logIndexArchive:O=0,addArchiveTimestamp:F=!0,addArchiveIndex:K=!0,compressArchives:Q=!1,compressionLevel:Z=1,logToRemote:Fe=void 0,logToRemoteUrl:Ne=void 0,logToRemoteBinaryUrl:De=void 0,loopback:Me=T.loopback,requiredLogLevel:Ie=L.LOG,oneConsolePerContext:ke=void 0,silent:he=void 0,enableDate:He=void 0,protocol:_e=void 0,host:Ue=void 0,port:Be=void 0,pathname:Pe=void 0,binarypathname:Ge=void 0}=null){this.options.contextLenMax=t,this.options.idLenMax=o,this.options.lidLenMax=r,this.options.messageLenMax=i,this.options.symbolLenMax=n,this.options.logMaxSize=y,this.options.logMaxArchives=E,this.options.logIndexArchive=O,this.options.addArchiveTimestamp=F,this.options.addArchiveIndex=K,this.options.compressArchives=Q,this.options.compressionLevel=Z,this.options.requiredLogLevel=Ie;let ee;he!==void 0?ee=!!he:l!==void 0&&(ee=!!l),[{hideLog:ee},{oneConsolePerContext:ke},{hideError:a},{enableDate:He},{hideHookMessage:h},{hidePassingTests:u},{logToRemote:Fe}].forEach(k=>{let H=Object.keys(k)[0],_=k[H];_!==void 0&&(this.options[H]=!!_)}),[{logToRemoteBinaryUrl:De},{logToRemoteUrl:Ne},{loopback:Me},{protocol:_e},{host:Ue},{port:Be},{pathname:Pe},{binarypathname:Ge}].forEach(k=>{let H=Object.keys(k)[0],_=k[H];_!==void 0&&(this.options[H]=_)}),this.options.logToRemote&&!this.options.logToRemoteUrl&&(this.options.logToRemoteUrl=this.convertToUrl({protocol:this.options.protocol,host:this.options.host,port:this.options.port,pathname:this.options.pathname})),this.options.logToRemote&&!this.options.logToRemoteBinaryUrl&&(this.options.logToRemoteBinaryUrl=this.convertToUrl({protocol:this.options.protocol,host:this.options.host,port:this.options.port,pathname:this.options.binarypathname||T.binarypathname})),d===!1?this.options.logToDom=!1:d!==void 0&&(this.options.logToDom=d===!0?T.consoleDomId:d),g===!1?this.options.logToFile=!1:g!==void 0&&(this.isBrowser()||(this.options.logToFile=g||T.logFilename),f.Console.log("LogToFile is not supported in this environment. "))}getOptions(){return this.options}truncateMessage(t="",{fit:o=0,align:r=f.ALIGN.LEFT,ellipsis:n="..."}={}){return t=""+t,o&&t.length>o&&(t=t.substring(0,o-n.length)+n),t=r===f.ALIGN.LEFT?t.padEnd(o," "):t.padStart(o," "),t}onBuildLog({contextName:t,message:o="",lid:r="",symbol:n=""}={}){try{let i="",l=o.split(/\n/g);for(let a=0;a<l.length;++a){let h=l[a],u=new Date,d=("0"+u.getHours()).slice(-2)+":"+("0"+u.getMinutes()).slice(-2)+":"+("0"+u.getSeconds()).slice(-2);this.options.enableDate&&(d=u.getFullYear().toString().slice(-2)+"-"+(u.getMonth()+1).toString().padStart(2,"0")+"-"+u.getDate().toString().padStart(2,"0")+" "+d),d=this.truncateMessage(d,{fit:this.options.timeLenMax}),a>0&&(t="",r=""),t=this.truncateMessage(t,{fit:this.options.contextLenMax,align:f.ALIGN.RIGHT}),r=this.truncateMessage(r,{fit:this.options.lidLenMax}),this.options.messageLenMax!==void 0&&(h=this.truncateMessage(h,{fit:this.options.messageLenMax})),n=this.truncateMessage(n,{fit:this.options.symbolLenMax}),a<=0?i+=`[${d}] ${t}: (${r}) ${n} ${h}`:a<l.length-1?(i+=`
|
|
3
3
|
`,i+=`[${d}] ${t} ${r} ${h}`):h&&(i+=`
|
|
4
|
-
`,i+=`[${d}] ${t} ${r} ${h}`)}return i}catch(i){console.rawError(i.message)}return""}onErrorForUserTarget(t,...o){this.errorUserTargetHandler(t,...o)}onError(t,...o){t.target===
|
|
5
|
-
`),r=[];for(let s=0;s<o.length;++s){let i=o[s];r.push(i)}return r}catch(o){console.rawError(o.message)}return t.message}onDisplayError(...t){try{let o=-1,r=null;for(let s=0;s<t.length;++s){let i=t[s];if(i instanceof Error&&i.stack){o=s,r=this.assistStask(i)||[];break}}if(!r){this.error(...t);return}for(let s=0;s<r.length;++s)t[o]=r[s],this.error(...t)}catch(o){console.rawError(o)}}setLogFormat(t){if(typeof t!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=t.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(t){this.errorTargetHandler=t.bind(this)}setErrorHandlerForUserTarget(t){this.errorUserTargetHandler=t.bind(this)}isContextValid(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null?t.hasOwnProperty("contextName")&&t.hasOwnProperty("target"):!1}setDefaultContext(t){this.setContext($.DEFAULT.contextName,t)}generateDefaultContext(){let t=f(this,w)[$.DEFAULT.contextName]||{};return t=Object.assign({},{lid:"",contextName:$.DEFAULT.contextName,target:U.ALL,symbol:"\u26A1",color:H[1],logLevel:L.LOG},t),t.name=t.contextName,t.id=this.logIndex++,t}generateNewContext(){let t=this.generateDefaultContext();return t.color=H[this.indexColor++%(H.length-3)+2],t.symbol="",t}generateErrorContext(){let t=this.generateDefaultContext();return t.contextName=$.ERROR.contextName,t.name=t.contextName,t.color=H[0],t.symbol="\u274C",t.error=!0,t.logLevel=L.ERROR,t}setContext(t,o={}){o.contextName=t,o.name=t,o=ce(this,te,Me).call(this,o),f(this,w)[t]=o}getContext(t){return f(this,w)[t]}setContexts(t){Object.keys(t).forEach(r=>{let s=t[r]||{};this.setContext(r,s),t[r]=f(this,w)[r]})}getContexts(){return Object.freeze(f(this,w))}setTargets(t={}){let o={};if(Array.isArray(t))try{for(let r=0;r<t.length;++r){let s=t[r];if(typeof s=="string"||s instanceof String)o[s]=s;else if(typeof s=="object"){let i=null;for(let a in s){let l=s[a];if(a=a.trim(),!a){console.error("Invalid target");break}if(typeof l=="string"||l instanceof String){l=l.trim(),i=[a,l];break}if(typeof l=="number")break}i&&(o[i[0]]=i[1])}}}catch(r){console.error({lid:4321},r.message)}else o=t;le(this,F,Object.assign({},o,{...U}))}addTargets(t){let o=f(this,F),r=Object.assign({},o,t);this.setTargets(r)}getTargets(){return Object.freeze(f(this,F))}setActiveTargets(t=null){if(t===null){this.activeTargets=[U.ALL];return}else if(typeof t=="string"||t instanceof String)t=t.split(",");else if(typeof t=="object"||typeof t=="function")return;for(let o=0;o<t.length;++o)t[o]=t[o].trim();this.activeTargets=t}getActiveTarget(){return this.activeTargets}setActiveTarget(t){this.activeTargets=[],this.setActiveTargets(t),this.activeTargets=[this.activeTargets[0]]}setLogLevel(t,o){f(this,N)[t]=o}getLogLevel(t){return f(this,N)[t]}setLogLevels(t){le(this,N,t)}getLogLevels(){return Object.freeze(f(this,N))}isTargetAllowed(t){return!t||!this.activeTargets||!this.activeTargets.length||t===U.ALL||this.activeTargets.includes(U.ALL)?!0:this.activeTargets.includes(t)}setColumns(t,o,r){let s=0;for(let a in o){if(!["contextName","symbol","lid","text"].includes(a))continue;let l=o[a],h=document.createElement("span");h.classList.add("analogger-col",`analogger-col-${a}`,`analogger-col-${s}`),++s,h.textContent=l,t.append(h)}let i=document.createElement("span");i.classList.add("analogger-col","analogger-col-text",`analogger-col-${s}`),i.textContent=r,t.append(i);for(let a=1;a<=3;++a)i=document.createElement("span"),i.classList.add("analogger-col","analogger-col-extra",`analogger-extra-${a}`),t.append(i)}checkOnLoggingToDom(t,o){try{let r=t.onLoggingToDom;return typeof r!="function"?void 0:r.call(this,t,o)}catch{}}addLineToDom(t,o,{context:r,addType:s,message:i,text:a,args:l}){if(this.checkOnLoggingToDom(r,{message:i,text:a,args:l,logCounter:this.logCounter,$view:t,$line:o,addType:s})===!1)return;if(s===K.BOTTOM?t.append(o):t.insertBefore(o,t.firstChild),this.removeDomOldEntries(t)){if(t.getElementsByClassName(ue).length)return;this.showRemovedNotification(r);return}this.scrollDivToBottom(t)}showRemovedNotification(t){t.contextName=we,t.symbol="\u{1F5D1}",t.color="orange",t.className=ue,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(t,"",{addType:K.TOP,message:"Oldest entries removed"})},500)}writeLogToDom(t,o,{addType:r=K.BOTTOM,message:s="",args:i=null}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),o=s||o;for(let a=0;a<this.$containers.length;++a){let l=this.$containers[a],h=l.querySelector("."+ge);h||(h=document.createElement("div"),h.classList.add(ge),h.append(document.createElement("span")),h.append(document.createElement("span")),h.append(document.createElement("span")),l.append(h));let u=l.querySelector("."+pe);u||(u=document.createElement("div"),u.classList.add(pe),l.append(u));let d=l.querySelector("."+me);d||(d=document.createElement("div"),d.classList.add(me),d.append(document.createElement("span")),d.append(document.createElement("span")),d.append(document.createElement("span")),l.append(d));let p=document.createElement("div");p.classList.add(Re),t.className&&p.classList.add(t.className),p.style.color=t.color,this.setColumns(p,t,o,i),setTimeout(function(E,y,{addType:A,context:M,message:re,text:se,args:ne}){this.addLineToDom(E,y,{addType:A,context:M,message:re,text:se,args:ne})}.bind(this,u,p,{addType:r,context:t,message:s,text:o,args:i}),0)}}writeLogToFile(t){try{if(!fs.existsSync(this.options.logToFilePath)){let o=path.dirname(this.options.logToFilePath);fs.existsSync(o)||fs.mkdirSync(o,{recursive:!0}),fs.writeFileSync(this.options.logToFilePath,"")}if(this.options.logMaxSize&&fs.statSync(this.options.logToFilePath).size>this.options.logMaxSize){this.options.logIndexArchive<this.options.logMaxArchives?++this.options.logIndexArchive:this.options.logIndexArchive=1;let s=this.options.logMaxArchives.toString().length+1,{filePath:i,extension:a,basename:l,dirname:h}=lt(this.options.logToFilePath),u,d;u=this.options.addArchiveIndex?"."+this.options.logIndexArchive.toString().padStart(s,"0"):"",d=this.options.addArchiveTimestamp?"."+ct():"";let p=`${i}${d}${u}${a}`,E=this.options.compressArchives?`${i}.tar.gz`:"";ft(h,l,u,a,E,this.options.compressionLevel,y=>{y&&console.error("DELETION_FAILURE: Failed to delete some files")}),fs.renameSync(this.options.logToFilePath,p),fs.writeFileSync(this.options.logToFilePath,"")}fs.appendFileSync(this.options.logToFilePath,t+this.EOL)}catch(o){console.rawError("LOG_TO_FILE_FAILURE: ",o.message)}}writeLogToRemote(...t){try{let o=this.generateLogToRemoteUrl(this.options.logToRemoteUrl);if(!o)return null;let r=[...t],s=JSON.stringify(r);fetch(o,{method:"post",body:s,headers:{"Content-Type":"application/json"}}).then(i=>i.json()).catch(()=>null)}catch(o){console.rawError("LOG_TO_REMOTE_FAILURE: ",o.message)}}uploadDataToRemote(t,o=null,r=null){try{if(!this.options.logToRemote)return;let s=this.generateLogToRemoteUrl(this.options.logToRemoteBinaryUrl,{pathname:O.binarypathname});if(!s)return null;let i=t;o&&(i=JSON.stringify({raw:t,context:o})),fetch(s,{method:"post",body:i}).then(a=>a.json()).then(a=>r&&r(a)).catch(a=>a)}catch(s){console.rawError("BINARY_TO_REMOTE_FAILURE: ",s.message)}}stringifyEntry(t){let o;try{o=JSON.stringify(t)}catch{}if(!o)try{o=Ce(t)}catch{}return o}convertEntry(t){try{if(t==null||t==="")return t;if(typeof t=="boolean")return t;if(typeof t=="symbol"||typeof t=="number")return t;if(typeof t=="string"||myVar instanceof t)return t;if(t instanceof Date)return t}catch{}return this.stringifyEntry(t)}convertArgumentsToText(t){let o=[],r,s=t.length;for(let i=0;i<s;++i){let a,l=t[i];a=this.convertEntry(l),o.push(a)}return r=o.join("\u2022"),r}writeToConsole(t,o){let r=[t];this.isBrowser()&&r.push(`color: ${o.color}`);let s=o.contextLevel||L.LOG;s>=L.ERROR?f(this,D).call(this,...r):s>=L.WARN?f(this,_).call(this,...r):s>=L.INFO?f(this,C).call(this,...r):s>=L.LOG?f(this,b).call(this,...r):s>=L.DEBUG&&f(this,ee).call(this,...r)}checkPlugins(t,{message:o,text:r,args:s,logCounter:i}){try{if(!Object.keys(g.pluginTable).length)return;let a=!0;for(let l in t){let h=t[l];if(!h)continue;let u=g.pluginTable[l];if(!u||typeof u!="object")continue;let{callback:d,methodName:p,type:E}=u;if(typeof d!="function")continue;d.call(this,t,{message:o,text:r,args:s,logCounter:i,methodName:p,type:E,pluginOptions:h})===!1&&(a=!1)}return a}catch{}}checkOnLogging(t,o,r,s){if(!!s)try{let i=t[s];return typeof i!="function"?void 0:i.call(this,o,r)}catch{}}processOutput(t={}){try{let o="";if(this.applySymbolByName(t),this.checkOnLogging(t,t,arguments,"onContext"),!this.isTargetAllowed(t.target)||t.logLevel===L.OFF||this.options.requiredLogLevel>t.logLevel)return;let r=this.checkOnLogging(t,arguments&&arguments.length>1?arguments[1]:arguments,arguments,"onMessage");r!==void 0&&(arguments[1]=r);let s=Array.prototype.slice.call(arguments,1);o=this.convertArgumentsToText(s);let i="",a=this.format({...t,message:o});this.keepLog&&this.addToLogHistory({context:t,message:o,text:a}),++this.logCounter;let l=this.checkOnLogging(t,a,{message:o,args:s,logCounter:this.logCounter},"onOutput");if(l===!1||((typeof l=="string"||l instanceof String)&&(a=l),l=this.checkPlugins(t,{message:o,text:a,args:s,logCounter:this.logCounter}),l===!1)||(this.options.logToRemote&&this.writeLogToRemote(t,...s),this.isBrowser()?(t.environnment=g.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(t,a,{message:o,args:s}),i=`%c${a}`):(t.environnment=g.ENVIRONMENT_TYPE.NODE,i=X.getTextFromColor(a,{fg:t.color,bg:t.bgColor,isBold:t.bold,isUnderline:t.underline,isReversed:t.reversed}),this.options.logToFile&&this.writeLogToFile(a)),this.options.hideLog||t.hideLog||t.silent))return;this.writeToConsole(i,t),this.errorTargetHandler(t,s)}catch(o){console.rawError("AnaLogger:",o.message)}}isExtendedOptionsPassed(t){return typeof t!="object"?!1:t.hasOwnProperty("context")||t.hasOwnProperty("target")||t.hasOwnProperty("color")||t.hasOwnProperty("contextName")||t.hasOwnProperty("raw")||t.hasOwnProperty("lid")}extractContextFromInput(t){return(typeof t=="string"||t instanceof String)&&t.toLowerCase().indexOf("lid:")!==0,t}listSymbols(){for(let t in Z)console.rawLog(Z[t]+` ${t} `)}applySymbolByName(t){try{t.symbol&&Z[t.symbol]&&(t.symbol=Z[t.symbol])}catch{}}convertToContext(t,o){t=t||o;let r=t;if(t.context&&typeof t.context=="object"){let s=Object.assign({},t);delete s.context,r=Object.assign({},t.context,s)}return r=Object.assign({},o,r),delete r.context,r}log(t,...o){if(t=this.extractContextFromInput(t),!this.isExtendedOptionsPassed(t)){let i=this.generateDefaultContext();this.processOutput.apply(this,[i,t,...o]);return}let r=this.generateDefaultContext(),s=this.convertToContext(t,r);if(s.raw){f(this,b).call(this,...o);return}this.processOutput.apply(this,[s,...o])}error(t,...o){if(this.options.hideError)return;if(t=this.extractContextFromInput(t),!this.isExtendedOptionsPassed(t)){let a=this.generateErrorContext();this.processOutput.apply(this,[a,t,...o]);return}let r=this.generateErrorContext(),s=this.convertToContext(t,r),i=Array.prototype.slice.call(arguments,1);this.log(s,...i)}overrideError(){this.options.hideHookMessage||f(this,b).call(this,"AnaLogger: Hook placed on console.error"),f(this,S).error=!0,console.error=this.onDisplayError.bind(this)}attachConsole(){try{return console.rawLog=f(this,b),console.raw=f(this,b),console.rawInfo=f(this,C),console.rawWarn=f(this,_),console.rawError=f(this,D),console.logHistory=this.logHistory,console.logHistory=this.logHistory,gt.forEach(t=>{console[t]=function(...o){this[t](...o)}.bind(this)}),!0}catch(t){console.error({lid:4321},t.message)}return!1}overrideConsole({log:t=!0,info:o=!0,warn:r=!0,error:s=!1}={}){this.options.hideHookMessage||f(this,b).call(this,"AnaLogger: Hook placed on console.log"),[{log:t},{info:o},{warn:r}].forEach(function(i){let a=Object.keys(i)[0];i[a]&&(f(this,S)[a]=!0,console[a]=this.onDisplayLog.bind(this))}.bind(this)),s&&this.overrideError(),this.attachConsole()}removeOverrideError(){console.error=f(this,D),f(this,S).error=!1}removeOverride({log:t=!0,info:o=!0,warn:r=!0,error:s=!1}={}){t&&(console.log=f(this,b),f(this,S).log=!1),o&&(console.info=f(this,C),f(this,S).info=!1),r&&(console.warn=f(this,_),f(this,S).warn=!1),s&&this.removeOverrideError()}info(...t){return this.log(...t)}warn(...t){return this.log(...t)}table(...t){if(!f(this,S).log){f(this,z).call(this,...t);return}let o=console.log;console.log=f(this,b),f(this,z).call(this,...t),console.log=o}alert(...t){if(!this.isBrowser())return this.log(...t);let o;if(t&&(t[0]&&t[0].hasOwnProperty("lid")||this.isContextValid(t[0]))){let r=this.generateDefaultContext();o=this.convertToContext(t[0],r).lid+": "+t.slice(1).join(" | ")}else o=t.join(" | ");alert(o)}assert(t,o=!0,...r){let s;try{return typeof t=="function"?(s=t(...r),s!==o?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):t!==o?(this.error("Assert failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)}catch{this.error("Unexpected error in assert")}return!1}applyAnalogFormatting({activeTarget:t="",override:o=!1}={}){try{let s={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"}};return this.setDefaultContext(s.DEFAULT),t&&this.setActiveTarget(t),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:6}),o&&(this.overrideConsole(),this.overrideError()),!0}catch(r){console.error({lid:3249},r.message)}return!1}applyPredefinedFormat(t=Q.DEFAULT_FORMAT,{activeTarget:o="",override:r=!1}={}){if(t===Q.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:o,override:r})}static generateInstance(){return new g}static getInstance(t=0){return g.instanceCount?f(g,q)[t]:null}static generateMainInstance(){let t=g.getInstance();return t||new g}static startLogger(){g.generateMainInstance().applyPredefinedFormat(Q.DEFAULT_FORMAT,{override:!0})}static stopLogger(){let t=g.generateMainInstance();t.removeOverride(),t.removeOverrideError()}convertToUrl({protocol:t=O.protocol,host:o=O.host,port:r=O.port,pathname:s=O.pathname}={}){let i=new URL("http://localhost");return i.protocol=t,i.host=o,i.port=r,s&&(i.pathname=s),i.toString()}generateLogToRemoteUrl(t=null,{pathname:o=O.pathname}={}){if(typeof t=="string"||t instanceof String)return t;if(!this.isBrowser())return null;let r=this.options.protocol||window.location.protocol+"//",s=this.options.host||window.location.host||O.host,i=this.options.port||O.port;return o=this.options.pathname||o,this.convertToUrl({protocol:r,host:s,port:i,pathname:o})}addPlugin(t,o,r=""){r=r||t,this[t]=o,g.pluginTable[r]={type:_e.LOCAL,methodName:t,callback:o}}addGlobalPlugin(t,o,r){g[t]=o,g.pluginTable[r]={type:_e.GLOBAL,methodName:t,callback:o}}getPluginList(){return Object.keys(g.pluginTable)}validatePlugin(t){return g.pluginTable[t]?!0:(console.warn(`The plugin ${t} is not registered`),!1)}},v=g;q=new WeakMap,w=new WeakMap,F=new WeakMap,N=new WeakMap,b=new WeakMap,C=new WeakMap,_=new WeakMap,D=new WeakMap,ee=new WeakMap,z=new WeakMap,S=new WeakMap,te=new WeakSet,Me=function(t){let o=this.generateNewContext(),r=Object.assign({},o,t);return r.color.toLowerCase().indexOf("rgb")>-1?r.color=X.rgbStringToHex(r.color):r.color.indexOf("#")===-1&&(r.color=X.colorNameToHex(r.color)),r},oe=new WeakSet,Ie=function(){try{this.setTargets(U),this.setLogLevels(L),this.setContexts($)}catch(t){console.error({lid:4321},t.message)}return!1},T(v,q,[]),m(v,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),m(v,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),m(v,"instanceCount",0),m(v,"pluginTable",{});var pt=v,St=pt,Rt=v.generateMainInstance();var wt=v;export{wt as AnaLogger,$ as DEFAULT_LOG_CONTEXTS,L as DEFAULT_LOG_LEVELS,U as DEFAULT_LOG_TARGETS,Rt as anaLogger,St as default};
|
|
4
|
+
`,i+=`[${d}] ${t} ${r} ${h}`)}return i}catch(i){console.rawError(i.message)}return""}onErrorForUserTarget(t,...o){this.errorUserTargetHandler(t,...o)}onError(t,...o){t.target===m(this,R).USER&&this.onErrorForUserTarget(t,...o)}onDisplayLog(...t){this.log(...t)}assistStask(t){try{let o=t.stack.split(`
|
|
5
|
+
`),r=[];for(let n=0;n<o.length;++n){let i=o[n];r.push(i)}return r}catch(o){console.rawError(o.message)}return t.message}onDisplayError(...t){try{let o=-1,r=null;for(let n=0;n<t.length;++n){let i=t[n];if(i instanceof Error&&i.stack){o=n,r=this.assistStask(i)||[];break}}if(!r){this.error(...t);return}for(let n=0;n<r.length;++n)t[o]=r[n],this.error(...t)}catch(o){console.rawError(o)}}setLogFormat(t){if(typeof t!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=t.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(t){this.errorTargetHandler=t.bind(this)}setErrorHandlerForUserTarget(t){this.errorUserTargetHandler=t.bind(this)}isContextValid(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null?t.hasOwnProperty("contextName")&&t.hasOwnProperty("target"):!1}setDefaultContext(t){this.setContext(B.DEFAULT.contextName,t)}generateDefaultContext(){let t=m(this,S)[B.DEFAULT.contextName]||{};return t=Object.assign({},{lid:"",contextName:B.DEFAULT.contextName,target:I.ALL,symbol:"\u26A1",color:M[1],logLevel:L.LOG},t),t.name=t.contextName,t.id=this.logIndex++,t}generateNewContext(){let t=this.generateDefaultContext();return t.color=M[this.indexColor++%(M.length-3)+2],t.symbol="",t}generateErrorContext(){let t=this.generateDefaultContext();return t.contextName=B.ERROR.contextName,t.name=t.contextName,t.color=M[0],t.symbol="\u274C",t.error=!0,t.logLevel=L.ERROR,t}setContext(t,o={}){o.contextName=t,o.name=t,o=re(this,J,Re).call(this,o),m(this,S)[t]=o}getContext(t){return m(this,S)[t]}setContexts(t){Object.keys(t).forEach(r=>{let n=t[r]||{};this.setContext(r,n),t[r]=m(this,S)[r]})}getContexts(){return Object.freeze(m(this,S))}setTargets(t={}){let o={};if(Array.isArray(t))try{for(let r=0;r<t.length;++r){let n=t[r];if(typeof n=="string"||n instanceof String)o[n]=n;else if(typeof n=="object"){let i=null;for(let l in n){let a=n[l];if(l=l.trim(),!l){console.error("Invalid target");break}if(typeof a=="string"||a instanceof String){a=a.trim(),i=[l,a];break}if(typeof a=="number")break}i&&(o[i[0]]=i[1])}}}catch(r){console.error({lid:4321},r.message)}else o=t;oe(this,R,Object.assign({},o,{...I}))}addTargets(t){let o=m(this,R),r=Object.assign({},o,t);this.setTargets(r)}getTargets(){return Object.freeze(m(this,R))}setActiveTargets(t=null){if(t===null){this.activeTargets=[I.ALL];return}else if(typeof t=="string"||t instanceof String)t=t.split(",");else if(typeof t=="object"||typeof t=="function")return;for(let o=0;o<t.length;++o)t[o]=t[o].trim();this.activeTargets=t}getActiveTarget(){return this.activeTargets}setActiveTarget(t){this.activeTargets=[],this.setActiveTargets(t),this.activeTargets=[this.activeTargets[0]]}setLogLevel(t,o){m(this,C)[t]=o}getLogLevel(t){return m(this,C)[t]}setLogLevels(t){oe(this,C,t)}getLogLevels(){return Object.freeze(m(this,C))}isTargetAllowed(t){return!t||!this.activeTargets||!this.activeTargets.length||t===I.ALL||this.activeTargets.includes(I.ALL)?!0:this.activeTargets.includes(t)}setColumns(t,o,r){let n=0;for(let l in o){if(!["contextName","symbol","lid","text"].includes(l))continue;let a=o[l],h=document.createElement("span");h.classList.add("analogger-col",`analogger-col-${l}`,`analogger-col-${n}`),++n,h.textContent=a,t.append(h)}let i=document.createElement("span");i.classList.add("analogger-col","analogger-col-text",`analogger-col-${n}`),i.textContent=r,t.append(i);for(let l=1;l<=3;++l)i=document.createElement("span"),i.classList.add("analogger-col","analogger-col-extra",`analogger-extra-${l}`),t.append(i)}checkOnLoggingToDom(t,o){try{let r=t.onLoggingToDom;return typeof r!="function"?void 0:r.call(this,t,o)}catch{}}addLineToDom(t,o,{context:r,addType:n,message:i,text:l,args:a}){if(this.checkOnLoggingToDom(r,{message:i,text:l,args:a,logCounter:this.logCounter,$view:t,$line:o,addType:n})===!1)return;if(n===W.BOTTOM?t.append(o):t.insertBefore(o,t.firstChild),this.removeDomOldEntries(t)){if(t.getElementsByClassName(le).length)return;this.showRemovedNotification(r);return}this.scrollDivToBottom(t)}showRemovedNotification(t){t.contextName=Oe,t.symbol="\u{1F5D1}",t.color="orange",t.className=le,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(t,"",{addType:W.TOP,message:"Oldest entries removed"})},500)}writeLogToDom(t,o,{addType:r=W.BOTTOM,message:n="",args:i=null}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),o=n||o;for(let l=0;l<this.$containers.length;++l){let a=this.$containers[l],h=a.querySelector("."+ae);h||(h=document.createElement("div"),h.classList.add(ae),h.append(document.createElement("span")),h.append(document.createElement("span")),h.append(document.createElement("span")),a.append(h));let u=a.querySelector("."+ce);u||(u=document.createElement("div"),u.classList.add(ce),a.append(u));let d=a.querySelector("."+fe);d||(d=document.createElement("div"),d.classList.add(fe),d.append(document.createElement("span")),d.append(document.createElement("span")),d.append(document.createElement("span")),a.append(d));let g=document.createElement("div");g.classList.add(be),t.className&&g.classList.add(t.className),g.style.color=t.color,this.setColumns(g,t,o,i),setTimeout(function(y,E,{addType:O,context:F,message:K,text:Q,args:Z}){this.addLineToDom(y,E,{addType:O,context:F,message:K,text:Q,args:Z})}.bind(this,u,g,{addType:r,context:t,message:n,text:o,args:i}),0)}}writeLogToFile(t){try{if(!fs.existsSync(this.options.logToFilePath)){let o=path.dirname(this.options.logToFilePath);fs.existsSync(o)||fs.mkdirSync(o,{recursive:!0}),fs.writeFileSync(this.options.logToFilePath,"")}if(this.options.logMaxSize&&fs.statSync(this.options.logToFilePath).size>this.options.logMaxSize){this.options.logIndexArchive<this.options.logMaxArchives?++this.options.logIndexArchive:this.options.logIndexArchive=1;let n=this.options.logMaxArchives.toString().length+1,{filePath:i,extension:l,basename:a,dirname:h}=ot(this.options.logToFilePath),u,d;u=this.options.addArchiveIndex?"."+this.options.logIndexArchive.toString().padStart(n,"0"):"",d=this.options.addArchiveTimestamp?"."+rt():"";let g=`${i}${d}${u}${l}`,y=this.options.compressArchives?`${i}.tar.gz`:"";nt(h,a,u,l,y,this.options.compressionLevel,E=>{E&&console.error("DELETION_FAILURE: Failed to delete some files")}),fs.renameSync(this.options.logToFilePath,g),fs.writeFileSync(this.options.logToFilePath,"")}fs.appendFileSync(this.options.logToFilePath,t+this.EOL)}catch(o){console.rawError("LOG_TO_FILE_FAILURE: ",o.message)}}writeLogToRemote(...t){try{let o=this.generateLogToRemoteUrl(this.options.logToRemoteUrl);if(!o)return null;let r=[...t],n=JSON.stringify(r);fetch(o,{method:"post",body:n,headers:{"Content-Type":"application/json"}}).then(i=>i.json()).catch(()=>null)}catch(o){console.rawError("LOG_TO_REMOTE_FAILURE: ",o.message)}}uploadDataToRemote(t,o=null,r=null){try{if(!this.options.logToRemote)return;let n=this.generateLogToRemoteUrl(this.options.logToRemoteBinaryUrl,{pathname:T.binarypathname});if(!n)return null;let i=t;o&&(i=JSON.stringify({raw:t,context:o})),fetch(n,{method:"post",body:i}).then(l=>l.json()).then(l=>r&&r(l)).catch(l=>l)}catch(n){console.rawError("BINARY_TO_REMOTE_FAILURE: ",n.message)}}stringifyEntry(t){let o;try{o=JSON.stringify(t)}catch{}if(!o)try{o=ve(t)}catch{}return o}convertEntry(t){try{if(t==null||t==="")return t;if(typeof t=="boolean")return t;if(typeof t=="symbol"||typeof t=="number")return t;if(typeof t=="string"||myVar instanceof t)return t;if(t instanceof Date)return t}catch{}return this.stringifyEntry(t)}convertArgumentsToText(t){let o=[],r,n=t.length;for(let i=0;i<n;++i){let l,a=t[i];l=this.convertEntry(a),o.push(l)}return r=o.join("\u2022"),r}writeToConsole(t,o){let r=[t];this.isBrowser()&&r.push(`color: ${o.color}`);let n=o.contextLevel||L.LOG;n>=L.ERROR?f.Console.error(...r):n>=L.WARN?f.Console.warn(...r):n>=L.INFO?f.Console.info(...r):n>=L.LOG?f.Console.log(...r):n>=L.DEBUG&&f.Console.debug(...r)}checkPlugins(t,{message:o,text:r,args:n,logCounter:i}){try{if(!Object.keys(f.pluginTable).length)return;let l=!0;for(let a in t){let h=t[a];if(!h)continue;let u=f.pluginTable[a];if(!u||typeof u!="object")continue;let{callback:d,methodName:g,type:y}=u;if(typeof d!="function")continue;d.call(this,t,{message:o,text:r,args:n,logCounter:i,methodName:g,type:y,pluginOptions:h})===!1&&(l=!1)}return l}catch{}}checkOnLogging(t,o,r,n){if(!!n)try{let i=t[n];return typeof i!="function"?void 0:i.call(this,o,r)}catch{}}processOutput(t={}){try{let o="";if(this.applySymbolByName(t),this.checkOnLogging(t,t,arguments,"onContext"),!this.isTargetAllowed(t.target)||t.logLevel===L.OFF||this.options.requiredLogLevel>t.logLevel)return;let r=this.checkOnLogging(t,arguments&&arguments.length>1?arguments[1]:arguments,arguments,"onMessage");r!==void 0&&(arguments[1]=r);let n=Array.prototype.slice.call(arguments,1);o=this.convertArgumentsToText(n);let i="",l=this.format({...t,message:o});this.keepLog&&this.addToLogHistory({context:t,message:o,text:l}),++this.logCounter;let a=this.checkOnLogging(t,l,{message:o,args:n,logCounter:this.logCounter},"onOutput");if(a===!1||((typeof a=="string"||a instanceof String)&&(l=a),a=this.checkPlugins(t,{message:o,text:l,args:n,logCounter:this.logCounter}),a===!1)||(this.options.logToRemote&&this.writeLogToRemote(t,...n),this.isBrowser()?(t.environnment=f.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(t,l,{message:o,args:n}),i=`%c${l}`):(t.environnment=f.ENVIRONMENT_TYPE.NODE,i=z.getTextFromColor(l,{fg:t.color,bg:t.bgColor,isBold:t.bold,isUnderline:t.underline,isReversed:t.reversed}),this.options.logToFile&&this.writeLogToFile(l)),this.options.hideLog||t.hideLog||t.silent))return;this.writeToConsole(i,t),this.errorTargetHandler(t,n)}catch(o){console.rawError("AnaLogger:",o.message)}}isExtendedOptionsPassed(t){return typeof t!="object"?!1:t.hasOwnProperty("context")||t.hasOwnProperty("target")||t.hasOwnProperty("color")||t.hasOwnProperty("contextName")||t.hasOwnProperty("raw")||t.hasOwnProperty("lid")}extractContextFromInput(t){return(typeof t=="string"||t instanceof String)&&t.toLowerCase().indexOf("lid:")!==0,t}listSymbols(){for(let t in V)console.rawLog(V[t]+` ${t} `)}applySymbolByName(t){try{t.symbol&&V[t.symbol]&&(t.symbol=V[t.symbol])}catch{}}convertToContext(t,o){t=t||o;let r=t;if(t.context&&typeof t.context=="object"){let n=Object.assign({},t);delete n.context,r=Object.assign({},t.context,n)}return r=Object.assign({},o,r),delete r.context,r}log(t,...o){if(t=this.extractContextFromInput(t),!this.isExtendedOptionsPassed(t)){let i=this.generateDefaultContext();this.processOutput.apply(this,[i,t,...o]);return}let r=this.generateDefaultContext(),n=this.convertToContext(t,r);if(n.raw){f.Console.log(...o);return}this.processOutput.apply(this,[n,...o])}error(t,...o){if(this.options.hideError)return;if(t=this.extractContextFromInput(t),!this.isExtendedOptionsPassed(t)){let l=this.generateErrorContext();this.processOutput.apply(this,[l,t,...o]);return}let r=this.generateErrorContext(),n=this.convertToContext(t,r),i=Array.prototype.slice.call(arguments,1);this.log(n,...i)}overrideError(){this.options.hideHookMessage||f.Console.log("AnaLogger: Hook placed on console.error"),m(this,A).error=!0,console.error=this.onDisplayError.bind(this)}attachConsole(){try{return console.rawLog=f.Console.log,console.raw=f.Console.log,console.rawInfo=f.Console.info,console.rawWarn=f.Console.warn,console.rawError=f.Console.error,console.logHistory=this.logHistory,console.logHistory=this.logHistory,at.forEach(t=>{console[t]=function(...o){this[t](...o)}.bind(this)}),!0}catch(t){console.error({lid:4321},t.message)}return!1}overrideConsole({log:t=!0,info:o=!0,warn:r=!0,error:n=!1}={}){this.options.hideHookMessage||f.Console.log("AnaLogger: Hook placed on console.log"),[{log:t},{info:o},{warn:r}].forEach(function(i){let l=Object.keys(i)[0];i[l]&&(m(this,A)[l]=!0,console[l]=this.onDisplayLog.bind(this))}.bind(this)),n&&this.overrideError(),this.attachConsole()}removeOverrideError(){console.error=f.Console.error,m(this,A).error=!1}removeOverride({log:t=!0,info:o=!0,warn:r=!0,error:n=!1}={}){t&&(console.log=f.Console.log,m(this,A).log=!1),o&&(console.info=f.Console.info,m(this,A).info=!1),r&&(console.warn=f.Console.warn,m(this,A).warn=!1),n&&this.removeOverrideError()}info(...t){return this.log(...t)}warn(...t){return this.log(...t)}table(...t){if(!m(this,A).log){f.Console.table(...t);return}let o=console.log;console.log=f.Console.log,f.Console.table(...t),console.log=o}alert(...t){if(!this.isBrowser())return this.log(...t);let o;if(t&&(t[0]&&t[0].hasOwnProperty("lid")||this.isContextValid(t[0]))){let r=this.generateDefaultContext();o=this.convertToContext(t[0],r).lid+": "+t.slice(1).join(" | ")}else o=t.join(" | ");alert(o)}assert(t,o=!0,...r){let n;try{return typeof t=="function"?(n=t(...r),n!==o?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):t!==o?(this.error("Assert failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)}catch{this.error("Unexpected error in assert")}return!1}applyAnalogFormatting({activeTarget:t="",override:o=!1}={}){try{let n={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"}};return this.setDefaultContext(n.DEFAULT),t&&this.setActiveTarget(t),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:6}),o&&(this.overrideConsole(),this.overrideError()),!0}catch(r){console.error({lid:3249},r.message)}return!1}applyPredefinedFormat(t=Y.DEFAULT_FORMAT,{activeTarget:o="",override:r=!1}={}){if(t===Y.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:o,override:r})}static generateInstance(){return new f}static getInstance(t=0){return f.instanceCount?m(f,P)[t]:null}static generateMainInstance(){let t=f.getInstance();return t||new f}static startLogger(){f.generateMainInstance().applyPredefinedFormat(Y.DEFAULT_FORMAT,{override:!0})}static stopLogger(){let t=f.generateMainInstance();t.removeOverride(),t.removeOverrideError()}convertToUrl({protocol:t=T.protocol,host:o=T.host,port:r=T.port,pathname:n=T.pathname}={}){let i=new URL("http://localhost");return i.protocol=t,i.host=o,i.port=r,n&&(i.pathname=n),i.toString()}generateLogToRemoteUrl(t=null,{pathname:o=T.pathname}={}){if(typeof t=="string"||t instanceof String)return t;if(!this.isBrowser())return null;let r=this.options.protocol||window.location.protocol+"//",n=this.options.host||window.location.host||T.host,i=this.options.port||T.port;return o=this.options.pathname||o,this.convertToUrl({protocol:r,host:n,port:i,pathname:o})}addPlugin(t,o,r=""){r=r||t,this[t]=o,f.pluginTable[r]={type:we.LOCAL,methodName:t,callback:o}}addGlobalPlugin(t,o,r){f[t]=o,f.pluginTable[r]={type:we.GLOBAL,methodName:t,callback:o}}getPluginList(){return Object.keys(f.pluginTable)}validatePlugin(t){return f.pluginTable[t]?!0:(console.warn(`The plugin ${t} is not registered`),!1)}},b=f;P=new WeakMap,S=new WeakMap,R=new WeakMap,C=new WeakMap,A=new WeakMap,J=new WeakSet,Re=function(t){let o=this.generateNewContext(),r=Object.assign({},o,t);return r.color.toLowerCase().indexOf("rgb")>-1?r.color=z.rgbStringToHex(r.color):r.color.indexOf("#")===-1&&(r.color=z.colorNameToHex(r.color)),r},X=new WeakSet,Ce=function(){try{this.setTargets(I),this.setLogLevels(L),this.setContexts(B)}catch(t){console.error({lid:4321},t.message)}return!1},v(b,P,[]),p(b,"Console",null),p(b,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),p(b,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),p(b,"instanceCount",0),p(b,"pluginTable",{});var ct=b,Tt=ct,bt=b.generateMainInstance();var Ot=b;export{Ot as AnaLogger,B as DEFAULT_LOG_CONTEXTS,L as DEFAULT_LOG_LEVELS,I as DEFAULT_LOG_TARGETS,bt as anaLogger,Tt as default};
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,Z={airplane:"\u2708",anchor:"\u2693",arrow_backward:"\u25C0",arrow_double_up:"\u23EB",arrow_double_down:"\u23EC",arrow_forward:"\u25B6",arrow_lower_right:"\u2198",arrow_lower_left:"\u2199",arrow_right_hook:"\u21AA",arrow_up_down:"\u2195",arrow_upper_left:"\u2196",arrow_upper_right:"\u2197",ballot_box_with_check:"\u2611",biohazard:"\u2623",black_circle:"\u23FA",black_medium_small_square:"\u25FE",black_medium_square:"\u25FC",black_nib:"\u2712",black_small_square:"\u25AA",black_square:"\u23F9",chains:"\u26D3",check:"\u2714",chess_pawn:"\u265F",cloud_and_rain:"\u26C8",clubs:"\u2663",coffee:"\u2615",copyright:"\xA9",cross:"\u274C",diamonds:"\u2666",divisions_ign:"\u2797",double_triangle_right:"\u23ED",double_triangle_left:"\u23EE",email:"\u2709",eject:"\u23CF",exclamation_mark:"\u2757",fast_forward:"\u23E9",female_sign:"\u2640",fist:"\u270A",fuel_pump:"\u26FD",gear:"\u2699",hammer_and_pick:"\u2692",hand:"\u270B",hearts:"\u2665",infinity:"\u267E",information:"\u2139",left_right_arrow:"\u2194",leftwards_arrow_with_hook:"\u21A9",male_sign:"\u2642",minus_sign:"\u2796",no_entry:"\u26D4",partly_sunny:"\u26C5",pencil:"\u270F",phone:"\u260E",plus_sign:"\u2795",question:"\u2754",radioactive:"\u2622",raised_hand:"\u270B",recycle:"\u267B",registered:"\xAE",relaxed:"\u263A",rewind:"\u23EA",scissors:"\u2702",snowman:"\u2603",spades:"\u2660",sparkles:"\u2728",star:"\u2B50",sunny:"\u2600",tent:"\u26FA",trademark:"\u2122",triangle_with_vertical_bar:"\u23EF",umbrella:"\u2614",vertical_bars:"\u23F8",watch:"\u231A",white_frowning_face:"\u2639",white_medium_square:"\u25FB",white_medium_small_square:"\u25FD",white_small_square:"\u25AB",wheelchair:"\u267F",white_circle:"\u26AA",writing_hand:"\u270D"};function lt(n){try{let t=path.extname(n),o=path.basename(n,t),r=path.dirname(n),s=n.slice(0,n.length-t.length);return{extension:t,filePath:s,basename:o,dirname:r}}catch(t){console.error("FILEPATH_EXT_FAILURE: ",t.message)}return{extension:".log",filePath:n}}function ct(){return new Date().toISOString().replace(/:/g,"-").replace(/\./g,"-")}function ft(n,t,o,r,s,i,a){fs.readdir(n,(l,h)=>{if(l){a(l,null);return}let u=[],d=0,p=(y,A)=>{if(!fs.existsSync(y)){A(null,null);return}fs.unlink(y,M=>{M?console.error(`DELETION_FAILURE: Error deleting file ${y}: ${M}`):u.push(y),d++,d===h.length&&A(null,u)})},E=y=>{if(y.startsWith(t+".")&&y.endsWith(o+r)){let A=path.join(n,y);s&&ht(A,s,i),p(A,a)}else d++,d===h.length&&a(null,u)};h.length===0?a(null,u):h.forEach(E,i)})}function ht(n,t,o=1){try{if(!fs.existsSync(n))return;if(!fs.existsSync(t)){let s=fs.mkdtempSync(path.join(os.tmpdir(),"tar-gz-init-"));try{let i=path.join(s,path.basename(n));fs.copyFileSync(n,i),c({sync:!0,gzip:{level:o},file:t,cwd:s,portable:!0},[path.basename(n)])}finally{fs.rmSync(s,{recursive:!0,force:!0})}return}let r=fs.mkdtempSync(path.join(os.tmpdir(),"tar-gz-append-"));try{x({file:t,cwd:r,sync:!0});let s=path.join(r,path.basename(n));fs.copyFileSync(n,s),c({gzip:!0,file:t,cwd:r,sync:!0,portable:!0},fs.readdirSync(r))}finally{fs.rmSync(r,{recursive:!0,force:!0})}}catch{console.error(`ARCHIVE_FAILURE: ${e.message}`)}}function De(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"?j.NODE:j.BROWSER}var dt=De();function ut(){return dt===j.NODE}var gt=["alert","assert","keepLogHistory","getLogHistory","truncateMessage","truncateMessage","rawLog","removeOverride","removeOverrideError","overrideConsole","overrideError","table","rawInfo","rawWarn","rawError","hasSeenLid","addToLogHistory","releaseLogHistory","resetLogHistory","setLogFormat","resetLogFormatter","getRawLogHistory"],q,w,F,N,b,C,_,D,ee,z,S,te,Me,oe,Ie,g=class{constructor({name:t="default"}={}){T(this,te);T(this,oe);m(this,"system","");m(this,"instanceId","");m(this,"instanceName","");m(this,"logIndex",0);m(this,"logCounter",0);T(this,w,[]);T(this,F,{});T(this,N,{});m(this,"activeTargets",[]);m(this,"indexColor",0);m(this,"format","");m(this,"keepLog",!1);m(this,"logHistory",[]);m(this,"$containers",null);m(this,"options",{hideHookMessage:!1});T(this,b,console.log);T(this,C,console.info);T(this,_,console.warn);T(this,D,console.error);T(this,ee,console.debug);T(this,z,console.table);T(this,S,{log:!1,info:!1,warn:!1,error:!1,debug:!1,table:!1});m(this,"originalFormatFunction");m(this,"removeDomOldEntries",t=>{if(t.childElementCount>de){let r=Math.ceil(de/10);for(let s=0;s<r;++s)t.removeChild(t.firstChild);return r}return 0});m(this,"scrollDivToBottom",t=>{let o=t.scrollHeight-(t.clientHeight+t.scrollTop),r=t.clientHeight||t.offsetHeight;o>r/2||(t.scrollTop=t.scrollHeight)});this.system=De(),this.format=this.onBuildLog.bind(this),this.originalFormatFunction=this.format,this.instanceName=t,this.instanceId=g.instanceCount+"-"+Date.now(),f(g,q)[g.instanceCount]=this,++g.instanceCount,this.errorTargetHandler=this.onError.bind(this),this.errorUserTargetHandler=this.onErrorForUserTarget.bind(this),this.setOptions(this.options),this.rawLog=f(this,b),this.rawInfo=f(this,C),this.rawWarn=f(this,_),this.rawError=f(this,D),this.ALIGN=g.ALIGN,this.ENVIRONMENT_TYPE=g.ENVIRONMENT_TYPE,ce(this,oe,Ie).call(this),this.resetLogHistory()}getName(){return this.instanceName}getId(){return this.instanceId}keepLogHistory(){this.keepLog=!0}releaseLogHistory(){this.keepLog=!1}resetLogHistory(){this.logHistory=[]}addToLogHistory(t){t=t||{},this.logHistory.push(Object.assign({},t))}getLogHistory(t=!0,o=at){let r=this.logHistory||[],s=[];return r.forEach(i=>{let{text:a}=i;s.push(a)}),t?s.join(o):s}getRawLogHistory(){return this.logHistory||[]}hasSeenLid(t){this.logHistory=this.logHistory||[];for(let o=0;o<this.logHistory.length;++o){let s=(this.logHistory[o]||{}).context||{};if(t===s.lid)return!0}return!1}forceEnvironment(t){this.forcedSystem=t}isNode(){return this&&this.forcedSystem?this.forcedSystem===j.NODE:ut()}isBrowser(){return!this.isNode()}resetLogger(){this.options={},this.options.timeLenMax=12,this.options.contextLenMax=10,this.options.idLenMax=5,this.options.lidLenMax=6,this.options.messageLenMax=void 0,this.options.symbolLenMax=60,this.options.hideHookMessage=void 0,this.options.hidePassingTests=void 0,this.options.hideLog=void 0,this.options.hideError=void 0,this.options.oneConsolePerContext=!0,this.options.logToDom=void 0,this.options.logToFile=void 0,this.options.logMaxSize=0,this.options.logMaxArchives=3,this.options.logIndexArchive=0,this.options.logToRemote=void 0,this.options.addArchiveTimestamp=!0,this.options.addArchiveIndex=!0,this.options.logToRemoteUrl=void 0,this.options.logToRemoteBinaryUrl=void 0,this.options.compressArchives=!1,this.options.compressionLevel=1,this.options.protocol=void 0,this.options.host=void 0,this.options.port=void 0,this.options.pathname=void 0,this.options.binarypathname=void 0,this.options.enableDate=void 0}resetOptions(){this.resetLogger()}setOptions({contextLenMax:t=10,idLenMax:o=5,lidLenMax:r=6,symbolLenMax:s=2,messageLenMax:i=void 0,hideLog:a=void 0,hideError:l=void 0,hideHookMessage:h=void 0,hidePassingTests:u=void 0,logToDom:d=void 0,logToFile:p=void 0,logMaxSize:E=0,logMaxArchives:y=3,logIndexArchive:A=0,addArchiveTimestamp:M=!0,addArchiveIndex:re=!0,compressArchives:se=!1,compressionLevel:ne=1,logToRemote:ke=void 0,logToRemoteUrl:He=void 0,logToRemoteBinaryUrl:Ue=void 0,loopback:Be=O.loopback,requiredLogLevel:Pe=L.LOG,oneConsolePerContext:Ge=void 0,silent:Le=void 0,enableDate:je=void 0,protocol:$e=void 0,host:qe=void 0,port:ze=void 0,pathname:We=void 0,binarypathname:Ye=void 0}=null){this.options.contextLenMax=t,this.options.idLenMax=o,this.options.lidLenMax=r,this.options.messageLenMax=i,this.options.symbolLenMax=s,this.options.logMaxSize=E,this.options.logMaxArchives=y,this.options.logIndexArchive=A,this.options.addArchiveTimestamp=M,this.options.addArchiveIndex=re,this.options.compressArchives=se,this.options.compressionLevel=ne,this.options.requiredLogLevel=Pe;let ie;Le!==void 0?ie=!!Le:a!==void 0&&(ie=!!a),[{hideLog:ie},{oneConsolePerContext:Ge},{hideError:l},{enableDate:je},{hideHookMessage:h},{hidePassingTests:u},{logToRemote:ke}].forEach(B=>{let P=Object.keys(B)[0],G=B[P];G!==void 0&&(this.options[P]=!!G)}),[{logToRemoteBinaryUrl:Ue},{logToRemoteUrl:He},{loopback:Be},{protocol:$e},{host:qe},{port:ze},{pathname:We},{binarypathname:Ye}].forEach(B=>{let P=Object.keys(B)[0],G=B[P];G!==void 0&&(this.options[P]=G)}),this.options.logToRemote&&!this.options.logToRemoteUrl&&(this.options.logToRemoteUrl=this.convertToUrl({protocol:this.options.protocol,host:this.options.host,port:this.options.port,pathname:this.options.pathname})),this.options.logToRemote&&!this.options.logToRemoteBinaryUrl&&(this.options.logToRemoteBinaryUrl=this.convertToUrl({protocol:this.options.protocol,host:this.options.host,port:this.options.port,pathname:this.options.binarypathname||O.binarypathname})),d===!1?this.options.logToDom=!1:d!==void 0&&(this.options.logToDom=d===!0?O.consoleDomId:d),p===!1?this.options.logToFile=!1:p!==void 0&&(this.isBrowser()||(this.options.logToFile=p||O.logFilename),f(this,b).call(this,"LogToFile is not supported in this environment. "))}getOptions(){return this.options}truncateMessage(t="",{fit:o=0,align:r=g.ALIGN.LEFT,ellipsis:s="..."}={}){return t=""+t,o&&t.length>o&&(t=t.substring(0,o-s.length)+s),t=r===g.ALIGN.LEFT?t.padEnd(o," "):t.padStart(o," "),t}onBuildLog({contextName:t,message:o="",lid:r="",symbol:s=""}={}){try{let i="",a=o.split(/\n/g);for(let l=0;l<a.length;++l){let h=a[l],u=new Date,d=("0"+u.getHours()).slice(-2)+":"+("0"+u.getMinutes()).slice(-2)+":"+("0"+u.getSeconds()).slice(-2);this.options.enableDate&&(d=u.getFullYear().toString().slice(-2)+"-"+(u.getMonth()+1).toString().padStart(2,"0")+"-"+u.getDate().toString().padStart(2,"0")+" "+d),d=this.truncateMessage(d,{fit:this.options.timeLenMax}),l>0&&(t="",r=""),t=this.truncateMessage(t,{fit:this.options.contextLenMax,align:g.ALIGN.RIGHT}),r=this.truncateMessage(r,{fit:this.options.lidLenMax}),this.options.messageLenMax!==void 0&&(h=this.truncateMessage(h,{fit:this.options.messageLenMax})),s=this.truncateMessage(s,{fit:this.options.symbolLenMax}),l<=0?i+=`[${d}] ${t}: (${r}) ${s} ${h}`:l<a.length-1?(i+=`
|
|
1
|
+
var je=Object.defineProperty;var $e=(s,t,o)=>t in s?je(s,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[t]=o;var p=(s,t,o)=>($e(s,typeof t!="symbol"?t+"":t,o),o),te=(s,t,o)=>{if(!t.has(s))throw TypeError("Cannot "+o)};var m=(s,t,o)=>(te(s,t,"read from private field"),o?o.call(s):t.get(s)),v=(s,t,o)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,o)},oe=(s,t,o,r)=>(te(s,t,"write to private field"),r?r.call(s,o):t.set(s,o),o);var re=(s,t,o)=>(te(s,t,"access private method"),o);var de={Foreground:38,Background:48},w="\x1B[1D",ue="\x1B[0m"+w,G={Bold:"\x1B[1m"+w,Underline:"\x1B[4m"+w,Reversed:"\x1B[7m"+w},qe={Bold:"\x1B[1m"+w,Underline:"\x1B[4m"+w,Reversed:"\x1B[7m"+w},ne={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function ze(s){return!!ne[s]}var ge=(s,t,o)=>s===t&&t===o?s<8?16:s>248?231:Math.round((s-8)/247*24)+232:16+36*Math.round(s/255*5)+6*Math.round(t/255*5)+Math.round(o/255*5),pe=s=>{let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;s=s.replace(t,function(r,n,i,l){return n+n+i+i+l+l});let o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(s);return o?{red:parseInt(o[1],16),blue:parseInt(o[2],16),green:parseInt(o[3],16)}:{}},me=function({red:s,green:t,blue:o}){let r=s<<16|t<<8|o<<0;return"#"+(16777216+r).toString(16).slice(1)},Le=function(s){let t=s.matchAll(/\d+/g),o=[];for(let r of t){let n=parseInt(r[0]);if(n>255)return null;o.push(n)}return o.length!==3?null:{red:o[0],green:o[1],blue:o[2]}},We=function(s){let t=Le(s);return t&&me(t)},j=function(t,o,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(o-t)*6*r:r<1/2?o:r<2/3?t+(o-t)*(2/3-r)*6:t},ye=({hue:s,saturation:t,lightness:o})=>{let r,n,i;if(t===0)r=n=i=o;else{let l=o<.5?o*(1+t):o+t-o*t,a=2*o-l;r=j(a,l,s+1/3),n=j(a,l,s),i=j(a,l,s-1/3)}return{red:Math.round(r*255),blue:Math.round(i*255),green:Math.round(n*255)}},Ee=s=>{let t=s.toLowerCase();return typeof ne[t]<"u"?ne[t]:""};function D({red:s,blue:t,green:o},r=!0){if(s===void 0||t===void 0||o===void 0)return"";let n=ge(s,t,o);return`\x1B[${r?de.Foreground:de.Background};5;`+n+"m "+w}function N(s,t=!0){let{red:o,green:r,blue:n}=pe(s);return D({red:o,green:r,blue:n},t)}function $({hue:s,saturation:t,lightness:o},r){let{red:n,green:i,blue:l}=ye({hue:s,saturation:t,lightness:o});return D({red:n,green:i,blue:l},r)}function se(s,t=!0){try{let o;return s=s||"",s?((typeof s=="string"||s instanceof String)&&(s=s.trim()),ze(s)?(o=Ee(s),N(o,t)):typeof s=="object"&&!!s.red&&!!s.blue&&!!s.green?D(s,t):typeof s=="object"&&!!s.hue&&!!s.saturation&&!!s.lightness?$(s,t):s.startsWith("#")?N(s,t):(s=s.toString(),/^[\da-fA-F]+$/.test(s)?N("#"+s,t):"")):""}catch(o){console.error("TO_ANSI_INVALID_ARGUMENT_ERROR",o.message)}}function q(s,{fg:t,bg:o,isUnderline:r=!1,isBold:n=!1,isReversed:i=!1}){let l=!1,a="";return t&&(l=!0,a=a+t),o&&(l=!0,a=a+o),r&&(l=!0,a=a+G.Underline),n&&(l=!0,a=a+G.Bold),i&&(l=!0,a=a+G.Reversed),l?a+s+ue:s}function Ye(s,{fg:t={},bg:o={},isUnderline:r=!1,isBold:n=!1,isReversed:i=!1}){return t&&(t=D({...t})),o&&(o=D({...o},!1)),q(s,{fg:t,bg:o,isUnderline:r,isBold:n,isReversed:i})}function Ve(s,{fg:t="",bg:o="",isUnderline:r=!1,isBold:n=!1,isReversed:i=!1}){return t&&(t=$({...t})),o&&(o=$({...o},!1)),q(s,{fg:t,bg:o,isUnderline:r,isBold:n,isReversed:i})}function Je(s,{fg:t="",bg:o="",isUnderline:r=!1,isBold:n=!1,isReversed:i=!1}){return t&&(t=N(t)),o&&(o=N(o,!1)),q(s,{fg:t,bg:o,isUnderline:r,isBold:n,isReversed:i})}function Xe(s,t=null){if(!t)return s;let{fg:o="",bg:r="",isUnderline:n=!1,isBold:i=!1,isReversed:l=!1}=t;return o&&(o=se(o)),r&&(r=se(r,!1)),q(s,{fg:o,bg:r,isUnderline:n,isBold:i,isReversed:l})}var z={fromRgb:D,fromHexa:N,fromHsl:$,fromColor:se,getTextFromRgb:Ye,getTextFromHsl:Ve,getTextFromHex:Je,getTextFromColor:Xe,colorNameToHex:Ee,hslToRgb:ye,hexToRgb:pe,rgbToHex:me,rgbToAnsi256:ge,rgbStringToRgb:Le,rgbStringToHex:We,hue2rgb:j,RESET:ue,FONT_STYLE:G,STYLE:qe};var Te={COLOR_TABLE:["#d2466e","#FFA07A","#FF7F50","#FF6347","#FFE4B5","#ADFF2F","#808000","#40E0D0","#1E90FF","#EE82EE","#708090","#DEB887","#FE642E","#210B61","#088A4B","#5E610B","#FA8258","#088A68","#B40431"],SYSTEM:{BROWSER:"BROWSER",NODE:"NODE"}},M=Te.COLOR_TABLE,U=Te.SYSTEM,ie=2e3,le="analogger-removed-notif",ae="analogger-header",ce="analogger-view",fe="analogger-footer",be="to-esm-line",W={TOP:"TOP",BOTTOM:"BOTTOM"},Oe="ANALOGGER",Y={DEFAULT_FORMAT:"FORMAT1"};var{parse:ut,stringify:Ke}=JSON,{keys:gt}=Object,Qe=String,Ze="string";var Ae="object",et=(s,t)=>t;var xe=(s,t,o)=>{let r=Qe(t.push(o)-1);return s.set(o,r),r};var ve=(s,t,o)=>{let r=t&&typeof t===Ae?(d,g)=>d===""||-1<t.indexOf(d)?g:void 0:t||et,n=new Map,i=[],l=[],a=+xe(n,i,r.call({"":s},"",s)),h=!a;for(;a<i.length;)h=!0,l[a]=Ke(i[a++],u,o);return"["+l.join(",")+"]";function u(d,g){if(h)return h=!h,g;let y=r.call(this,d,g);switch(typeof y){case Ae:if(y===null)return y;case Ze:return n.get(y)||xe(n,i,y)}return y}};var T={moduleName:"analogger",protocol:"http://",host:"localhost",port:12e3,pathname:"analogger",binarypathname:"uploaded",loopback:"localhost",consoleDomId:"#analogger",logFilename:"./analogger.log"},I={ALL:"ALL",USER:"USER"},L={FATAL:5e3,ERROR:4e3,WARN:3e3,INFO:2e3,LOG:1e3,DEBUG:500,ALL:200,OFF:0,INHERIT:-1},we={LOCAL:"local",GLOBAL:"global"},B={DEFAULT:{contextName:"DEFAULT",logLevel:L.LOG,symbol:"check"},LOG:{contextName:"LOG",logLevel:L.LOG,symbol:"check"},DEBUG:{contextName:"DEBUG",logLevel:L.DEBUG},INFO:{contextName:"INFO",logLevel:L.INFO,color:"#B18904",symbol:"diamonds"},WARN:{contextName:"WARN",logLevel:L.WARN,color:M[0],symbol:"cross"},ERROR:{contextName:"ERROR",logLevel:L.ERROR},CRITICAL:{contextName:"CRITICAL",logLevel:L.CRITICAL}},tt=`
|
|
2
|
+
`,V={airplane:"\u2708",anchor:"\u2693",arrow_backward:"\u25C0",arrow_double_up:"\u23EB",arrow_double_down:"\u23EC",arrow_forward:"\u25B6",arrow_lower_right:"\u2198",arrow_lower_left:"\u2199",arrow_right_hook:"\u21AA",arrow_up_down:"\u2195",arrow_upper_left:"\u2196",arrow_upper_right:"\u2197",ballot_box_with_check:"\u2611",biohazard:"\u2623",black_circle:"\u23FA",black_medium_small_square:"\u25FE",black_medium_square:"\u25FC",black_nib:"\u2712",black_small_square:"\u25AA",black_square:"\u23F9",chains:"\u26D3",check:"\u2714",chess_pawn:"\u265F",cloud_and_rain:"\u26C8",clubs:"\u2663",coffee:"\u2615",copyright:"\xA9",cross:"\u274C",diamonds:"\u2666",divisions_ign:"\u2797",double_triangle_right:"\u23ED",double_triangle_left:"\u23EE",email:"\u2709",eject:"\u23CF",exclamation_mark:"\u2757",fast_forward:"\u23E9",female_sign:"\u2640",fist:"\u270A",fuel_pump:"\u26FD",gear:"\u2699",hammer_and_pick:"\u2692",hand:"\u270B",hearts:"\u2665",infinity:"\u267E",information:"\u2139",left_right_arrow:"\u2194",leftwards_arrow_with_hook:"\u21A9",male_sign:"\u2642",minus_sign:"\u2796",no_entry:"\u26D4",partly_sunny:"\u26C5",pencil:"\u270F",phone:"\u260E",plus_sign:"\u2795",question:"\u2754",radioactive:"\u2622",raised_hand:"\u270B",recycle:"\u267B",registered:"\xAE",relaxed:"\u263A",rewind:"\u23EA",scissors:"\u2702",snowman:"\u2603",spades:"\u2660",sparkles:"\u2728",star:"\u2B50",sunny:"\u2600",tent:"\u26FA",trademark:"\u2122",triangle_with_vertical_bar:"\u23EF",umbrella:"\u2614",vertical_bars:"\u23F8",watch:"\u231A",white_frowning_face:"\u2639",white_medium_square:"\u25FB",white_medium_small_square:"\u25FD",white_small_square:"\u25AB",wheelchair:"\u267F",white_circle:"\u26AA",writing_hand:"\u270D"};function ot(s){try{let t=path.extname(s),o=path.basename(s,t),r=path.dirname(s),n=s.slice(0,s.length-t.length);return{extension:t,filePath:n,basename:o,dirname:r}}catch(t){console.error("FILEPATH_EXT_FAILURE: ",t.message)}return{extension:".log",filePath:s}}function rt(){return new Date().toISOString().replace(/:/g,"-").replace(/\./g,"-")}function nt(s,t,o,r,n,i,l){fs.readdir(s,(a,h)=>{if(a){l(a,null);return}let u=[],d=0,g=(E,O)=>{if(!fs.existsSync(E)){O(null,null);return}fs.unlink(E,F=>{F?console.error(`DELETION_FAILURE: Error deleting file ${E}: ${F}`):u.push(E),d++,d===h.length&&O(null,u)})},y=E=>{if(E.startsWith(t+".")&&E.endsWith(o+r)){let O=path.join(s,E);n&&st(O,n,i),g(O,l)}else d++,d===h.length&&l(null,u)};h.length===0?l(null,u):h.forEach(y,i)})}function st(s,t,o=1){try{if(!fs.existsSync(s))return;if(!fs.existsSync(t)){let n=fs.mkdtempSync(path.join(os.tmpdir(),"tar-gz-init-"));try{let i=path.join(n,path.basename(s));fs.copyFileSync(s,i),c({sync:!0,gzip:{level:o},file:t,cwd:n,portable:!0},[path.basename(s)])}finally{fs.rmSync(n,{recursive:!0,force:!0})}return}let r=fs.mkdtempSync(path.join(os.tmpdir(),"tar-gz-append-"));try{x({file:t,cwd:r,sync:!0});let n=path.join(r,path.basename(s));fs.copyFileSync(s,n),c({gzip:!0,file:t,cwd:r,sync:!0,portable:!0},fs.readdirSync(r))}finally{fs.rmSync(r,{recursive:!0,force:!0})}}catch{console.error(`ARCHIVE_FAILURE: ${e.message}`)}}function Se(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"?U.NODE:U.BROWSER}var it=Se();function lt(){return it===U.NODE}var at=["alert","assert","keepLogHistory","getLogHistory","truncateMessage","truncateMessage","rawLog","removeOverride","removeOverrideError","overrideConsole","overrideError","table","rawInfo","rawWarn","rawError","hasSeenLid","addToLogHistory","releaseLogHistory","resetLogHistory","setLogFormat","resetLogFormatter","getRawLogHistory"],P,S,R,C,A,J,Re,X,Ce,f=class{constructor({name:t="default"}={}){v(this,J);v(this,X);p(this,"system","");p(this,"instanceId","");p(this,"instanceName","");p(this,"logIndex",0);p(this,"logCounter",0);v(this,S,[]);v(this,R,{});v(this,C,{});p(this,"activeTargets",[]);p(this,"indexColor",0);p(this,"format","");p(this,"keepLog",!1);p(this,"logHistory",[]);p(this,"$containers",null);p(this,"options",{hideHookMessage:!1});v(this,A,{log:!1,info:!1,warn:!1,error:!1});p(this,"originalFormatFunction");p(this,"removeDomOldEntries",t=>{if(t.childElementCount>ie){let r=Math.ceil(ie/10);for(let n=0;n<r;++n)t.removeChild(t.firstChild);return r}return 0});p(this,"scrollDivToBottom",t=>{let o=t.scrollHeight-(t.clientHeight+t.scrollTop),r=t.clientHeight||t.offsetHeight;o>r/2||(t.scrollTop=t.scrollHeight)});this.system=Se(),this.format=this.onBuildLog.bind(this),this.originalFormatFunction=this.format,this.instanceName=t,this.instanceId=f.instanceCount+"-"+Date.now(),m(f,P)[f.instanceCount]=this,++f.instanceCount,this.errorTargetHandler=this.onError.bind(this),this.errorUserTargetHandler=this.onErrorForUserTarget.bind(this),this.setOptions(this.options),f.Console||(f.Console={log:console.log,info:console.info,warn:console.warn,error:console.error,debug:console.debug,table:console.table}),this.rawLog=f.Console.log,this.rawInfo=f.Console.info,this.rawWarn=f.Console.warn,this.rawError=f.Console.error,this.ALIGN=f.ALIGN,this.ENVIRONMENT_TYPE=f.ENVIRONMENT_TYPE,re(this,X,Ce).call(this),this.resetLogHistory()}getName(){return this.instanceName}getId(){return this.instanceId}keepLogHistory(){this.keepLog=!0}releaseLogHistory(){this.keepLog=!1}resetLogHistory(){this.logHistory=[]}addToLogHistory(t){t=t||{},this.logHistory.push(Object.assign({},t))}getLogHistory(t=!0,o=tt){let r=this.logHistory||[],n=[];return r.forEach(i=>{let{text:l}=i;n.push(l)}),t?n.join(o):n}getRawLogHistory(){return this.logHistory||[]}hasSeenLid(t){this.logHistory=this.logHistory||[];for(let o=0;o<this.logHistory.length;++o){let n=(this.logHistory[o]||{}).context||{};if(t===n.lid)return!0}return!1}forceEnvironment(t){this.forcedSystem=t}isNode(){return this&&this.forcedSystem?this.forcedSystem===U.NODE:lt()}isBrowser(){return!this.isNode()}resetLogger(){this.options={},this.options.timeLenMax=12,this.options.contextLenMax=10,this.options.idLenMax=5,this.options.lidLenMax=6,this.options.messageLenMax=void 0,this.options.symbolLenMax=60,this.options.hideHookMessage=void 0,this.options.hidePassingTests=void 0,this.options.hideLog=void 0,this.options.hideError=void 0,this.options.oneConsolePerContext=!0,this.options.logToDom=void 0,this.options.logToFile=void 0,this.options.logMaxSize=0,this.options.logMaxArchives=3,this.options.logIndexArchive=0,this.options.logToRemote=void 0,this.options.addArchiveTimestamp=!0,this.options.addArchiveIndex=!0,this.options.logToRemoteUrl=void 0,this.options.logToRemoteBinaryUrl=void 0,this.options.compressArchives=!1,this.options.compressionLevel=1,this.options.protocol=void 0,this.options.host=void 0,this.options.port=void 0,this.options.pathname=void 0,this.options.binarypathname=void 0,this.options.enableDate=void 0}resetOptions(){this.resetLogger()}setOptions({contextLenMax:t=10,idLenMax:o=5,lidLenMax:r=6,symbolLenMax:n=2,messageLenMax:i=void 0,hideLog:l=void 0,hideError:a=void 0,hideHookMessage:h=void 0,hidePassingTests:u=void 0,logToDom:d=void 0,logToFile:g=void 0,logMaxSize:y=0,logMaxArchives:E=3,logIndexArchive:O=0,addArchiveTimestamp:F=!0,addArchiveIndex:K=!0,compressArchives:Q=!1,compressionLevel:Z=1,logToRemote:Fe=void 0,logToRemoteUrl:Ne=void 0,logToRemoteBinaryUrl:De=void 0,loopback:Me=T.loopback,requiredLogLevel:Ie=L.LOG,oneConsolePerContext:ke=void 0,silent:he=void 0,enableDate:He=void 0,protocol:_e=void 0,host:Ue=void 0,port:Be=void 0,pathname:Pe=void 0,binarypathname:Ge=void 0}=null){this.options.contextLenMax=t,this.options.idLenMax=o,this.options.lidLenMax=r,this.options.messageLenMax=i,this.options.symbolLenMax=n,this.options.logMaxSize=y,this.options.logMaxArchives=E,this.options.logIndexArchive=O,this.options.addArchiveTimestamp=F,this.options.addArchiveIndex=K,this.options.compressArchives=Q,this.options.compressionLevel=Z,this.options.requiredLogLevel=Ie;let ee;he!==void 0?ee=!!he:l!==void 0&&(ee=!!l),[{hideLog:ee},{oneConsolePerContext:ke},{hideError:a},{enableDate:He},{hideHookMessage:h},{hidePassingTests:u},{logToRemote:Fe}].forEach(k=>{let H=Object.keys(k)[0],_=k[H];_!==void 0&&(this.options[H]=!!_)}),[{logToRemoteBinaryUrl:De},{logToRemoteUrl:Ne},{loopback:Me},{protocol:_e},{host:Ue},{port:Be},{pathname:Pe},{binarypathname:Ge}].forEach(k=>{let H=Object.keys(k)[0],_=k[H];_!==void 0&&(this.options[H]=_)}),this.options.logToRemote&&!this.options.logToRemoteUrl&&(this.options.logToRemoteUrl=this.convertToUrl({protocol:this.options.protocol,host:this.options.host,port:this.options.port,pathname:this.options.pathname})),this.options.logToRemote&&!this.options.logToRemoteBinaryUrl&&(this.options.logToRemoteBinaryUrl=this.convertToUrl({protocol:this.options.protocol,host:this.options.host,port:this.options.port,pathname:this.options.binarypathname||T.binarypathname})),d===!1?this.options.logToDom=!1:d!==void 0&&(this.options.logToDom=d===!0?T.consoleDomId:d),g===!1?this.options.logToFile=!1:g!==void 0&&(this.isBrowser()||(this.options.logToFile=g||T.logFilename),f.Console.log("LogToFile is not supported in this environment. "))}getOptions(){return this.options}truncateMessage(t="",{fit:o=0,align:r=f.ALIGN.LEFT,ellipsis:n="..."}={}){return t=""+t,o&&t.length>o&&(t=t.substring(0,o-n.length)+n),t=r===f.ALIGN.LEFT?t.padEnd(o," "):t.padStart(o," "),t}onBuildLog({contextName:t,message:o="",lid:r="",symbol:n=""}={}){try{let i="",l=o.split(/\n/g);for(let a=0;a<l.length;++a){let h=l[a],u=new Date,d=("0"+u.getHours()).slice(-2)+":"+("0"+u.getMinutes()).slice(-2)+":"+("0"+u.getSeconds()).slice(-2);this.options.enableDate&&(d=u.getFullYear().toString().slice(-2)+"-"+(u.getMonth()+1).toString().padStart(2,"0")+"-"+u.getDate().toString().padStart(2,"0")+" "+d),d=this.truncateMessage(d,{fit:this.options.timeLenMax}),a>0&&(t="",r=""),t=this.truncateMessage(t,{fit:this.options.contextLenMax,align:f.ALIGN.RIGHT}),r=this.truncateMessage(r,{fit:this.options.lidLenMax}),this.options.messageLenMax!==void 0&&(h=this.truncateMessage(h,{fit:this.options.messageLenMax})),n=this.truncateMessage(n,{fit:this.options.symbolLenMax}),a<=0?i+=`[${d}] ${t}: (${r}) ${n} ${h}`:a<l.length-1?(i+=`
|
|
3
3
|
`,i+=`[${d}] ${t} ${r} ${h}`):h&&(i+=`
|
|
4
|
-
`,i+=`[${d}] ${t} ${r} ${h}`)}return i}catch(i){console.rawError(i.message)}return""}onErrorForUserTarget(t,...o){this.errorUserTargetHandler(t,...o)}onError(t,...o){t.target===
|
|
5
|
-
`),r=[];for(let s=0;s<o.length;++s){let i=o[s];r.push(i)}return r}catch(o){console.rawError(o.message)}return t.message}onDisplayError(...t){try{let o=-1,r=null;for(let s=0;s<t.length;++s){let i=t[s];if(i instanceof Error&&i.stack){o=s,r=this.assistStask(i)||[];break}}if(!r){this.error(...t);return}for(let s=0;s<r.length;++s)t[o]=r[s],this.error(...t)}catch(o){console.rawError(o)}}setLogFormat(t){if(typeof t!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=t.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(t){this.errorTargetHandler=t.bind(this)}setErrorHandlerForUserTarget(t){this.errorUserTargetHandler=t.bind(this)}isContextValid(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null?t.hasOwnProperty("contextName")&&t.hasOwnProperty("target"):!1}setDefaultContext(t){this.setContext($.DEFAULT.contextName,t)}generateDefaultContext(){let t=f(this,w)[$.DEFAULT.contextName]||{};return t=Object.assign({},{lid:"",contextName:$.DEFAULT.contextName,target:U.ALL,symbol:"\u26A1",color:H[1],logLevel:L.LOG},t),t.name=t.contextName,t.id=this.logIndex++,t}generateNewContext(){let t=this.generateDefaultContext();return t.color=H[this.indexColor++%(H.length-3)+2],t.symbol="",t}generateErrorContext(){let t=this.generateDefaultContext();return t.contextName=$.ERROR.contextName,t.name=t.contextName,t.color=H[0],t.symbol="\u274C",t.error=!0,t.logLevel=L.ERROR,t}setContext(t,o={}){o.contextName=t,o.name=t,o=ce(this,te,Me).call(this,o),f(this,w)[t]=o}getContext(t){return f(this,w)[t]}setContexts(t){Object.keys(t).forEach(r=>{let s=t[r]||{};this.setContext(r,s),t[r]=f(this,w)[r]})}getContexts(){return Object.freeze(f(this,w))}setTargets(t={}){let o={};if(Array.isArray(t))try{for(let r=0;r<t.length;++r){let s=t[r];if(typeof s=="string"||s instanceof String)o[s]=s;else if(typeof s=="object"){let i=null;for(let a in s){let l=s[a];if(a=a.trim(),!a){console.error("Invalid target");break}if(typeof l=="string"||l instanceof String){l=l.trim(),i=[a,l];break}if(typeof l=="number")break}i&&(o[i[0]]=i[1])}}}catch(r){console.error({lid:4321},r.message)}else o=t;le(this,F,Object.assign({},o,{...U}))}addTargets(t){let o=f(this,F),r=Object.assign({},o,t);this.setTargets(r)}getTargets(){return Object.freeze(f(this,F))}setActiveTargets(t=null){if(t===null){this.activeTargets=[U.ALL];return}else if(typeof t=="string"||t instanceof String)t=t.split(",");else if(typeof t=="object"||typeof t=="function")return;for(let o=0;o<t.length;++o)t[o]=t[o].trim();this.activeTargets=t}getActiveTarget(){return this.activeTargets}setActiveTarget(t){this.activeTargets=[],this.setActiveTargets(t),this.activeTargets=[this.activeTargets[0]]}setLogLevel(t,o){f(this,N)[t]=o}getLogLevel(t){return f(this,N)[t]}setLogLevels(t){le(this,N,t)}getLogLevels(){return Object.freeze(f(this,N))}isTargetAllowed(t){return!t||!this.activeTargets||!this.activeTargets.length||t===U.ALL||this.activeTargets.includes(U.ALL)?!0:this.activeTargets.includes(t)}setColumns(t,o,r){let s=0;for(let a in o){if(!["contextName","symbol","lid","text"].includes(a))continue;let l=o[a],h=document.createElement("span");h.classList.add("analogger-col",`analogger-col-${a}`,`analogger-col-${s}`),++s,h.textContent=l,t.append(h)}let i=document.createElement("span");i.classList.add("analogger-col","analogger-col-text",`analogger-col-${s}`),i.textContent=r,t.append(i);for(let a=1;a<=3;++a)i=document.createElement("span"),i.classList.add("analogger-col","analogger-col-extra",`analogger-extra-${a}`),t.append(i)}checkOnLoggingToDom(t,o){try{let r=t.onLoggingToDom;return typeof r!="function"?void 0:r.call(this,t,o)}catch{}}addLineToDom(t,o,{context:r,addType:s,message:i,text:a,args:l}){if(this.checkOnLoggingToDom(r,{message:i,text:a,args:l,logCounter:this.logCounter,$view:t,$line:o,addType:s})===!1)return;if(s===K.BOTTOM?t.append(o):t.insertBefore(o,t.firstChild),this.removeDomOldEntries(t)){if(t.getElementsByClassName(ue).length)return;this.showRemovedNotification(r);return}this.scrollDivToBottom(t)}showRemovedNotification(t){t.contextName=we,t.symbol="\u{1F5D1}",t.color="orange",t.className=ue,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(t,"",{addType:K.TOP,message:"Oldest entries removed"})},500)}writeLogToDom(t,o,{addType:r=K.BOTTOM,message:s="",args:i=null}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),o=s||o;for(let a=0;a<this.$containers.length;++a){let l=this.$containers[a],h=l.querySelector("."+ge);h||(h=document.createElement("div"),h.classList.add(ge),h.append(document.createElement("span")),h.append(document.createElement("span")),h.append(document.createElement("span")),l.append(h));let u=l.querySelector("."+pe);u||(u=document.createElement("div"),u.classList.add(pe),l.append(u));let d=l.querySelector("."+me);d||(d=document.createElement("div"),d.classList.add(me),d.append(document.createElement("span")),d.append(document.createElement("span")),d.append(document.createElement("span")),l.append(d));let p=document.createElement("div");p.classList.add(Re),t.className&&p.classList.add(t.className),p.style.color=t.color,this.setColumns(p,t,o,i),setTimeout(function(E,y,{addType:A,context:M,message:re,text:se,args:ne}){this.addLineToDom(E,y,{addType:A,context:M,message:re,text:se,args:ne})}.bind(this,u,p,{addType:r,context:t,message:s,text:o,args:i}),0)}}writeLogToFile(t){try{if(!fs.existsSync(this.options.logToFilePath)){let o=path.dirname(this.options.logToFilePath);fs.existsSync(o)||fs.mkdirSync(o,{recursive:!0}),fs.writeFileSync(this.options.logToFilePath,"")}if(this.options.logMaxSize&&fs.statSync(this.options.logToFilePath).size>this.options.logMaxSize){this.options.logIndexArchive<this.options.logMaxArchives?++this.options.logIndexArchive:this.options.logIndexArchive=1;let s=this.options.logMaxArchives.toString().length+1,{filePath:i,extension:a,basename:l,dirname:h}=lt(this.options.logToFilePath),u,d;u=this.options.addArchiveIndex?"."+this.options.logIndexArchive.toString().padStart(s,"0"):"",d=this.options.addArchiveTimestamp?"."+ct():"";let p=`${i}${d}${u}${a}`,E=this.options.compressArchives?`${i}.tar.gz`:"";ft(h,l,u,a,E,this.options.compressionLevel,y=>{y&&console.error("DELETION_FAILURE: Failed to delete some files")}),fs.renameSync(this.options.logToFilePath,p),fs.writeFileSync(this.options.logToFilePath,"")}fs.appendFileSync(this.options.logToFilePath,t+this.EOL)}catch(o){console.rawError("LOG_TO_FILE_FAILURE: ",o.message)}}writeLogToRemote(...t){try{let o=this.generateLogToRemoteUrl(this.options.logToRemoteUrl);if(!o)return null;let r=[...t],s=JSON.stringify(r);fetch(o,{method:"post",body:s,headers:{"Content-Type":"application/json"}}).then(i=>i.json()).catch(()=>null)}catch(o){console.rawError("LOG_TO_REMOTE_FAILURE: ",o.message)}}uploadDataToRemote(t,o=null,r=null){try{if(!this.options.logToRemote)return;let s=this.generateLogToRemoteUrl(this.options.logToRemoteBinaryUrl,{pathname:O.binarypathname});if(!s)return null;let i=t;o&&(i=JSON.stringify({raw:t,context:o})),fetch(s,{method:"post",body:i}).then(a=>a.json()).then(a=>r&&r(a)).catch(a=>a)}catch(s){console.rawError("BINARY_TO_REMOTE_FAILURE: ",s.message)}}stringifyEntry(t){let o;try{o=JSON.stringify(t)}catch{}if(!o)try{o=Ce(t)}catch{}return o}convertEntry(t){try{if(t==null||t==="")return t;if(typeof t=="boolean")return t;if(typeof t=="symbol"||typeof t=="number")return t;if(typeof t=="string"||myVar instanceof t)return t;if(t instanceof Date)return t}catch{}return this.stringifyEntry(t)}convertArgumentsToText(t){let o=[],r,s=t.length;for(let i=0;i<s;++i){let a,l=t[i];a=this.convertEntry(l),o.push(a)}return r=o.join("\u2022"),r}writeToConsole(t,o){let r=[t];this.isBrowser()&&r.push(`color: ${o.color}`);let s=o.contextLevel||L.LOG;s>=L.ERROR?f(this,D).call(this,...r):s>=L.WARN?f(this,_).call(this,...r):s>=L.INFO?f(this,C).call(this,...r):s>=L.LOG?f(this,b).call(this,...r):s>=L.DEBUG&&f(this,ee).call(this,...r)}checkPlugins(t,{message:o,text:r,args:s,logCounter:i}){try{if(!Object.keys(g.pluginTable).length)return;let a=!0;for(let l in t){let h=t[l];if(!h)continue;let u=g.pluginTable[l];if(!u||typeof u!="object")continue;let{callback:d,methodName:p,type:E}=u;if(typeof d!="function")continue;d.call(this,t,{message:o,text:r,args:s,logCounter:i,methodName:p,type:E,pluginOptions:h})===!1&&(a=!1)}return a}catch{}}checkOnLogging(t,o,r,s){if(!!s)try{let i=t[s];return typeof i!="function"?void 0:i.call(this,o,r)}catch{}}processOutput(t={}){try{let o="";if(this.applySymbolByName(t),this.checkOnLogging(t,t,arguments,"onContext"),!this.isTargetAllowed(t.target)||t.logLevel===L.OFF||this.options.requiredLogLevel>t.logLevel)return;let r=this.checkOnLogging(t,arguments&&arguments.length>1?arguments[1]:arguments,arguments,"onMessage");r!==void 0&&(arguments[1]=r);let s=Array.prototype.slice.call(arguments,1);o=this.convertArgumentsToText(s);let i="",a=this.format({...t,message:o});this.keepLog&&this.addToLogHistory({context:t,message:o,text:a}),++this.logCounter;let l=this.checkOnLogging(t,a,{message:o,args:s,logCounter:this.logCounter},"onOutput");if(l===!1||((typeof l=="string"||l instanceof String)&&(a=l),l=this.checkPlugins(t,{message:o,text:a,args:s,logCounter:this.logCounter}),l===!1)||(this.options.logToRemote&&this.writeLogToRemote(t,...s),this.isBrowser()?(t.environnment=g.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(t,a,{message:o,args:s}),i=`%c${a}`):(t.environnment=g.ENVIRONMENT_TYPE.NODE,i=X.getTextFromColor(a,{fg:t.color,bg:t.bgColor,isBold:t.bold,isUnderline:t.underline,isReversed:t.reversed}),this.options.logToFile&&this.writeLogToFile(a)),this.options.hideLog||t.hideLog||t.silent))return;this.writeToConsole(i,t),this.errorTargetHandler(t,s)}catch(o){console.rawError("AnaLogger:",o.message)}}isExtendedOptionsPassed(t){return typeof t!="object"?!1:t.hasOwnProperty("context")||t.hasOwnProperty("target")||t.hasOwnProperty("color")||t.hasOwnProperty("contextName")||t.hasOwnProperty("raw")||t.hasOwnProperty("lid")}extractContextFromInput(t){return(typeof t=="string"||t instanceof String)&&t.toLowerCase().indexOf("lid:")!==0,t}listSymbols(){for(let t in Z)console.rawLog(Z[t]+` ${t} `)}applySymbolByName(t){try{t.symbol&&Z[t.symbol]&&(t.symbol=Z[t.symbol])}catch{}}convertToContext(t,o){t=t||o;let r=t;if(t.context&&typeof t.context=="object"){let s=Object.assign({},t);delete s.context,r=Object.assign({},t.context,s)}return r=Object.assign({},o,r),delete r.context,r}log(t,...o){if(t=this.extractContextFromInput(t),!this.isExtendedOptionsPassed(t)){let i=this.generateDefaultContext();this.processOutput.apply(this,[i,t,...o]);return}let r=this.generateDefaultContext(),s=this.convertToContext(t,r);if(s.raw){f(this,b).call(this,...o);return}this.processOutput.apply(this,[s,...o])}error(t,...o){if(this.options.hideError)return;if(t=this.extractContextFromInput(t),!this.isExtendedOptionsPassed(t)){let a=this.generateErrorContext();this.processOutput.apply(this,[a,t,...o]);return}let r=this.generateErrorContext(),s=this.convertToContext(t,r),i=Array.prototype.slice.call(arguments,1);this.log(s,...i)}overrideError(){this.options.hideHookMessage||f(this,b).call(this,"AnaLogger: Hook placed on console.error"),f(this,S).error=!0,console.error=this.onDisplayError.bind(this)}attachConsole(){try{return console.rawLog=f(this,b),console.raw=f(this,b),console.rawInfo=f(this,C),console.rawWarn=f(this,_),console.rawError=f(this,D),console.logHistory=this.logHistory,console.logHistory=this.logHistory,gt.forEach(t=>{console[t]=function(...o){this[t](...o)}.bind(this)}),!0}catch(t){console.error({lid:4321},t.message)}return!1}overrideConsole({log:t=!0,info:o=!0,warn:r=!0,error:s=!1}={}){this.options.hideHookMessage||f(this,b).call(this,"AnaLogger: Hook placed on console.log"),[{log:t},{info:o},{warn:r}].forEach(function(i){let a=Object.keys(i)[0];i[a]&&(f(this,S)[a]=!0,console[a]=this.onDisplayLog.bind(this))}.bind(this)),s&&this.overrideError(),this.attachConsole()}removeOverrideError(){console.error=f(this,D),f(this,S).error=!1}removeOverride({log:t=!0,info:o=!0,warn:r=!0,error:s=!1}={}){t&&(console.log=f(this,b),f(this,S).log=!1),o&&(console.info=f(this,C),f(this,S).info=!1),r&&(console.warn=f(this,_),f(this,S).warn=!1),s&&this.removeOverrideError()}info(...t){return this.log(...t)}warn(...t){return this.log(...t)}table(...t){if(!f(this,S).log){f(this,z).call(this,...t);return}let o=console.log;console.log=f(this,b),f(this,z).call(this,...t),console.log=o}alert(...t){if(!this.isBrowser())return this.log(...t);let o;if(t&&(t[0]&&t[0].hasOwnProperty("lid")||this.isContextValid(t[0]))){let r=this.generateDefaultContext();o=this.convertToContext(t[0],r).lid+": "+t.slice(1).join(" | ")}else o=t.join(" | ");alert(o)}assert(t,o=!0,...r){let s;try{return typeof t=="function"?(s=t(...r),s!==o?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):t!==o?(this.error("Assert failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)}catch{this.error("Unexpected error in assert")}return!1}applyAnalogFormatting({activeTarget:t="",override:o=!1}={}){try{let s={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"}};return this.setDefaultContext(s.DEFAULT),t&&this.setActiveTarget(t),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:6}),o&&(this.overrideConsole(),this.overrideError()),!0}catch(r){console.error({lid:3249},r.message)}return!1}applyPredefinedFormat(t=Q.DEFAULT_FORMAT,{activeTarget:o="",override:r=!1}={}){if(t===Q.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:o,override:r})}static generateInstance(){return new g}static getInstance(t=0){return g.instanceCount?f(g,q)[t]:null}static generateMainInstance(){let t=g.getInstance();return t||new g}static startLogger(){g.generateMainInstance().applyPredefinedFormat(Q.DEFAULT_FORMAT,{override:!0})}static stopLogger(){let t=g.generateMainInstance();t.removeOverride(),t.removeOverrideError()}convertToUrl({protocol:t=O.protocol,host:o=O.host,port:r=O.port,pathname:s=O.pathname}={}){let i=new URL("http://localhost");return i.protocol=t,i.host=o,i.port=r,s&&(i.pathname=s),i.toString()}generateLogToRemoteUrl(t=null,{pathname:o=O.pathname}={}){if(typeof t=="string"||t instanceof String)return t;if(!this.isBrowser())return null;let r=this.options.protocol||window.location.protocol+"//",s=this.options.host||window.location.host||O.host,i=this.options.port||O.port;return o=this.options.pathname||o,this.convertToUrl({protocol:r,host:s,port:i,pathname:o})}addPlugin(t,o,r=""){r=r||t,this[t]=o,g.pluginTable[r]={type:_e.LOCAL,methodName:t,callback:o}}addGlobalPlugin(t,o,r){g[t]=o,g.pluginTable[r]={type:_e.GLOBAL,methodName:t,callback:o}}getPluginList(){return Object.keys(g.pluginTable)}validatePlugin(t){return g.pluginTable[t]?!0:(console.warn(`The plugin ${t} is not registered`),!1)}},v=g;q=new WeakMap,w=new WeakMap,F=new WeakMap,N=new WeakMap,b=new WeakMap,C=new WeakMap,_=new WeakMap,D=new WeakMap,ee=new WeakMap,z=new WeakMap,S=new WeakMap,te=new WeakSet,Me=function(t){let o=this.generateNewContext(),r=Object.assign({},o,t);return r.color.toLowerCase().indexOf("rgb")>-1?r.color=X.rgbStringToHex(r.color):r.color.indexOf("#")===-1&&(r.color=X.colorNameToHex(r.color)),r},oe=new WeakSet,Ie=function(){try{this.setTargets(U),this.setLogLevels(L),this.setContexts($)}catch(t){console.error({lid:4321},t.message)}return!1},T(v,q,[]),m(v,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),m(v,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),m(v,"instanceCount",0),m(v,"pluginTable",{});var pt=v,St=pt,Rt=v.generateMainInstance();var wt=v;export{wt as AnaLogger,$ as DEFAULT_LOG_CONTEXTS,L as DEFAULT_LOG_LEVELS,U as DEFAULT_LOG_TARGETS,Rt as anaLogger,St as default};
|
|
4
|
+
`,i+=`[${d}] ${t} ${r} ${h}`)}return i}catch(i){console.rawError(i.message)}return""}onErrorForUserTarget(t,...o){this.errorUserTargetHandler(t,...o)}onError(t,...o){t.target===m(this,R).USER&&this.onErrorForUserTarget(t,...o)}onDisplayLog(...t){this.log(...t)}assistStask(t){try{let o=t.stack.split(`
|
|
5
|
+
`),r=[];for(let n=0;n<o.length;++n){let i=o[n];r.push(i)}return r}catch(o){console.rawError(o.message)}return t.message}onDisplayError(...t){try{let o=-1,r=null;for(let n=0;n<t.length;++n){let i=t[n];if(i instanceof Error&&i.stack){o=n,r=this.assistStask(i)||[];break}}if(!r){this.error(...t);return}for(let n=0;n<r.length;++n)t[o]=r[n],this.error(...t)}catch(o){console.rawError(o)}}setLogFormat(t){if(typeof t!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=t.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(t){this.errorTargetHandler=t.bind(this)}setErrorHandlerForUserTarget(t){this.errorUserTargetHandler=t.bind(this)}isContextValid(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null?t.hasOwnProperty("contextName")&&t.hasOwnProperty("target"):!1}setDefaultContext(t){this.setContext(B.DEFAULT.contextName,t)}generateDefaultContext(){let t=m(this,S)[B.DEFAULT.contextName]||{};return t=Object.assign({},{lid:"",contextName:B.DEFAULT.contextName,target:I.ALL,symbol:"\u26A1",color:M[1],logLevel:L.LOG},t),t.name=t.contextName,t.id=this.logIndex++,t}generateNewContext(){let t=this.generateDefaultContext();return t.color=M[this.indexColor++%(M.length-3)+2],t.symbol="",t}generateErrorContext(){let t=this.generateDefaultContext();return t.contextName=B.ERROR.contextName,t.name=t.contextName,t.color=M[0],t.symbol="\u274C",t.error=!0,t.logLevel=L.ERROR,t}setContext(t,o={}){o.contextName=t,o.name=t,o=re(this,J,Re).call(this,o),m(this,S)[t]=o}getContext(t){return m(this,S)[t]}setContexts(t){Object.keys(t).forEach(r=>{let n=t[r]||{};this.setContext(r,n),t[r]=m(this,S)[r]})}getContexts(){return Object.freeze(m(this,S))}setTargets(t={}){let o={};if(Array.isArray(t))try{for(let r=0;r<t.length;++r){let n=t[r];if(typeof n=="string"||n instanceof String)o[n]=n;else if(typeof n=="object"){let i=null;for(let l in n){let a=n[l];if(l=l.trim(),!l){console.error("Invalid target");break}if(typeof a=="string"||a instanceof String){a=a.trim(),i=[l,a];break}if(typeof a=="number")break}i&&(o[i[0]]=i[1])}}}catch(r){console.error({lid:4321},r.message)}else o=t;oe(this,R,Object.assign({},o,{...I}))}addTargets(t){let o=m(this,R),r=Object.assign({},o,t);this.setTargets(r)}getTargets(){return Object.freeze(m(this,R))}setActiveTargets(t=null){if(t===null){this.activeTargets=[I.ALL];return}else if(typeof t=="string"||t instanceof String)t=t.split(",");else if(typeof t=="object"||typeof t=="function")return;for(let o=0;o<t.length;++o)t[o]=t[o].trim();this.activeTargets=t}getActiveTarget(){return this.activeTargets}setActiveTarget(t){this.activeTargets=[],this.setActiveTargets(t),this.activeTargets=[this.activeTargets[0]]}setLogLevel(t,o){m(this,C)[t]=o}getLogLevel(t){return m(this,C)[t]}setLogLevels(t){oe(this,C,t)}getLogLevels(){return Object.freeze(m(this,C))}isTargetAllowed(t){return!t||!this.activeTargets||!this.activeTargets.length||t===I.ALL||this.activeTargets.includes(I.ALL)?!0:this.activeTargets.includes(t)}setColumns(t,o,r){let n=0;for(let l in o){if(!["contextName","symbol","lid","text"].includes(l))continue;let a=o[l],h=document.createElement("span");h.classList.add("analogger-col",`analogger-col-${l}`,`analogger-col-${n}`),++n,h.textContent=a,t.append(h)}let i=document.createElement("span");i.classList.add("analogger-col","analogger-col-text",`analogger-col-${n}`),i.textContent=r,t.append(i);for(let l=1;l<=3;++l)i=document.createElement("span"),i.classList.add("analogger-col","analogger-col-extra",`analogger-extra-${l}`),t.append(i)}checkOnLoggingToDom(t,o){try{let r=t.onLoggingToDom;return typeof r!="function"?void 0:r.call(this,t,o)}catch{}}addLineToDom(t,o,{context:r,addType:n,message:i,text:l,args:a}){if(this.checkOnLoggingToDom(r,{message:i,text:l,args:a,logCounter:this.logCounter,$view:t,$line:o,addType:n})===!1)return;if(n===W.BOTTOM?t.append(o):t.insertBefore(o,t.firstChild),this.removeDomOldEntries(t)){if(t.getElementsByClassName(le).length)return;this.showRemovedNotification(r);return}this.scrollDivToBottom(t)}showRemovedNotification(t){t.contextName=Oe,t.symbol="\u{1F5D1}",t.color="orange",t.className=le,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(t,"",{addType:W.TOP,message:"Oldest entries removed"})},500)}writeLogToDom(t,o,{addType:r=W.BOTTOM,message:n="",args:i=null}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),o=n||o;for(let l=0;l<this.$containers.length;++l){let a=this.$containers[l],h=a.querySelector("."+ae);h||(h=document.createElement("div"),h.classList.add(ae),h.append(document.createElement("span")),h.append(document.createElement("span")),h.append(document.createElement("span")),a.append(h));let u=a.querySelector("."+ce);u||(u=document.createElement("div"),u.classList.add(ce),a.append(u));let d=a.querySelector("."+fe);d||(d=document.createElement("div"),d.classList.add(fe),d.append(document.createElement("span")),d.append(document.createElement("span")),d.append(document.createElement("span")),a.append(d));let g=document.createElement("div");g.classList.add(be),t.className&&g.classList.add(t.className),g.style.color=t.color,this.setColumns(g,t,o,i),setTimeout(function(y,E,{addType:O,context:F,message:K,text:Q,args:Z}){this.addLineToDom(y,E,{addType:O,context:F,message:K,text:Q,args:Z})}.bind(this,u,g,{addType:r,context:t,message:n,text:o,args:i}),0)}}writeLogToFile(t){try{if(!fs.existsSync(this.options.logToFilePath)){let o=path.dirname(this.options.logToFilePath);fs.existsSync(o)||fs.mkdirSync(o,{recursive:!0}),fs.writeFileSync(this.options.logToFilePath,"")}if(this.options.logMaxSize&&fs.statSync(this.options.logToFilePath).size>this.options.logMaxSize){this.options.logIndexArchive<this.options.logMaxArchives?++this.options.logIndexArchive:this.options.logIndexArchive=1;let n=this.options.logMaxArchives.toString().length+1,{filePath:i,extension:l,basename:a,dirname:h}=ot(this.options.logToFilePath),u,d;u=this.options.addArchiveIndex?"."+this.options.logIndexArchive.toString().padStart(n,"0"):"",d=this.options.addArchiveTimestamp?"."+rt():"";let g=`${i}${d}${u}${l}`,y=this.options.compressArchives?`${i}.tar.gz`:"";nt(h,a,u,l,y,this.options.compressionLevel,E=>{E&&console.error("DELETION_FAILURE: Failed to delete some files")}),fs.renameSync(this.options.logToFilePath,g),fs.writeFileSync(this.options.logToFilePath,"")}fs.appendFileSync(this.options.logToFilePath,t+this.EOL)}catch(o){console.rawError("LOG_TO_FILE_FAILURE: ",o.message)}}writeLogToRemote(...t){try{let o=this.generateLogToRemoteUrl(this.options.logToRemoteUrl);if(!o)return null;let r=[...t],n=JSON.stringify(r);fetch(o,{method:"post",body:n,headers:{"Content-Type":"application/json"}}).then(i=>i.json()).catch(()=>null)}catch(o){console.rawError("LOG_TO_REMOTE_FAILURE: ",o.message)}}uploadDataToRemote(t,o=null,r=null){try{if(!this.options.logToRemote)return;let n=this.generateLogToRemoteUrl(this.options.logToRemoteBinaryUrl,{pathname:T.binarypathname});if(!n)return null;let i=t;o&&(i=JSON.stringify({raw:t,context:o})),fetch(n,{method:"post",body:i}).then(l=>l.json()).then(l=>r&&r(l)).catch(l=>l)}catch(n){console.rawError("BINARY_TO_REMOTE_FAILURE: ",n.message)}}stringifyEntry(t){let o;try{o=JSON.stringify(t)}catch{}if(!o)try{o=ve(t)}catch{}return o}convertEntry(t){try{if(t==null||t==="")return t;if(typeof t=="boolean")return t;if(typeof t=="symbol"||typeof t=="number")return t;if(typeof t=="string"||myVar instanceof t)return t;if(t instanceof Date)return t}catch{}return this.stringifyEntry(t)}convertArgumentsToText(t){let o=[],r,n=t.length;for(let i=0;i<n;++i){let l,a=t[i];l=this.convertEntry(a),o.push(l)}return r=o.join("\u2022"),r}writeToConsole(t,o){let r=[t];this.isBrowser()&&r.push(`color: ${o.color}`);let n=o.contextLevel||L.LOG;n>=L.ERROR?f.Console.error(...r):n>=L.WARN?f.Console.warn(...r):n>=L.INFO?f.Console.info(...r):n>=L.LOG?f.Console.log(...r):n>=L.DEBUG&&f.Console.debug(...r)}checkPlugins(t,{message:o,text:r,args:n,logCounter:i}){try{if(!Object.keys(f.pluginTable).length)return;let l=!0;for(let a in t){let h=t[a];if(!h)continue;let u=f.pluginTable[a];if(!u||typeof u!="object")continue;let{callback:d,methodName:g,type:y}=u;if(typeof d!="function")continue;d.call(this,t,{message:o,text:r,args:n,logCounter:i,methodName:g,type:y,pluginOptions:h})===!1&&(l=!1)}return l}catch{}}checkOnLogging(t,o,r,n){if(!!n)try{let i=t[n];return typeof i!="function"?void 0:i.call(this,o,r)}catch{}}processOutput(t={}){try{let o="";if(this.applySymbolByName(t),this.checkOnLogging(t,t,arguments,"onContext"),!this.isTargetAllowed(t.target)||t.logLevel===L.OFF||this.options.requiredLogLevel>t.logLevel)return;let r=this.checkOnLogging(t,arguments&&arguments.length>1?arguments[1]:arguments,arguments,"onMessage");r!==void 0&&(arguments[1]=r);let n=Array.prototype.slice.call(arguments,1);o=this.convertArgumentsToText(n);let i="",l=this.format({...t,message:o});this.keepLog&&this.addToLogHistory({context:t,message:o,text:l}),++this.logCounter;let a=this.checkOnLogging(t,l,{message:o,args:n,logCounter:this.logCounter},"onOutput");if(a===!1||((typeof a=="string"||a instanceof String)&&(l=a),a=this.checkPlugins(t,{message:o,text:l,args:n,logCounter:this.logCounter}),a===!1)||(this.options.logToRemote&&this.writeLogToRemote(t,...n),this.isBrowser()?(t.environnment=f.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(t,l,{message:o,args:n}),i=`%c${l}`):(t.environnment=f.ENVIRONMENT_TYPE.NODE,i=z.getTextFromColor(l,{fg:t.color,bg:t.bgColor,isBold:t.bold,isUnderline:t.underline,isReversed:t.reversed}),this.options.logToFile&&this.writeLogToFile(l)),this.options.hideLog||t.hideLog||t.silent))return;this.writeToConsole(i,t),this.errorTargetHandler(t,n)}catch(o){console.rawError("AnaLogger:",o.message)}}isExtendedOptionsPassed(t){return typeof t!="object"?!1:t.hasOwnProperty("context")||t.hasOwnProperty("target")||t.hasOwnProperty("color")||t.hasOwnProperty("contextName")||t.hasOwnProperty("raw")||t.hasOwnProperty("lid")}extractContextFromInput(t){return(typeof t=="string"||t instanceof String)&&t.toLowerCase().indexOf("lid:")!==0,t}listSymbols(){for(let t in V)console.rawLog(V[t]+` ${t} `)}applySymbolByName(t){try{t.symbol&&V[t.symbol]&&(t.symbol=V[t.symbol])}catch{}}convertToContext(t,o){t=t||o;let r=t;if(t.context&&typeof t.context=="object"){let n=Object.assign({},t);delete n.context,r=Object.assign({},t.context,n)}return r=Object.assign({},o,r),delete r.context,r}log(t,...o){if(t=this.extractContextFromInput(t),!this.isExtendedOptionsPassed(t)){let i=this.generateDefaultContext();this.processOutput.apply(this,[i,t,...o]);return}let r=this.generateDefaultContext(),n=this.convertToContext(t,r);if(n.raw){f.Console.log(...o);return}this.processOutput.apply(this,[n,...o])}error(t,...o){if(this.options.hideError)return;if(t=this.extractContextFromInput(t),!this.isExtendedOptionsPassed(t)){let l=this.generateErrorContext();this.processOutput.apply(this,[l,t,...o]);return}let r=this.generateErrorContext(),n=this.convertToContext(t,r),i=Array.prototype.slice.call(arguments,1);this.log(n,...i)}overrideError(){this.options.hideHookMessage||f.Console.log("AnaLogger: Hook placed on console.error"),m(this,A).error=!0,console.error=this.onDisplayError.bind(this)}attachConsole(){try{return console.rawLog=f.Console.log,console.raw=f.Console.log,console.rawInfo=f.Console.info,console.rawWarn=f.Console.warn,console.rawError=f.Console.error,console.logHistory=this.logHistory,console.logHistory=this.logHistory,at.forEach(t=>{console[t]=function(...o){this[t](...o)}.bind(this)}),!0}catch(t){console.error({lid:4321},t.message)}return!1}overrideConsole({log:t=!0,info:o=!0,warn:r=!0,error:n=!1}={}){this.options.hideHookMessage||f.Console.log("AnaLogger: Hook placed on console.log"),[{log:t},{info:o},{warn:r}].forEach(function(i){let l=Object.keys(i)[0];i[l]&&(m(this,A)[l]=!0,console[l]=this.onDisplayLog.bind(this))}.bind(this)),n&&this.overrideError(),this.attachConsole()}removeOverrideError(){console.error=f.Console.error,m(this,A).error=!1}removeOverride({log:t=!0,info:o=!0,warn:r=!0,error:n=!1}={}){t&&(console.log=f.Console.log,m(this,A).log=!1),o&&(console.info=f.Console.info,m(this,A).info=!1),r&&(console.warn=f.Console.warn,m(this,A).warn=!1),n&&this.removeOverrideError()}info(...t){return this.log(...t)}warn(...t){return this.log(...t)}table(...t){if(!m(this,A).log){f.Console.table(...t);return}let o=console.log;console.log=f.Console.log,f.Console.table(...t),console.log=o}alert(...t){if(!this.isBrowser())return this.log(...t);let o;if(t&&(t[0]&&t[0].hasOwnProperty("lid")||this.isContextValid(t[0]))){let r=this.generateDefaultContext();o=this.convertToContext(t[0],r).lid+": "+t.slice(1).join(" | ")}else o=t.join(" | ");alert(o)}assert(t,o=!0,...r){let n;try{return typeof t=="function"?(n=t(...r),n!==o?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):t!==o?(this.error("Assert failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)}catch{this.error("Unexpected error in assert")}return!1}applyAnalogFormatting({activeTarget:t="",override:o=!1}={}){try{let n={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"}};return this.setDefaultContext(n.DEFAULT),t&&this.setActiveTarget(t),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:6}),o&&(this.overrideConsole(),this.overrideError()),!0}catch(r){console.error({lid:3249},r.message)}return!1}applyPredefinedFormat(t=Y.DEFAULT_FORMAT,{activeTarget:o="",override:r=!1}={}){if(t===Y.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:o,override:r})}static generateInstance(){return new f}static getInstance(t=0){return f.instanceCount?m(f,P)[t]:null}static generateMainInstance(){let t=f.getInstance();return t||new f}static startLogger(){f.generateMainInstance().applyPredefinedFormat(Y.DEFAULT_FORMAT,{override:!0})}static stopLogger(){let t=f.generateMainInstance();t.removeOverride(),t.removeOverrideError()}convertToUrl({protocol:t=T.protocol,host:o=T.host,port:r=T.port,pathname:n=T.pathname}={}){let i=new URL("http://localhost");return i.protocol=t,i.host=o,i.port=r,n&&(i.pathname=n),i.toString()}generateLogToRemoteUrl(t=null,{pathname:o=T.pathname}={}){if(typeof t=="string"||t instanceof String)return t;if(!this.isBrowser())return null;let r=this.options.protocol||window.location.protocol+"//",n=this.options.host||window.location.host||T.host,i=this.options.port||T.port;return o=this.options.pathname||o,this.convertToUrl({protocol:r,host:n,port:i,pathname:o})}addPlugin(t,o,r=""){r=r||t,this[t]=o,f.pluginTable[r]={type:we.LOCAL,methodName:t,callback:o}}addGlobalPlugin(t,o,r){f[t]=o,f.pluginTable[r]={type:we.GLOBAL,methodName:t,callback:o}}getPluginList(){return Object.keys(f.pluginTable)}validatePlugin(t){return f.pluginTable[t]?!0:(console.warn(`The plugin ${t} is not registered`),!1)}},b=f;P=new WeakMap,S=new WeakMap,R=new WeakMap,C=new WeakMap,A=new WeakMap,J=new WeakSet,Re=function(t){let o=this.generateNewContext(),r=Object.assign({},o,t);return r.color.toLowerCase().indexOf("rgb")>-1?r.color=z.rgbStringToHex(r.color):r.color.indexOf("#")===-1&&(r.color=z.colorNameToHex(r.color)),r},X=new WeakSet,Ce=function(){try{this.setTargets(I),this.setLogLevels(L),this.setContexts(B)}catch(t){console.error({lid:4321},t.message)}return!1},v(b,P,[]),p(b,"Console",null),p(b,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),p(b,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),p(b,"instanceCount",0),p(b,"pluginTable",{});var ct=b,Tt=ct,bt=b.generateMainInstance();var Ot=b;export{Ot as AnaLogger,B as DEFAULT_LOG_CONTEXTS,L as DEFAULT_LOG_LEVELS,I as DEFAULT_LOG_TARGETS,bt as anaLogger,Tt as default};
|
|
6
6
|
|
package/esm/ana-logger.mjs
CHANGED
|
@@ -430,20 +430,13 @@ class ____AnaLogger
|
|
|
430
430
|
hideHookMessage: false
|
|
431
431
|
};
|
|
432
432
|
|
|
433
|
-
|
|
434
|
-
#realConsoleInfo = console.info;
|
|
435
|
-
#realConsoleWarn = console.warn;
|
|
436
|
-
#realConsoleError = console.error;
|
|
437
|
-
#realConsoleDebug = console.debug;
|
|
438
|
-
#realConsoleTable = console.table;
|
|
433
|
+
static Console = null;
|
|
439
434
|
|
|
440
435
|
#overridenMap = {
|
|
441
436
|
log : false,
|
|
442
437
|
info : false,
|
|
443
438
|
warn : false,
|
|
444
439
|
error: false,
|
|
445
|
-
debug: false,
|
|
446
|
-
table: false,
|
|
447
440
|
};
|
|
448
441
|
|
|
449
442
|
static ALIGN = {
|
|
@@ -482,10 +475,21 @@ class ____AnaLogger
|
|
|
482
475
|
|
|
483
476
|
this.setOptions(this.options);
|
|
484
477
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
478
|
+
if (!____AnaLogger.Console) {
|
|
479
|
+
____AnaLogger.Console = {
|
|
480
|
+
log: console.log,
|
|
481
|
+
info: console.info,
|
|
482
|
+
warn: console.warn,
|
|
483
|
+
error: console.error,
|
|
484
|
+
debug: console.debug,
|
|
485
|
+
table: console.table
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
this.rawLog = ____AnaLogger.Console.log;
|
|
490
|
+
this.rawInfo = ____AnaLogger.Console.info;
|
|
491
|
+
this.rawWarn = ____AnaLogger.Console.warn;
|
|
492
|
+
this.rawError = ____AnaLogger.Console.error;
|
|
489
493
|
|
|
490
494
|
this.ALIGN = ____AnaLogger.ALIGN;
|
|
491
495
|
this.ENVIRONMENT_TYPE = ____AnaLogger.ENVIRONMENT_TYPE;
|
|
@@ -1770,23 +1774,23 @@ class ____AnaLogger
|
|
|
1770
1774
|
const contextLevel = context.contextLevel || DEFAULT_LOG_LEVELS.LOG;
|
|
1771
1775
|
if (contextLevel >= DEFAULT_LOG_LEVELS.ERROR)
|
|
1772
1776
|
{
|
|
1773
|
-
|
|
1777
|
+
____AnaLogger.Console.error(...res);
|
|
1774
1778
|
}
|
|
1775
1779
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.WARN)
|
|
1776
1780
|
{
|
|
1777
|
-
|
|
1781
|
+
____AnaLogger.Console.warn(...res);
|
|
1778
1782
|
}
|
|
1779
1783
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.INFO)
|
|
1780
1784
|
{
|
|
1781
|
-
|
|
1785
|
+
____AnaLogger.Console.info(...res);
|
|
1782
1786
|
}
|
|
1783
1787
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.LOG)
|
|
1784
1788
|
{
|
|
1785
|
-
|
|
1789
|
+
____AnaLogger.Console.log(...res);
|
|
1786
1790
|
}
|
|
1787
1791
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.DEBUG)
|
|
1788
1792
|
{
|
|
1789
|
-
|
|
1793
|
+
____AnaLogger.Console.debug(...res);
|
|
1790
1794
|
}
|
|
1791
1795
|
|
|
1792
1796
|
}
|
|
@@ -2137,7 +2141,7 @@ class ____AnaLogger
|
|
|
2137
2141
|
|
|
2138
2142
|
if (context.raw)
|
|
2139
2143
|
{
|
|
2140
|
-
|
|
2144
|
+
____AnaLogger.Console.log(...args);
|
|
2141
2145
|
return;
|
|
2142
2146
|
}
|
|
2143
2147
|
|
|
@@ -2173,7 +2177,7 @@ class ____AnaLogger
|
|
|
2173
2177
|
{
|
|
2174
2178
|
if (!this.options.hideHookMessage)
|
|
2175
2179
|
{
|
|
2176
|
-
|
|
2180
|
+
____AnaLogger.Console.log("AnaLogger: Hook placed on console.error");
|
|
2177
2181
|
}
|
|
2178
2182
|
this.#overridenMap.error = true;
|
|
2179
2183
|
console.error = this.onDisplayError.bind(this);
|
|
@@ -2183,12 +2187,12 @@ class ____AnaLogger
|
|
|
2183
2187
|
{
|
|
2184
2188
|
try
|
|
2185
2189
|
{
|
|
2186
|
-
console.rawLog =
|
|
2187
|
-
console.raw =
|
|
2190
|
+
console.rawLog = ____AnaLogger.Console.log;
|
|
2191
|
+
console.raw = ____AnaLogger.Console.log;
|
|
2188
2192
|
|
|
2189
|
-
console.rawInfo =
|
|
2190
|
-
console.rawWarn =
|
|
2191
|
-
console.rawError =
|
|
2193
|
+
console.rawInfo = ____AnaLogger.Console.info;
|
|
2194
|
+
console.rawWarn = ____AnaLogger.Console.warn;
|
|
2195
|
+
console.rawError = ____AnaLogger.Console.error;
|
|
2192
2196
|
|
|
2193
2197
|
console.logHistory = this.logHistory;
|
|
2194
2198
|
|
|
@@ -2215,7 +2219,7 @@ class ____AnaLogger
|
|
|
2215
2219
|
{
|
|
2216
2220
|
if (!this.options.hideHookMessage)
|
|
2217
2221
|
{
|
|
2218
|
-
|
|
2222
|
+
____AnaLogger.Console.log("AnaLogger: Hook placed on console.log");
|
|
2219
2223
|
}
|
|
2220
2224
|
|
|
2221
2225
|
[{log}, {info}, {warn},].forEach(function (methodObj)
|
|
@@ -2238,7 +2242,7 @@ class ____AnaLogger
|
|
|
2238
2242
|
|
|
2239
2243
|
removeOverrideError()
|
|
2240
2244
|
{
|
|
2241
|
-
console.error =
|
|
2245
|
+
console.error = ____AnaLogger.Console.error;
|
|
2242
2246
|
this.#overridenMap.error = false;
|
|
2243
2247
|
}
|
|
2244
2248
|
|
|
@@ -2246,19 +2250,19 @@ class ____AnaLogger
|
|
|
2246
2250
|
{
|
|
2247
2251
|
if (log)
|
|
2248
2252
|
{
|
|
2249
|
-
console.log =
|
|
2253
|
+
console.log = ____AnaLogger.Console.log;
|
|
2250
2254
|
this.#overridenMap.log = false;
|
|
2251
2255
|
}
|
|
2252
2256
|
|
|
2253
2257
|
if (info)
|
|
2254
2258
|
{
|
|
2255
|
-
console.info =
|
|
2259
|
+
console.info = ____AnaLogger.Console.info;
|
|
2256
2260
|
this.#overridenMap.info = false;
|
|
2257
2261
|
}
|
|
2258
2262
|
|
|
2259
2263
|
if (warn)
|
|
2260
2264
|
{
|
|
2261
|
-
console.warn =
|
|
2265
|
+
console.warn = ____AnaLogger.Console.warn;
|
|
2262
2266
|
this.#overridenMap.warn = false;
|
|
2263
2267
|
}
|
|
2264
2268
|
|
|
@@ -2283,13 +2287,13 @@ class ____AnaLogger
|
|
|
2283
2287
|
{
|
|
2284
2288
|
if (!this.#overridenMap.log)
|
|
2285
2289
|
{
|
|
2286
|
-
|
|
2290
|
+
____AnaLogger.Console.table(...args);
|
|
2287
2291
|
return;
|
|
2288
2292
|
}
|
|
2289
2293
|
|
|
2290
2294
|
const currentLog = console.log;
|
|
2291
|
-
console.log =
|
|
2292
|
-
|
|
2295
|
+
console.log = ____AnaLogger.Console.log;
|
|
2296
|
+
____AnaLogger.Console.table(...args);
|
|
2293
2297
|
console.log = currentLog;
|
|
2294
2298
|
}
|
|
2295
2299
|
|
|
@@ -2436,8 +2440,7 @@ class ____AnaLogger
|
|
|
2436
2440
|
|
|
2437
2441
|
static generateInstance()
|
|
2438
2442
|
{
|
|
2439
|
-
|
|
2440
|
-
return analogger;
|
|
2443
|
+
return new ____AnaLogger();
|
|
2441
2444
|
}
|
|
2442
2445
|
|
|
2443
2446
|
/**
|
package/package.json
CHANGED
package/src/ana-logger.cjs
CHANGED
|
@@ -416,20 +416,13 @@ class ____AnaLogger
|
|
|
416
416
|
hideHookMessage: false
|
|
417
417
|
};
|
|
418
418
|
|
|
419
|
-
|
|
420
|
-
#realConsoleInfo = console.info;
|
|
421
|
-
#realConsoleWarn = console.warn;
|
|
422
|
-
#realConsoleError = console.error;
|
|
423
|
-
#realConsoleDebug = console.debug;
|
|
424
|
-
#realConsoleTable = console.table;
|
|
419
|
+
static Console = null;
|
|
425
420
|
|
|
426
421
|
#overridenMap = {
|
|
427
422
|
log : false,
|
|
428
423
|
info : false,
|
|
429
424
|
warn : false,
|
|
430
425
|
error: false,
|
|
431
|
-
debug: false,
|
|
432
|
-
table: false,
|
|
433
426
|
};
|
|
434
427
|
|
|
435
428
|
static ALIGN = {
|
|
@@ -468,10 +461,21 @@ class ____AnaLogger
|
|
|
468
461
|
|
|
469
462
|
this.setOptions(this.options);
|
|
470
463
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
464
|
+
if (!____AnaLogger.Console) {
|
|
465
|
+
____AnaLogger.Console = {
|
|
466
|
+
log: console.log,
|
|
467
|
+
info: console.info,
|
|
468
|
+
warn: console.warn,
|
|
469
|
+
error: console.error,
|
|
470
|
+
debug: console.debug,
|
|
471
|
+
table: console.table
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
this.rawLog = ____AnaLogger.Console.log;
|
|
476
|
+
this.rawInfo = ____AnaLogger.Console.info;
|
|
477
|
+
this.rawWarn = ____AnaLogger.Console.warn;
|
|
478
|
+
this.rawError = ____AnaLogger.Console.error;
|
|
475
479
|
|
|
476
480
|
this.ALIGN = ____AnaLogger.ALIGN;
|
|
477
481
|
this.ENVIRONMENT_TYPE = ____AnaLogger.ENVIRONMENT_TYPE;
|
|
@@ -775,7 +779,7 @@ class ____AnaLogger
|
|
|
775
779
|
}
|
|
776
780
|
|
|
777
781
|
/** to-esm-browser: add
|
|
778
|
-
|
|
782
|
+
____AnaLogger.Console.log("LogToFile is not supported in this environment. ")
|
|
779
783
|
**/
|
|
780
784
|
}
|
|
781
785
|
|
|
@@ -1758,23 +1762,23 @@ class ____AnaLogger
|
|
|
1758
1762
|
const contextLevel = context.contextLevel || DEFAULT_LOG_LEVELS.LOG;
|
|
1759
1763
|
if (contextLevel >= DEFAULT_LOG_LEVELS.ERROR)
|
|
1760
1764
|
{
|
|
1761
|
-
|
|
1765
|
+
____AnaLogger.Console.error(...res);
|
|
1762
1766
|
}
|
|
1763
1767
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.WARN)
|
|
1764
1768
|
{
|
|
1765
|
-
|
|
1769
|
+
____AnaLogger.Console.warn(...res);
|
|
1766
1770
|
}
|
|
1767
1771
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.INFO)
|
|
1768
1772
|
{
|
|
1769
|
-
|
|
1773
|
+
____AnaLogger.Console.info(...res);
|
|
1770
1774
|
}
|
|
1771
1775
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.LOG)
|
|
1772
1776
|
{
|
|
1773
|
-
|
|
1777
|
+
____AnaLogger.Console.log(...res);
|
|
1774
1778
|
}
|
|
1775
1779
|
else if (contextLevel >= DEFAULT_LOG_LEVELS.DEBUG)
|
|
1776
1780
|
{
|
|
1777
|
-
|
|
1781
|
+
____AnaLogger.Console.debug(...res);
|
|
1778
1782
|
}
|
|
1779
1783
|
|
|
1780
1784
|
}
|
|
@@ -2125,7 +2129,7 @@ class ____AnaLogger
|
|
|
2125
2129
|
|
|
2126
2130
|
if (context.raw)
|
|
2127
2131
|
{
|
|
2128
|
-
|
|
2132
|
+
____AnaLogger.Console.log(...args);
|
|
2129
2133
|
return;
|
|
2130
2134
|
}
|
|
2131
2135
|
|
|
@@ -2161,7 +2165,7 @@ class ____AnaLogger
|
|
|
2161
2165
|
{
|
|
2162
2166
|
if (!this.options.hideHookMessage)
|
|
2163
2167
|
{
|
|
2164
|
-
|
|
2168
|
+
____AnaLogger.Console.log("AnaLogger: Hook placed on console.error");
|
|
2165
2169
|
}
|
|
2166
2170
|
this.#overridenMap.error = true;
|
|
2167
2171
|
console.error = this.onDisplayError.bind(this);
|
|
@@ -2171,12 +2175,12 @@ class ____AnaLogger
|
|
|
2171
2175
|
{
|
|
2172
2176
|
try
|
|
2173
2177
|
{
|
|
2174
|
-
console.rawLog =
|
|
2175
|
-
console.raw =
|
|
2178
|
+
console.rawLog = ____AnaLogger.Console.log;
|
|
2179
|
+
console.raw = ____AnaLogger.Console.log;
|
|
2176
2180
|
|
|
2177
|
-
console.rawInfo =
|
|
2178
|
-
console.rawWarn =
|
|
2179
|
-
console.rawError =
|
|
2181
|
+
console.rawInfo = ____AnaLogger.Console.info;
|
|
2182
|
+
console.rawWarn = ____AnaLogger.Console.warn;
|
|
2183
|
+
console.rawError = ____AnaLogger.Console.error;
|
|
2180
2184
|
|
|
2181
2185
|
console.logHistory = this.logHistory;
|
|
2182
2186
|
|
|
@@ -2203,7 +2207,7 @@ class ____AnaLogger
|
|
|
2203
2207
|
{
|
|
2204
2208
|
if (!this.options.hideHookMessage)
|
|
2205
2209
|
{
|
|
2206
|
-
|
|
2210
|
+
____AnaLogger.Console.log("AnaLogger: Hook placed on console.log");
|
|
2207
2211
|
}
|
|
2208
2212
|
|
|
2209
2213
|
[{log}, {info}, {warn},].forEach(function (methodObj)
|
|
@@ -2226,7 +2230,7 @@ class ____AnaLogger
|
|
|
2226
2230
|
|
|
2227
2231
|
removeOverrideError()
|
|
2228
2232
|
{
|
|
2229
|
-
console.error =
|
|
2233
|
+
console.error = ____AnaLogger.Console.error;
|
|
2230
2234
|
this.#overridenMap.error = false;
|
|
2231
2235
|
}
|
|
2232
2236
|
|
|
@@ -2234,19 +2238,19 @@ class ____AnaLogger
|
|
|
2234
2238
|
{
|
|
2235
2239
|
if (log)
|
|
2236
2240
|
{
|
|
2237
|
-
console.log =
|
|
2241
|
+
console.log = ____AnaLogger.Console.log;
|
|
2238
2242
|
this.#overridenMap.log = false;
|
|
2239
2243
|
}
|
|
2240
2244
|
|
|
2241
2245
|
if (info)
|
|
2242
2246
|
{
|
|
2243
|
-
console.info =
|
|
2247
|
+
console.info = ____AnaLogger.Console.info;
|
|
2244
2248
|
this.#overridenMap.info = false;
|
|
2245
2249
|
}
|
|
2246
2250
|
|
|
2247
2251
|
if (warn)
|
|
2248
2252
|
{
|
|
2249
|
-
console.warn =
|
|
2253
|
+
console.warn = ____AnaLogger.Console.warn;
|
|
2250
2254
|
this.#overridenMap.warn = false;
|
|
2251
2255
|
}
|
|
2252
2256
|
|
|
@@ -2271,13 +2275,13 @@ class ____AnaLogger
|
|
|
2271
2275
|
{
|
|
2272
2276
|
if (!this.#overridenMap.log)
|
|
2273
2277
|
{
|
|
2274
|
-
|
|
2278
|
+
____AnaLogger.Console.table(...args);
|
|
2275
2279
|
return;
|
|
2276
2280
|
}
|
|
2277
2281
|
|
|
2278
2282
|
const currentLog = console.log;
|
|
2279
|
-
console.log =
|
|
2280
|
-
|
|
2283
|
+
console.log = ____AnaLogger.Console.log;
|
|
2284
|
+
____AnaLogger.Console.table(...args);
|
|
2281
2285
|
console.log = currentLog;
|
|
2282
2286
|
}
|
|
2283
2287
|
|
|
@@ -2424,8 +2428,7 @@ class ____AnaLogger
|
|
|
2424
2428
|
|
|
2425
2429
|
static generateInstance()
|
|
2426
2430
|
{
|
|
2427
|
-
|
|
2428
|
-
return analogger;
|
|
2431
|
+
return new ____AnaLogger();
|
|
2429
2432
|
}
|
|
2430
2433
|
|
|
2431
2434
|
/**
|