analogger 1.22.0 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/README.md +204 -57
- package/browser/ana-logger.mjs +7 -7
- package/dist/analogger-browser.min.mjs +3 -3
- package/dist/html-to-image-plugin.min.mjs +3 -3
- package/esm/ana-logger.mjs +7 -5
- package/package.json +11 -8
- package/src/ana-logger.cjs +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
## [1.22.1](https://github.com/thimpat/analogger/compare/v1.22.0...v1.22.1) (2022-09-25)
|
|
2
2
|
|
|
3
|
+
# [1.22.0](https://github.com/thimpat/analogger/compare/v1.21.4...v1.22.0) (2022-09-24)
|
|
4
|
+
|
|
3
5
|
## [1.21.4](https://github.com/thimpat/analogger/compare/v1.21.3...v1.21.4) (2022-09-14)
|
|
4
6
|
|
|
5
7
|
## [1.21.3](https://github.com/thimpat/analogger/compare/v1.21.2...v1.21.3) (2022-09-13)
|
package/README.md
CHANGED
|
@@ -302,6 +302,8 @@ _The data received by your server may look like this:_
|
|
|
302
302
|
|
|
303
303
|
---
|
|
304
304
|
|
|
305
|
+
<br/>
|
|
306
|
+
|
|
305
307
|
### Write logs to the Remote Logging module
|
|
306
308
|
|
|
307
309
|
You can also use the Remote-Logging module if you don't want to implement the back-end.
|
|
@@ -326,6 +328,7 @@ $> analogger
|
|
|
326
328
|
|
|
327
329
|
> ##### On Linux, You will have to open port 12000 by default. To change it, pass the option --port number to the command above.
|
|
328
330
|
|
|
331
|
+
<br/>
|
|
329
332
|
|
|
330
333
|
#### 2- Copy the server URL in the AnaLogger options (In your client code)
|
|
331
334
|
|
|
@@ -380,6 +383,15 @@ _Data received by your server may look like this:_
|
|
|
380
383
|
]
|
|
381
384
|
```
|
|
382
385
|
|
|
386
|
+
<br/>
|
|
387
|
+
|
|
388
|
+
> #####
|
|
389
|
+
> ```
|
|
390
|
+
> Scroll down to the bottom to see a complete example
|
|
391
|
+
> ```
|
|
392
|
+
>
|
|
393
|
+
|
|
394
|
+
|
|
383
395
|
<br/>
|
|
384
396
|
|
|
385
397
|
---
|
|
@@ -793,73 +805,210 @@ $> analogger --port 8754
|
|
|
793
805
|
|
|
794
806
|
<br/>
|
|
795
807
|
|
|
796
|
-
3. **
|
|
808
|
+
3. **Set up the client (Browser in our case)**
|
|
797
809
|
|
|
798
|
-
|
|
799
|
-
// Load an AnaLogger instance (We use "import" here because the client is a browser)
|
|
800
|
-
import {anaLogger} from "./node_modules/analogger/browser/src/ana-logger.mjs";
|
|
810
|
+
HTML (Client-Side)
|
|
801
811
|
|
|
802
|
-
|
|
803
|
-
|
|
812
|
+
```html
|
|
813
|
+
<!DOCTYPE html>
|
|
814
|
+
<html lang="en">
|
|
815
|
+
<head>
|
|
816
|
+
<meta charset="UTF-8">
|
|
817
|
+
<title>Demo</title>
|
|
818
|
+
<!-- Theme file available in node_modules/analogger/dist/ -->
|
|
819
|
+
<link rel="stylesheet" href="./analogger.min.css">
|
|
820
|
+
<style>
|
|
821
|
+
.analogger {
|
|
822
|
+
height: 340px;
|
|
823
|
+
width: 420px;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
.image-container
|
|
827
|
+
{
|
|
828
|
+
display: block;
|
|
829
|
+
background: rgb(222, 199, 189);
|
|
830
|
+
position: absolute;
|
|
831
|
+
height: 100%;
|
|
832
|
+
left: 496px;
|
|
833
|
+
overflow: auto;
|
|
834
|
+
text-align: right;
|
|
835
|
+
right: 0;
|
|
836
|
+
top: 0;
|
|
837
|
+
bottom: 0;
|
|
838
|
+
}
|
|
804
839
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
840
|
+
.screenshot-container img
|
|
841
|
+
{
|
|
842
|
+
height: 340px;
|
|
843
|
+
width: 420px;
|
|
844
|
+
}
|
|
845
|
+
</style>
|
|
846
|
+
</head>
|
|
847
|
+
<body>
|
|
848
|
+
|
|
849
|
+
<button id="send-to-remote" class="add-button">Send log to remote</button>
|
|
850
|
+
<button id="take-screenshot" class="add-button">Take a screenshot</button>
|
|
811
851
|
|
|
852
|
+
<!-- Client logging view (We'll be sending logs to both this view and the remote ) -->
|
|
853
|
+
<div id="analogger" class="analogger">
|
|
854
|
+
</div>
|
|
855
|
+
|
|
856
|
+
<!-- This file is in the AnaLogger module_directory.
|
|
857
|
+
Note that you could use a version from the html-to-image module directly at:
|
|
858
|
+
https://www.npmjs.com/package/html-to-image
|
|
859
|
+
-->
|
|
860
|
+
<script src="browser/html-to-image.js"></script>
|
|
861
|
+
|
|
862
|
+
<!-- For this file, see 4. Link AnaLogger to the remote -->
|
|
863
|
+
<script type="module" src="./demo-remote.mjs"></script>
|
|
864
|
+
|
|
865
|
+
</body>
|
|
866
|
+
</html>
|
|
812
867
|
```
|
|
813
868
|
|
|
814
869
|
<br/>
|
|
815
870
|
|
|
816
|
-
4. **
|
|
871
|
+
4. **Link AnaLogger to the remote**
|
|
817
872
|
|
|
818
|
-
|
|
873
|
+
<br/>
|
|
819
874
|
|
|
875
|
+
JavaScript (**./demo-remote.mjs**)
|
|
820
876
|
```javascript
|
|
821
|
-
//
|
|
822
|
-
anaLogger.
|
|
823
|
-
lid : 1234,
|
|
824
|
-
[PLUGIN_NAME] : {
|
|
825
|
-
|
|
826
|
-
divSource: document.body, // Tell the plugin from what div to generate a screenshot
|
|
827
|
-
/**
|
|
828
|
-
* The client has generated data for the screenshot, but has not uploaded them yet
|
|
829
|
-
* @param event
|
|
830
|
-
*/
|
|
831
|
-
onScreenshot: function(event)
|
|
832
|
-
{
|
|
833
|
-
// do something with your data
|
|
834
|
-
},
|
|
835
|
-
/**
|
|
836
|
-
* The server has saved the screenshot server-side and it's
|
|
837
|
-
* now sending back information about it
|
|
838
|
-
*/
|
|
839
|
-
onResponse: (event) =>
|
|
840
|
-
{
|
|
841
|
-
console.log(`Success. The server has saved the screenshot`)
|
|
842
|
-
},
|
|
843
|
-
options : {
|
|
844
|
-
canvasHeight,
|
|
845
|
-
canvasWidth,
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
}, `Taking screenshot...`);
|
|
877
|
+
// Load the AnaLogger library ( Available in ./node_modules/analogger/browser/ )
|
|
878
|
+
import {anaLogger} from "./browser/ana-logger.mjs";
|
|
849
879
|
|
|
850
|
-
|
|
880
|
+
// Register plugin
|
|
881
|
+
import {PLUGIN_NAME} from "./browser/html-to-image-plugin.mjs";
|
|
851
882
|
|
|
852
|
-
|
|
883
|
+
/**
|
|
884
|
+
* Create a container to draw the screenshot
|
|
885
|
+
* @returns {HTMLDivElement}
|
|
886
|
+
*/
|
|
887
|
+
const buildImageContainer = () =>
|
|
888
|
+
{
|
|
889
|
+
const item = document.createElement("div");
|
|
890
|
+
document.body.appendChild(item);
|
|
891
|
+
item.classList.add("image-container");
|
|
892
|
+
item.id = "image-container";
|
|
893
|
+
return item;
|
|
894
|
+
};
|
|
853
895
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
{
|
|
858
|
-
|
|
859
|
-
|
|
896
|
+
/**
|
|
897
|
+
* AnaLogger is about to trigger a screenshot using the html-to-image module
|
|
898
|
+
* https://www.npmjs.com/package/html-to-image
|
|
899
|
+
* @returns {boolean}
|
|
900
|
+
*/
|
|
901
|
+
const takeScreenshot = ($container) =>
|
|
902
|
+
{
|
|
903
|
+
try
|
|
904
|
+
{
|
|
905
|
+
document.getElementById("image-container").style.display = "none";
|
|
906
|
+
const box = document.body;
|
|
907
|
+
|
|
908
|
+
let canvasWidth = box.offsetWidth;
|
|
909
|
+
let canvasHeight = box.offsetHeight;
|
|
910
|
+
|
|
911
|
+
const desiredHeight = 380;
|
|
912
|
+
if (canvasHeight > desiredHeight)
|
|
913
|
+
{
|
|
914
|
+
canvasWidth = Math.floor(desiredHeight / canvasHeight * canvasWidth);
|
|
915
|
+
canvasHeight = desiredHeight;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// Trigger the plugin has its name is passed to the context
|
|
919
|
+
anaLogger.log({
|
|
920
|
+
lid : 1234, // <= Random number
|
|
921
|
+
[PLUGIN_NAME] /** takeScreenshot */: {
|
|
922
|
+
/**
|
|
923
|
+
* Tell the plugin from which div to generate the screenshot
|
|
924
|
+
*/
|
|
925
|
+
divSource: box,
|
|
926
|
+
/**
|
|
927
|
+
* AnaLogger has called the plugin, and we have the data image,
|
|
928
|
+
* however data have not been uploaded yet
|
|
929
|
+
* @returns {boolean}
|
|
930
|
+
* @param event
|
|
931
|
+
*/
|
|
932
|
+
onScreenshot: function displayScreenshotInDom(event)
|
|
933
|
+
{
|
|
934
|
+
// Add image to DOM
|
|
935
|
+
document.getElementById("image-container").style.display = "block";
|
|
936
|
+
const img = new Image();
|
|
937
|
+
img.src = event.imageData;
|
|
938
|
+
$container.append(img);
|
|
939
|
+
},
|
|
940
|
+
/**
|
|
941
|
+
* The server has saved the screenshot on the machine host.
|
|
942
|
+
* @param response
|
|
943
|
+
* @returns {boolean}
|
|
944
|
+
*/
|
|
945
|
+
onResponse: function ({serverResponse})
|
|
946
|
+
{
|
|
947
|
+
const {message, success, urlPath} = serverResponse;
|
|
948
|
+
|
|
949
|
+
if (!success)
|
|
950
|
+
{
|
|
951
|
+
console.error({lid: 3007}, "Something went wrong server-side", message, urlPath)
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
console.log({lid: 3008}, message, urlPath)
|
|
955
|
+
return true;
|
|
956
|
+
},
|
|
957
|
+
options : {
|
|
958
|
+
canvasHeight,
|
|
959
|
+
canvasWidth,
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}, `Taking screenshot...`);
|
|
963
|
+
|
|
964
|
+
return true;
|
|
965
|
+
}
|
|
966
|
+
catch (e)
|
|
967
|
+
{
|
|
968
|
+
console.error({lid: 4321}, e.message);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
return false;
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
const init = () =>
|
|
975
|
+
{
|
|
976
|
+
try
|
|
977
|
+
{
|
|
978
|
+
let $container = buildImageContainer();
|
|
979
|
+
|
|
980
|
+
anaLogger.validatePlugin(PLUGIN_NAME);
|
|
981
|
+
anaLogger.setOptions({
|
|
982
|
+
logToRemote: true,
|
|
983
|
+
logToRemoteUrl: "http://192.168.2.12:8754/analogger", // To log standard entries (log, errors) to this url
|
|
984
|
+
logToRemoteBinaryUrl: "http://192.168.2.12/uploaded" // To process screenshot data on this url
|
|
985
|
+
logToDom: true
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
anaLogger.log({lid: 1232}, `AnaLogger set up to work with remote`);
|
|
989
|
+
|
|
990
|
+
document.getElementById("send-to-remote").addEventListener("click", () =>
|
|
991
|
+
{
|
|
992
|
+
anaLogger.log({lid: 1232}, `Sending a random number to the remote: ${Math.random()}`);
|
|
993
|
+
});
|
|
994
|
+
|
|
995
|
+
document.getElementById("take-screenshot").addEventListener("click", () =>
|
|
996
|
+
{
|
|
997
|
+
takeScreenshot($container)
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
catch (e)
|
|
1001
|
+
{
|
|
1002
|
+
anaLogger.error({lid: 4321}, e.message);
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
init();
|
|
860
1007
|
|
|
861
1008
|
```
|
|
862
1009
|
|
|
1010
|
+
<br/>
|
|
1011
|
+
|
|
863
1012
|
---
|
|
864
1013
|
|
|
865
1014
|
## Plugins
|
|
@@ -891,6 +1040,11 @@ anaLogger.addPlugin("doSomething", doSomething);
|
|
|
891
1040
|
## Changelog
|
|
892
1041
|
|
|
893
1042
|
##### current:
|
|
1043
|
+
* Fix screenshot endpoint
|
|
1044
|
+
* Fix remote breaking in browser due to misconfiguration
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
##### 1.22.0:
|
|
894
1048
|
* Review display for js primitive types
|
|
895
1049
|
* Use native console table
|
|
896
1050
|
* Set up AnaLogger as a Mocha reporter
|
|
@@ -939,11 +1093,4 @@ anaLogger.addPlugin("doSomething", doSomething);
|
|
|
939
1093
|
* Fix log displayed twice
|
|
940
1094
|
* Add takeScreenshot plugin
|
|
941
1095
|
|
|
942
|
-
|
|
943
|
-
##### 1.19.0:
|
|
944
|
-
* Add context levels
|
|
945
|
-
* Add a logToRemote option
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
1096
|
---
|
package/browser/ana-logger.mjs
CHANGED
|
@@ -11,10 +11,6 @@ import {
|
|
|
11
11
|
} from "./constants.mjs";
|
|
12
12
|
import {stringify} from "./imported/flatted/esm/index.mjs";
|
|
13
13
|
import {CONSOLE_HEADER_CLASSNAME, CONSOLE_FOOTER_CLASSNAME} from "./constants.mjs";
|
|
14
|
-
let fetch = null;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
14
|
|
|
19
15
|
// to-ansi is also used by the browser
|
|
20
16
|
|
|
@@ -553,14 +549,18 @@ class ____AnaLogger
|
|
|
553
549
|
protocol: this.options.protocol,
|
|
554
550
|
host : this.options.host,
|
|
555
551
|
port : this.options.port,
|
|
556
|
-
pathname: this.options.binarypathname
|
|
552
|
+
pathname: this.options.binarypathname || DEFAULT.binarypathname
|
|
557
553
|
});
|
|
558
554
|
}
|
|
559
555
|
|
|
560
556
|
// Special cases
|
|
561
|
-
if (logToDom
|
|
557
|
+
if (logToDom === false)
|
|
558
|
+
{
|
|
559
|
+
this.options.logToDom = false;
|
|
560
|
+
}
|
|
561
|
+
else if (logToDom !== undefined)
|
|
562
562
|
{
|
|
563
|
-
this.options.logToDom = logToDom
|
|
563
|
+
this.options.logToDom = (logToDom === true) ? DEFAULT.consoleDomId : logToDom;
|
|
564
564
|
}
|
|
565
565
|
|
|
566
566
|
if (logToFile === false)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
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
|
|
3
|
-
`),o=[];for(let r=0;r<t.length;++r){let s=t[r];o.push(s)}return o}catch(t){console.rawError(t.message)}return e.message}onDisplayError(...e){try{let t=-1,o=null;for(let r=0;r<e.length;++r){let s=e[r];if(s instanceof Error&&s.stack){t=r,o=this.assistStask(s)||[];break}}if(!o){this.error(...e);return}for(let r=0;r<o.length;++r)e[t]=o[r],this.error(...e)}catch(t){console.rawError(t)}}setLogFormat(e){if(typeof e!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=e.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(e){this.errorTargetHandler=e.bind(this)}setErrorHandlerForUserTarget(e){this.errorUserTargetHandler=e.bind(this)}isContextValid(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null?e.hasOwnProperty("contextName")&&e.hasOwnProperty("target"):!1}setDefaultContext(e){this.setContext(H.DEFAULT.contextName,e)}generateDefaultContext(){let e=a(this,A)[H.DEFAULT.contextName]||{};return e=Object.assign({},{lid:"",contextName:H.DEFAULT.contextName,target:C.ALL,symbol:"\u26A1",color:F[1],logLevel:u.LOG},e),e.name=e.contextName,e.id=this.logIndex++,e}generateNewContext(){let e=this.generateDefaultContext();return e.color=F[this.indexColor++%(F.length-3)+2],e.symbol="",e}generateErrorContext(){let e=this.generateDefaultContext();return e.contextName=H.ERROR.contextName,e.name=e.contextName,e.color=F[0],e.symbol="\u274C",e.error=!0,e.logLevel=u.ERROR,e}setContext(e,t={}){t.contextName=e,t.name=e,t=ne(this,J,Se).call(this,t),a(this,A)[e]=t}getContext(e){return a(this,A)[e]}setContexts(e){Object.keys(e).forEach(o=>{let r=e[o]||{};this.setContext(o,r),e[o]=a(this,A)[o]})}getContexts(){return Object.freeze(a(this,A))}setTargets(e={}){let t={};if(Array.isArray(e))try{for(let o=0;o<e.length;++o){let r=e[o];if(typeof r=="string"||r instanceof String)t[r]=r;else if(typeof r=="object"){let s=null;for(let i in r){let l=r[i];if(i=i.trim(),!i){console.error("Invalid target");break}if(typeof l=="string"||l instanceof String){l=l.trim(),s=[i,l];break}if(typeof l=="number")break}s&&(t[s[0]]=s[1])}}}catch(o){console.error({lid:4321},o.message)}else t=e;re(this,x,Object.assign({},t,{...C}))}addTargets(e){let t=a(this,x),o=Object.assign({},t,e);this.setTargets(o)}getTargets(){return Object.freeze(a(this,x))}setActiveTargets(e=null){if(e===null){this.activeTargets=[C.ALL];return}else if(typeof e=="string"||e instanceof String)e=e.split(",");else if(typeof e=="object"||typeof e=="function")return;for(let t=0;t<e.length;++t)e[t]=e[t].trim();this.activeTargets=e}getActiveTarget(){return this.activeTargets}setActiveTarget(e){this.activeTargets=[],this.setActiveTargets(e),this.activeTargets=[this.activeTargets[0]]}setLogLevel(e,t){a(this,R)[e]=t}getLogLevel(e){return a(this,R)[e]}setLogLevels(e){re(this,R,e)}getLogLevels(){return Object.freeze(a(this,R))}isTargetAllowed(e){return!e||!this.activeTargets||!this.activeTargets.length||e===C.ALL||this.activeTargets.includes(C.ALL)?!0:this.activeTargets.includes(e)}setColumns(e,t,o){let r=0;for(let i in t){if(!["contextName","symbol","lid","text"].includes(i))continue;let l=t[i],c=document.createElement("span");c.classList.add("analogger-col",`analogger-col-${i}`,`analogger-col-${r}`),++r,c.textContent=l,e.append(c)}let s=document.createElement("span");s.classList.add("analogger-col","analogger-col-text",`analogger-col-${r}`),s.textContent=o,e.append(s);for(let i=1;i<=3;++i)s=document.createElement("span"),s.classList.add("analogger-col","analogger-col-extra",`analogger-extra-${i}`),e.append(s)}checkOnLoggingToDom(e,t){try{let o=e.onLoggingToDom;return typeof o!="function"?void 0:o.call(this,e,t)}catch{}}addLineToDom(e,t,{context:o,addType:r,message:s,text:i,args:l}){if(this.checkOnLoggingToDom(o,{message:s,text:i,args:l,logCounter:this.logCounter,$view:e,$line:t,addType:r})===!1)return;if(r===$.BOTTOM?e.append(t):e.insertBefore(t,e.firstChild),this.removeDomOldEntries(e)){if(e.getElementsByClassName(ae).length)return;this.showRemovedNotification(o);return}this.scrollDivToBottom(e)}showRemovedNotification(e){e.contextName=Ae,e.symbol="\u{1F5D1}",e.color="orange",e.className=ae,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(e,"",{addType:$.TOP,message:"Oldest entries removed"})},500)}writeLogToDom(e,t,{addType:o=$.BOTTOM,message:r="",args:s=null}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),t=r||t;for(let i=0;i<this.$containers.length;++i){let l=this.$containers[i],c=l.querySelector("."+ce);c||(c=document.createElement("div"),c.classList.add(ce),c.append(document.createElement("span")),c.append(document.createElement("span")),c.append(document.createElement("span")),l.append(c));let p=l.querySelector("."+fe);p||(p=document.createElement("div"),p.classList.add(fe),l.append(p));let d=l.querySelector("."+de);d||(d=document.createElement("div"),d.classList.add(de),d.append(document.createElement("span")),d.append(document.createElement("span")),d.append(document.createElement("span")),l.append(d));let g=document.createElement("div");g.classList.add(Oe),e.className&&g.classList.add(e.className),g.style.color=e.color,this.setColumns(g,e,t,s),setTimeout(function(L,U,{addType:K,context:Q,message:Z,text:ee,args:G}){this.addLineToDom(L,U,{addType:K,context:Q,message:Z,text:ee,args:G})}.bind(this,p,g,{addType:o,context:e,message:r,text:t,args:s}),0)}}writeLogToFile(e){try{fs.appendFileSync(this.options.logToFilePath,e+this.EOL)}catch(t){console.rawError("LOG_TO_FILE_FAILURE: ",t.message)}}writeLogToRemote(...e){try{let t=this.generateLogToRemoteUrl(this.options.logToRemoteUrl);if(!t)return null;let o=[...e],r=JSON.stringify(o);Ne(t,{method:"post",body:r,headers:{"Content-Type":"application/json"}}).then(s=>s.json()).catch(()=>null)}catch(t){console.rawError("LOG_TO_REMOTE_FAILURE: ",t.message)}}uploadDataToRemote(e,t=null,o=null){try{if(!this.options.logToRemote)return;let r=this.generateLogToRemoteUrl(this.options.logToRemoteBinaryUrl,{pathname:b.binarypathname});if(!r)return null;let s=e;t&&(s=JSON.stringify({raw:e,context:t})),Ne(r,{method:"post",body:s}).then(i=>i.json()).then(i=>o&&o(i)).catch(i=>i)}catch(r){console.rawError("BINARY_TO_REMOTE_FAILURE: ",r.message)}}stringifyEntry(e){let t;try{t=JSON.stringify(e)}catch{}if(!t)try{t=we(e)}catch{}return t}convertEntry(e){try{if(e==null||e==="")return e;if(typeof e=="boolean")return e;if(typeof e=="symbol"||typeof e=="number")return e;if(typeof e=="string"||myVar instanceof e)return e;if(e instanceof Date)return e}catch{}return this.stringifyEntry(e)}convertArgumentsToText(e){let t=[],o,r=e.length;for(let s=0;s<r;++s){let i,l=e[s];i=this.convertEntry(l),t.push(i)}return o=t.join("\u2022"),o}writeToConsole(e,t){let o=[e];this.isBrowser()&&o.push(`color: ${t.color}`);let r=t.contextLevel||u.LOG;r>=u.ERROR?a(this,v).call(this,...o):r>=u.WARN?a(this,N).call(this,...o):r>=u.INFO?a(this,w).call(this,...o):r>=u.LOG?a(this,E).call(this,...o):r>=u.DEBUG&&a(this,z).call(this,...o)}checkPlugins(e,{message:t,text:o,args:r,logCounter:s}){try{if(!Object.keys(h.pluginTable).length)return;let i=!0;for(let l in e){let c=e[l];if(!c)continue;let p=h.pluginTable[l];if(!p||typeof p!="object")continue;let{callback:d,methodName:g,type:L}=p;if(typeof d!="function")continue;d.call(this,e,{message:t,text:o,args:r,logCounter:s,methodName:g,type:L,pluginOptions:c})===!1&&(i=!1)}return i}catch{}}checkOnLogging(e,t){try{let o=e.onLogging;return typeof o!="function"?void 0:o.call(this,e,t)}catch{}}processOutput(e={}){try{let t="";if(this.applySymbolByName(e),!this.isTargetAllowed(e.target)||e.logLevel===u.OFF||this.options.requiredLogLevel>e.logLevel)return;let o=Array.prototype.slice.call(arguments,1);t=this.convertArgumentsToText(o);let r="",s=this.format({...e,message:t});this.keepLog&&this.addToLogHistory({context:e,message:t,text:s}),++this.logCounter;let i;if(i=this.checkOnLogging(e,{message:t,text:s,args:o,logCounter:this.logCounter}),i===!1||(i=this.checkPlugins(e,{message:t,text:s,args:o,logCounter:this.logCounter}),i===!1)||(this.options.logToRemote&&this.writeLogToRemote(e,...o),this.isBrowser()?(e.environnment=h.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(e,s,{message:t,args:o}),r=`%c${s}`):(e.environnment=h.ENVIRONMENT_TYPE.NODE,r=Y.getTextFromColor(s,{fg:e.color,bg:e.bgColor,isBold:e.bold,isUnderline:e.underline,isReversed:e.reversed}),this.options.logToFile&&this.writeLogToFile(s)),this.options.hideLog))return;this.writeToConsole(r,e),this.errorTargetHandler(e,o)}catch(t){console.rawError("AnaLogger:",t.message)}}isExtendedOptionsPassed(e){return typeof e!="object"?!1:e.hasOwnProperty("context")||e.hasOwnProperty("target")||e.hasOwnProperty("color")||e.hasOwnProperty("contextName")||e.hasOwnProperty("lid")}extractContextFromInput(e){return(typeof e=="string"||e instanceof String)&&e.toLowerCase().indexOf("lid:")!==0,e}listSymbols(){for(let e in V)console.rawLog(V[e]+` ${e} `)}applySymbolByName(e){try{e.symbol&&V[e.symbol]&&(e.symbol=V[e.symbol])}catch{}}convertToContext(e,t){e=e||t;let o=e;if(e.context&&typeof e.context=="object"){let r=Object.assign({},e);delete r.context,o=Object.assign({},e.context,r)}return o=Object.assign({},t,o),delete o.context,o}log(e,...t){if(e=this.extractContextFromInput(e),!this.isExtendedOptionsPassed(e)){let s=this.generateDefaultContext();this.processOutput.apply(this,[s,e,...t]);return}let o=this.generateDefaultContext(),r=this.convertToContext(e,o);this.processOutput.apply(this,[r,...t])}error(e,...t){if(this.options.hideError)return;if(e=this.extractContextFromInput(e),!this.isExtendedOptionsPassed(e)){let i=this.generateErrorContext();this.processOutput.apply(this,[i,e,...t]);return}let o=this.generateErrorContext(),r=this.convertToContext(e,o),s=Array.prototype.slice.call(arguments,1);this.log(r,...s)}overrideError(){this.options.hideHookMessage||a(this,E).call(this,"AnaLogger: Hook placed on console.error"),a(this,T).error=!0,console.error=this.onDisplayError.bind(this)}attachConsole(){try{return console.rawLog=a(this,E),console.raw=a(this,E),console.rawInfo=a(this,w),console.rawWarn=a(this,N),console.rawError=a(this,v),console.logHistory=this.logHistory,console.logHistory=this.logHistory,Ze.forEach(e=>{console[e]=function(...t){this[e](...t)}.bind(this)}),!0}catch(e){console.error({lid:4321},e.message)}return!1}overrideConsole({log:e=!0,info:t=!0,warn:o=!0,error:r=!1}={}){this.options.hideHookMessage||a(this,E).call(this,"AnaLogger: Hook placed on console.log"),[{log:e},{info:t},{warn:o}].forEach(function(s){let i=Object.keys(s)[0];s[i]&&(a(this,T)[i]=!0,console[i]=this.onDisplayLog.bind(this))}.bind(this)),r&&this.overrideError(),this.attachConsole()}removeOverrideError(){console.error=a(this,v),a(this,T).error=!1}removeOverride({log:e=!0,info:t=!0,warn:o=!0,error:r=!1}={}){e&&(console.log=a(this,E),a(this,T).log=!1),t&&(console.info=a(this,w),a(this,T).info=!1),o&&(console.warn=a(this,N),a(this,T).warn=!1),r&&this.removeOverrideError()}info(...e){return this.log(...e)}warn(...e){return this.log(...e)}table(...e){if(!a(this,T).log){a(this,B).call(this,...e);return}let t=console.log;console.log=a(this,E),a(this,B).call(this,...e),console.log=t}alert(...e){if(!this.isBrowser())return this.log(...e);let t=e.join(" | ");alert(t)}assert(e,t=!0,...o){let r;try{return typeof e=="function"?(r=e(...o),r!==t?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):e!==t?(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:e="",override:t=!1}={}){try{let r={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"}};return this.setDefaultContext(r.DEFAULT),e&&this.setActiveTarget(e),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:6}),t&&(this.overrideConsole(),this.overrideError()),!0}catch(o){console.error({lid:3249},o.message)}return!1}applyPredefinedFormat(e=he.DEFAULT_FORMAT,{activeTarget:t="",override:o=!1}={}){if(e===he.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:t,override:o})}convertToUrl({protocol:e=b.protocol,host:t=b.host,port:o=b.port,pathname:r=b.pathname}={}){let s=new URL("http://localhost");return s.protocol=e,s.host=t,s.port=o,r&&(s.pathname=r),s.toString()}generateLogToRemoteUrl(e=null,{pathname:t=b.pathname}={}){if(typeof e=="string"||e instanceof String)return e;if(!this.isBrowser())return null;let o=this.options.protocol||window.location.protocol+"//",r=this.options.host||window.location.host||b.host,s=this.options.port||b.port;return t=this.options.pathname||t,this.convertToUrl({protocol:o,host:r,port:s,pathname:t})}addPlugin(e,t,o=""){o=o||e,this[e]=t,h.pluginTable[o]={type:ve.LOCAL,methodName:e,callback:t}}addGlobalPlugin(e,t,o){h[e]=t,h.pluginTable[o]={type:ve.GLOBAL,methodName:e,callback:t}}getPluginList(){return Object.keys(h.pluginTable)}validatePlugin(e){return h.pluginTable[e]?!0:(console.warn(`The plugin ${e} is not registered`),!1)}},y=h;A=new WeakMap,x=new WeakMap,R=new WeakMap,E=new WeakMap,w=new WeakMap,N=new WeakMap,v=new WeakMap,z=new WeakMap,B=new WeakMap,T=new WeakMap,J=new WeakSet,Se=function(e){let t=this.generateNewContext(),o=Object.assign({},t,e);return o.color.toLowerCase().indexOf("rgb")>-1?o.color=Y.rgbStringToHex(o.color):o.color.indexOf("#")===-1&&(o.color=Y.colorNameToHex(o.color)),o},X=new WeakSet,Fe=function(){try{this.setTargets(C),this.setLogLevels(u),this.setContexts(H)}catch(e){console.error({lid:4321},e.message)}return!1},f(y,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),f(y,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),f(y,"instanceCount",0),f(y,"pluginTable",{});var dt=y,et=y,ht=et,ut=new y;export{dt as AnaLogger,H as DEFAULT_LOG_CONTEXTS,u as DEFAULT_LOG_LEVELS,C as DEFAULT_LOG_TARGETS,ut as anaLogger,ht as default};
|
|
1
|
+
var Ie=Object.defineProperty;var He=(n,e,t)=>e in n?Ie(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>(He(n,typeof e!="symbol"?e+"":e,t),t),oe=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var a=(n,e,t)=>(oe(n,e,"read from private field"),t?t.call(n):e.get(n)),m=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},re=(n,e,t,o)=>(oe(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);var ne=(n,e,t)=>(oe(n,e,"access private method"),t);var ue={Foreground:38,Background:48},O="\x1B[1D",ge="\x1B[0m"+O,P={Bold:"\x1B[1m"+O,Underline:"\x1B[4m"+O,Reversed:"\x1B[7m"+O},Be={Bold:"\x1B[1m"+O,Underline:"\x1B[4m"+O,Reversed:"\x1B[7m"+O},se={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 Ue(n){return!!se[n]}var pe=(n,e,t)=>n===e&&e===t?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(e/255*5)+Math.round(t/255*5),me=n=>{let e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(e,function(o,r,s,i){return r+r+s+s+i+i});let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{red:parseInt(t[1],16),blue:parseInt(t[2],16),green:parseInt(t[3],16)}:{}},Le=function({red:n,green:e,blue:t}){let o=n<<16|e<<8|t<<0;return"#"+(16777216+o).toString(16).slice(1)},Ee=function(n){let e=n.matchAll(/\d+/g),t=[];for(let o of e){let r=parseInt(o[0]);if(r>255)return null;t.push(r)}return t.length!==3?null:{red:t[0],green:t[1],blue:t[2]}},Ge=function(n){let e=Ee(n);return e&&Le(e)},j=function(e,t,o){return o<0&&(o+=1),o>1&&(o-=1),o<1/6?e+(t-e)*6*o:o<1/2?t:o<2/3?e+(t-e)*(2/3-o)*6:e},be=({hue:n,saturation:e,lightness:t})=>{let o,r,s;if(e===0)o=r=s=t;else{let i=t<.5?t*(1+e):t+e-t*e,l=2*t-i;o=j(l,i,n+1/3),r=j(l,i,n),s=j(l,i,n-1/3)}return{red:Math.round(o*255),blue:Math.round(s*255),green:Math.round(r*255)}},Te=n=>{let e=n.toLowerCase();return typeof se[e]<"u"?se[e]:""};function S({red:n,blue:e,green:t},o=!0){if(n===void 0||e===void 0||t===void 0)return"";let r=pe(n,e,t);return`\x1B[${o?ue.Foreground:ue.Background};5;`+r+"m "+O}function _(n,e=!0){let{red:t,green:o,blue:r}=me(n);return S({red:t,green:o,blue:r},e)}function q({hue:n,saturation:e,lightness:t},o){let{red:r,green:s,blue:i}=be({hue:n,saturation:e,lightness:t});return S({red:r,green:s,blue:i},o)}function ie(n,e=!0){try{let t;return n=n||"",n?((typeof n=="string"||n instanceof String)&&(n=n.trim()),Ue(n)?(t=Te(n),_(t,e)):typeof n=="object"&&!!n.red&&!!n.blue&&!!n.green?S(n,e):typeof n=="object"&&!!n.hue&&!!n.saturation&&!!n.lightness?q(n,e):n.startsWith("#")?_(n,e):(n=n.toString(),/^[\da-fA-F]+$/.test(n)?_("#"+n,e):"")):""}catch(t){console.error("TO_ANSI_INVALID_ARGUMENT_ERROR",t.message)}}function W(n,{fg:e,bg:t,isUnderline:o=!1,isBold:r=!1,isReversed:s=!1}){let i=!1,l="";return e&&(i=!0,l=l+e),t&&(i=!0,l=l+t),o&&(i=!0,l=l+P.Underline),r&&(i=!0,l=l+P.Bold),s&&(i=!0,l=l+P.Reversed),i?l+n+ge:n}function Pe(n,{fg:e={},bg:t={},isUnderline:o=!1,isBold:r=!1,isReversed:s=!1}){return e&&(e=S({...e})),t&&(t=S({...t},!1)),W(n,{fg:e,bg:t,isUnderline:o,isBold:r,isReversed:s})}function je(n,{fg:e="",bg:t="",isUnderline:o=!1,isBold:r=!1,isReversed:s=!1}){return e&&(e=q({...e})),t&&(t=q({...t},!1)),W(n,{fg:e,bg:t,isUnderline:o,isBold:r,isReversed:s})}function qe(n,{fg:e="",bg:t="",isUnderline:o=!1,isBold:r=!1,isReversed:s=!1}){return e&&(e=_(e)),t&&(t=_(t,!1)),W(n,{fg:e,bg:t,isUnderline:o,isBold:r,isReversed:s})}function We(n,e=null){if(!e)return n;let{fg:t="",bg:o="",isUnderline:r=!1,isBold:s=!1,isReversed:i=!1}=e;return t&&(t=ie(t)),o&&(o=ie(o,!1)),W(n,{fg:t,bg:o,isUnderline:r,isBold:s,isReversed:i})}var Y={fromRgb:S,fromHexa:_,fromHsl:q,fromColor:ie,getTextFromRgb:Pe,getTextFromHsl:je,getTextFromHex:qe,getTextFromColor:We,colorNameToHex:Te,hslToRgb:be,hexToRgb:me,rgbToHex:Le,rgbToAnsi256:pe,rgbStringToRgb:Ee,rgbStringToHex:Ge,hue2rgb:j,RESET:ge,FONT_STYLE:P,STYLE:Be};var ye={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"}},F=ye.COLOR_TABLE,I=ye.SYSTEM,le=2e3,ae="analogger-removed-notif",ce="analogger-header",fe="analogger-view",de="analogger-footer",Oe="to-esm-line",$={TOP:"TOP",BOTTOM:"BOTTOM"},Ae="ANALOGGER",he={DEFAULT_FORMAT:"FORMAT1"};var{parse:rt,stringify:Ye}=JSON,{keys:nt}=Object,$e=String,Ve="string";var xe="object",ze=(n,e)=>e;var Re=(n,e,t)=>{let o=$e(e.push(t)-1);return n.set(t,o),o};var we=(n,e,t)=>{let o=e&&typeof e===xe?(f,g)=>f===""||-1<e.indexOf(f)?g:void 0:e||ze,r=new Map,s=[],i=[],l=+Re(r,s,o.call({"":n},"",n)),c=!l;for(;l<s.length;)c=!0,i[l]=Ye(s[l++],p,t);return"["+i.join(",")+"]";function p(f,g){if(c)return c=!c,g;let L=o.call(this,f,g);switch(typeof L){case xe:if(L===null)return L;case Ve:return r.get(L)||Re(r,s,L)}return L}};var E={moduleName:"analogger",protocol:"http://",host:"localhost",port:12e3,pathname:"analogger",binarypathname:"uploaded",loopback:"localhost",consoleDomId:"#analogger",logFilename:"./analogger.log"},C={ALL:"ALL",USER:"USER"},u={FATAL:5e3,ERROR:4e3,WARN:3e3,INFO:2e3,LOG:1e3,DEBUG:500,ALL:200,OFF:0,INHERIT:-1},Ne={LOCAL:"local",GLOBAL:"global"},H={DEFAULT:{contextName:"DEFAULT",logLevel:u.LOG,symbol:"check"},LOG:{contextName:"LOG",logLevel:u.LOG,symbol:"check"},DEBUG:{contextName:"DEBUG",logLevel:u.DEBUG},INFO:{contextName:"INFO",logLevel:u.INFO,color:"#B18904",symbol:"diamonds"},WARN:{contextName:"WARN",logLevel:u.WARN,color:F[0],symbol:"cross"},ERROR:{contextName:"ERROR",logLevel:u.ERROR},CRITICAL:{contextName:"CRITICAL",logLevel:u.CRITICAL}},Je=`
|
|
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 ve(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"?I.NODE:I.BROWSER}var Xe=ve();function Ke(){return Xe===I.NODE}var Qe=["keepLogHistory","getLogHistory","truncateMessage","truncateMessage","rawLog","removeOverride","removeOverrideError","overrideConsole","overrideError","table","rawInfo","rawWarn","rawError","hasSeenLid"],A,x,R,b,w,N,v,z,B,T,J,_e,X,Se,h=class{constructor({name:e="default"}={}){m(this,J);m(this,X);d(this,"system","");d(this,"instanceId","");d(this,"instanceName","");d(this,"logIndex",0);d(this,"logCounter",0);m(this,A,[]);m(this,x,{});m(this,R,{});d(this,"activeTargets",[]);d(this,"indexColor",0);d(this,"format","");d(this,"keepLog",!1);d(this,"logHistory",[]);d(this,"$containers",null);d(this,"options",{hideHookMessage:!1});m(this,b,console.log);m(this,w,console.info);m(this,N,console.warn);m(this,v,console.error);m(this,z,console.debug);m(this,B,console.table);m(this,T,{log:!1,info:!1,warn:!1,error:!1,debug:!1,table:!1});d(this,"originalFormatFunction");d(this,"removeDomOldEntries",e=>{if(e.childElementCount>le){let o=Math.ceil(le/10);for(let r=0;r<o;++r)e.removeChild(e.firstChild);return o}return 0});d(this,"scrollDivToBottom",e=>{let t=e.scrollHeight-(e.clientHeight+e.scrollTop),o=e.clientHeight||e.offsetHeight;t>o/2||(e.scrollTop=e.scrollHeight)});this.system=ve(),this.format=this.onBuildLog.bind(this),this.originalFormatFunction=this.format,this.instanceName=e,++h.instanceCount,this.instanceId=h.instanceCount+"-"+Date.now(),this.errorTargetHandler=this.onError.bind(this),this.errorUserTargetHandler=this.onErrorForUserTarget.bind(this),this.setOptions(this.options),this.rawLog=a(this,b),this.rawInfo=a(this,w),this.rawWarn=a(this,N),this.rawError=a(this,v),this.ALIGN=h.ALIGN,this.ENVIRONMENT_TYPE=h.ENVIRONMENT_TYPE,ne(this,X,Se).call(this),this.resetLogHistory()}getName(){return this.instanceName}getId(){return this.instanceId}keepLogHistory(){this.keepLog=!0}releaseLogHistory(){this.keepLog=!1}resetLogHistory(){this.logHistory=[]}addToLogHistory(e){e=e||{},this.logHistory.push(Object.assign({},e))}getLogHistory(e=!0,t=Je){let o=this.logHistory||[],r=[];return o.forEach(s=>{let{text:i}=s;r.push(i)}),e?r.join(t):r}getRawLogHistory(){return this.logHistory||[]}hasSeenLid(e){this.logHistory=this.logHistory||[];for(let t=0;t<this.logHistory.length;++t){let r=(this.logHistory[t]||{}).context||{};if(e===r.lid)return!0}return!1}forceEnvironment(e){this.forcedSystem=e}isNode(){return this&&this.forcedSystem?this.forcedSystem===I.NODE:Ke()}isBrowser(){return!this.isNode()}resetLogger(){this.options={},this.options.timeLenMax=10,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.logToRemote=void 0,this.options.logToRemoteUrl=void 0,this.options.logToRemoteBinaryUrl=void 0,this.options.logToDomlogToFile=void 0,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}resetOptions(){this.resetLogger()}setOptions({contextLenMax:e=10,idLenMax:t=5,lidLenMax:o=6,symbolLenMax:r=2,messageLenMax:s=void 0,hideLog:i=void 0,hideError:l=void 0,hideHookMessage:c=void 0,hidePassingTests:p=void 0,logToDom:f=void 0,logToFile:g=void 0,logToRemote:L=void 0,logToRemoteUrl:U=void 0,logToRemoteBinaryUrl:K=void 0,loopback:Q=E.loopback,requiredLogLevel:Z=u.LOG,oneConsolePerContext:ee=void 0,silent:G=void 0,protocol:Fe=void 0,host:Ce=void 0,port:De=void 0,pathname:Me=void 0,binarypathname:ke=void 0}=null){this.options.contextLenMax=e,this.options.idLenMax=t,this.options.lidLenMax=o,this.options.messageLenMax=s,this.options.symbolLenMax=r,this.options.requiredLogLevel=Z;let te;G!==void 0?te=!!G:i!==void 0&&(te=!!i),[{hideLog:te},{oneConsolePerContext:ee},{hideError:l},{hideHookMessage:c},{hidePassingTests:p},{logToRemote:L}].forEach(D=>{let M=Object.keys(D)[0],k=D[M];k!==void 0&&(this.options[M]=!!k)}),[{logToRemoteBinaryUrl:K},{logToRemoteUrl:U},{loopback:Q},{protocol:Fe},{host:Ce},{port:De},{pathname:Me},{binarypathname:ke}].forEach(D=>{let M=Object.keys(D)[0],k=D[M];k!==void 0&&(this.options[M]=k)}),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||E.binarypathname})),f===!1?this.options.logToDom=!1:f!==void 0&&(this.options.logToDom=f===!0?E.consoleDomId:f),g===!1?this.options.logToFile=!1:g!==void 0&&(this.isBrowser()||(this.options.logToFile=g||E.logFilename),a(this,b).call(this,"LogToFile is not supported in this environment. "))}getOptions(){return this.options}truncateMessage(e="",{fit:t=0,align:o=h.ALIGN.LEFT,ellipsis:r="..."}={}){return e=""+e,t&&e.length>t&&(e=e.substring(0,t-r.length)+r),e=o===h.ALIGN.LEFT?e.padEnd(t," "):e.padStart(t," "),e}onBuildLog({contextName:e,message:t="",lid:o="",symbol:r=""}={}){let s=new Date,i=("0"+s.getHours()).slice(-2)+":"+("0"+s.getMinutes()).slice(-2)+":"+("0"+s.getSeconds()).slice(-2);return i=this.truncateMessage(i,{fit:this.options.timeLenMax}),e=this.truncateMessage(e,{fit:this.options.contextLenMax,align:h.ALIGN.RIGHT}),o=this.truncateMessage(o,{fit:this.options.lidLenMax}),this.options.messageLenMax!==void 0&&(t=this.truncateMessage(t,{fit:this.options.messageLenMax})),r=this.truncateMessage(r,{fit:this.options.symbolLenMax}),`[${i}] ${e}: (${o}) ${r} ${t}`}onErrorForUserTarget(e,...t){this.errorUserTargetHandler(e,...t)}onError(e,...t){e.target===a(this,x).USER&&this.onErrorForUserTarget(e,...t)}onDisplayLog(...e){this.log(...e)}assistStask(e){try{let t=e.stack.split(`
|
|
3
|
+
`),o=[];for(let r=0;r<t.length;++r){let s=t[r];o.push(s)}return o}catch(t){console.rawError(t.message)}return e.message}onDisplayError(...e){try{let t=-1,o=null;for(let r=0;r<e.length;++r){let s=e[r];if(s instanceof Error&&s.stack){t=r,o=this.assistStask(s)||[];break}}if(!o){this.error(...e);return}for(let r=0;r<o.length;++r)e[t]=o[r],this.error(...e)}catch(t){console.rawError(t)}}setLogFormat(e){if(typeof e!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=e.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(e){this.errorTargetHandler=e.bind(this)}setErrorHandlerForUserTarget(e){this.errorUserTargetHandler=e.bind(this)}isContextValid(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null?e.hasOwnProperty("contextName")&&e.hasOwnProperty("target"):!1}setDefaultContext(e){this.setContext(H.DEFAULT.contextName,e)}generateDefaultContext(){let e=a(this,A)[H.DEFAULT.contextName]||{};return e=Object.assign({},{lid:"",contextName:H.DEFAULT.contextName,target:C.ALL,symbol:"\u26A1",color:F[1],logLevel:u.LOG},e),e.name=e.contextName,e.id=this.logIndex++,e}generateNewContext(){let e=this.generateDefaultContext();return e.color=F[this.indexColor++%(F.length-3)+2],e.symbol="",e}generateErrorContext(){let e=this.generateDefaultContext();return e.contextName=H.ERROR.contextName,e.name=e.contextName,e.color=F[0],e.symbol="\u274C",e.error=!0,e.logLevel=u.ERROR,e}setContext(e,t={}){t.contextName=e,t.name=e,t=ne(this,J,_e).call(this,t),a(this,A)[e]=t}getContext(e){return a(this,A)[e]}setContexts(e){Object.keys(e).forEach(o=>{let r=e[o]||{};this.setContext(o,r),e[o]=a(this,A)[o]})}getContexts(){return Object.freeze(a(this,A))}setTargets(e={}){let t={};if(Array.isArray(e))try{for(let o=0;o<e.length;++o){let r=e[o];if(typeof r=="string"||r instanceof String)t[r]=r;else if(typeof r=="object"){let s=null;for(let i in r){let l=r[i];if(i=i.trim(),!i){console.error("Invalid target");break}if(typeof l=="string"||l instanceof String){l=l.trim(),s=[i,l];break}if(typeof l=="number")break}s&&(t[s[0]]=s[1])}}}catch(o){console.error({lid:4321},o.message)}else t=e;re(this,x,Object.assign({},t,{...C}))}addTargets(e){let t=a(this,x),o=Object.assign({},t,e);this.setTargets(o)}getTargets(){return Object.freeze(a(this,x))}setActiveTargets(e=null){if(e===null){this.activeTargets=[C.ALL];return}else if(typeof e=="string"||e instanceof String)e=e.split(",");else if(typeof e=="object"||typeof e=="function")return;for(let t=0;t<e.length;++t)e[t]=e[t].trim();this.activeTargets=e}getActiveTarget(){return this.activeTargets}setActiveTarget(e){this.activeTargets=[],this.setActiveTargets(e),this.activeTargets=[this.activeTargets[0]]}setLogLevel(e,t){a(this,R)[e]=t}getLogLevel(e){return a(this,R)[e]}setLogLevels(e){re(this,R,e)}getLogLevels(){return Object.freeze(a(this,R))}isTargetAllowed(e){return!e||!this.activeTargets||!this.activeTargets.length||e===C.ALL||this.activeTargets.includes(C.ALL)?!0:this.activeTargets.includes(e)}setColumns(e,t,o){let r=0;for(let i in t){if(!["contextName","symbol","lid","text"].includes(i))continue;let l=t[i],c=document.createElement("span");c.classList.add("analogger-col",`analogger-col-${i}`,`analogger-col-${r}`),++r,c.textContent=l,e.append(c)}let s=document.createElement("span");s.classList.add("analogger-col","analogger-col-text",`analogger-col-${r}`),s.textContent=o,e.append(s);for(let i=1;i<=3;++i)s=document.createElement("span"),s.classList.add("analogger-col","analogger-col-extra",`analogger-extra-${i}`),e.append(s)}checkOnLoggingToDom(e,t){try{let o=e.onLoggingToDom;return typeof o!="function"?void 0:o.call(this,e,t)}catch{}}addLineToDom(e,t,{context:o,addType:r,message:s,text:i,args:l}){if(this.checkOnLoggingToDom(o,{message:s,text:i,args:l,logCounter:this.logCounter,$view:e,$line:t,addType:r})===!1)return;if(r===$.BOTTOM?e.append(t):e.insertBefore(t,e.firstChild),this.removeDomOldEntries(e)){if(e.getElementsByClassName(ae).length)return;this.showRemovedNotification(o);return}this.scrollDivToBottom(e)}showRemovedNotification(e){e.contextName=Ae,e.symbol="\u{1F5D1}",e.color="orange",e.className=ae,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(e,"",{addType:$.TOP,message:"Oldest entries removed"})},500)}writeLogToDom(e,t,{addType:o=$.BOTTOM,message:r="",args:s=null}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),t=r||t;for(let i=0;i<this.$containers.length;++i){let l=this.$containers[i],c=l.querySelector("."+ce);c||(c=document.createElement("div"),c.classList.add(ce),c.append(document.createElement("span")),c.append(document.createElement("span")),c.append(document.createElement("span")),l.append(c));let p=l.querySelector("."+fe);p||(p=document.createElement("div"),p.classList.add(fe),l.append(p));let f=l.querySelector("."+de);f||(f=document.createElement("div"),f.classList.add(de),f.append(document.createElement("span")),f.append(document.createElement("span")),f.append(document.createElement("span")),l.append(f));let g=document.createElement("div");g.classList.add(Oe),e.className&&g.classList.add(e.className),g.style.color=e.color,this.setColumns(g,e,t,s),setTimeout(function(L,U,{addType:K,context:Q,message:Z,text:ee,args:G}){this.addLineToDom(L,U,{addType:K,context:Q,message:Z,text:ee,args:G})}.bind(this,p,g,{addType:o,context:e,message:r,text:t,args:s}),0)}}writeLogToFile(e){try{fs.appendFileSync(this.options.logToFilePath,e+this.EOL)}catch(t){console.rawError("LOG_TO_FILE_FAILURE: ",t.message)}}writeLogToRemote(...e){try{let t=this.generateLogToRemoteUrl(this.options.logToRemoteUrl);if(!t)return null;let o=[...e],r=JSON.stringify(o);fetch(t,{method:"post",body:r,headers:{"Content-Type":"application/json"}}).then(s=>s.json()).catch(()=>null)}catch(t){console.rawError("LOG_TO_REMOTE_FAILURE: ",t.message)}}uploadDataToRemote(e,t=null,o=null){try{if(!this.options.logToRemote)return;let r=this.generateLogToRemoteUrl(this.options.logToRemoteBinaryUrl,{pathname:E.binarypathname});if(!r)return null;let s=e;t&&(s=JSON.stringify({raw:e,context:t})),fetch(r,{method:"post",body:s}).then(i=>i.json()).then(i=>o&&o(i)).catch(i=>i)}catch(r){console.rawError("BINARY_TO_REMOTE_FAILURE: ",r.message)}}stringifyEntry(e){let t;try{t=JSON.stringify(e)}catch{}if(!t)try{t=we(e)}catch{}return t}convertEntry(e){try{if(e==null||e==="")return e;if(typeof e=="boolean")return e;if(typeof e=="symbol"||typeof e=="number")return e;if(typeof e=="string"||myVar instanceof e)return e;if(e instanceof Date)return e}catch{}return this.stringifyEntry(e)}convertArgumentsToText(e){let t=[],o,r=e.length;for(let s=0;s<r;++s){let i,l=e[s];i=this.convertEntry(l),t.push(i)}return o=t.join("\u2022"),o}writeToConsole(e,t){let o=[e];this.isBrowser()&&o.push(`color: ${t.color}`);let r=t.contextLevel||u.LOG;r>=u.ERROR?a(this,v).call(this,...o):r>=u.WARN?a(this,N).call(this,...o):r>=u.INFO?a(this,w).call(this,...o):r>=u.LOG?a(this,b).call(this,...o):r>=u.DEBUG&&a(this,z).call(this,...o)}checkPlugins(e,{message:t,text:o,args:r,logCounter:s}){try{if(!Object.keys(h.pluginTable).length)return;let i=!0;for(let l in e){let c=e[l];if(!c)continue;let p=h.pluginTable[l];if(!p||typeof p!="object")continue;let{callback:f,methodName:g,type:L}=p;if(typeof f!="function")continue;f.call(this,e,{message:t,text:o,args:r,logCounter:s,methodName:g,type:L,pluginOptions:c})===!1&&(i=!1)}return i}catch{}}checkOnLogging(e,t){try{let o=e.onLogging;return typeof o!="function"?void 0:o.call(this,e,t)}catch{}}processOutput(e={}){try{let t="";if(this.applySymbolByName(e),!this.isTargetAllowed(e.target)||e.logLevel===u.OFF||this.options.requiredLogLevel>e.logLevel)return;let o=Array.prototype.slice.call(arguments,1);t=this.convertArgumentsToText(o);let r="",s=this.format({...e,message:t});this.keepLog&&this.addToLogHistory({context:e,message:t,text:s}),++this.logCounter;let i;if(i=this.checkOnLogging(e,{message:t,text:s,args:o,logCounter:this.logCounter}),i===!1||(i=this.checkPlugins(e,{message:t,text:s,args:o,logCounter:this.logCounter}),i===!1)||(this.options.logToRemote&&this.writeLogToRemote(e,...o),this.isBrowser()?(e.environnment=h.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(e,s,{message:t,args:o}),r=`%c${s}`):(e.environnment=h.ENVIRONMENT_TYPE.NODE,r=Y.getTextFromColor(s,{fg:e.color,bg:e.bgColor,isBold:e.bold,isUnderline:e.underline,isReversed:e.reversed}),this.options.logToFile&&this.writeLogToFile(s)),this.options.hideLog))return;this.writeToConsole(r,e),this.errorTargetHandler(e,o)}catch(t){console.rawError("AnaLogger:",t.message)}}isExtendedOptionsPassed(e){return typeof e!="object"?!1:e.hasOwnProperty("context")||e.hasOwnProperty("target")||e.hasOwnProperty("color")||e.hasOwnProperty("contextName")||e.hasOwnProperty("lid")}extractContextFromInput(e){return(typeof e=="string"||e instanceof String)&&e.toLowerCase().indexOf("lid:")!==0,e}listSymbols(){for(let e in V)console.rawLog(V[e]+` ${e} `)}applySymbolByName(e){try{e.symbol&&V[e.symbol]&&(e.symbol=V[e.symbol])}catch{}}convertToContext(e,t){e=e||t;let o=e;if(e.context&&typeof e.context=="object"){let r=Object.assign({},e);delete r.context,o=Object.assign({},e.context,r)}return o=Object.assign({},t,o),delete o.context,o}log(e,...t){if(e=this.extractContextFromInput(e),!this.isExtendedOptionsPassed(e)){let s=this.generateDefaultContext();this.processOutput.apply(this,[s,e,...t]);return}let o=this.generateDefaultContext(),r=this.convertToContext(e,o);this.processOutput.apply(this,[r,...t])}error(e,...t){if(this.options.hideError)return;if(e=this.extractContextFromInput(e),!this.isExtendedOptionsPassed(e)){let i=this.generateErrorContext();this.processOutput.apply(this,[i,e,...t]);return}let o=this.generateErrorContext(),r=this.convertToContext(e,o),s=Array.prototype.slice.call(arguments,1);this.log(r,...s)}overrideError(){this.options.hideHookMessage||a(this,b).call(this,"AnaLogger: Hook placed on console.error"),a(this,T).error=!0,console.error=this.onDisplayError.bind(this)}attachConsole(){try{return console.rawLog=a(this,b),console.raw=a(this,b),console.rawInfo=a(this,w),console.rawWarn=a(this,N),console.rawError=a(this,v),console.logHistory=this.logHistory,console.logHistory=this.logHistory,Qe.forEach(e=>{console[e]=function(...t){this[e](...t)}.bind(this)}),!0}catch(e){console.error({lid:4321},e.message)}return!1}overrideConsole({log:e=!0,info:t=!0,warn:o=!0,error:r=!1}={}){this.options.hideHookMessage||a(this,b).call(this,"AnaLogger: Hook placed on console.log"),[{log:e},{info:t},{warn:o}].forEach(function(s){let i=Object.keys(s)[0];s[i]&&(a(this,T)[i]=!0,console[i]=this.onDisplayLog.bind(this))}.bind(this)),r&&this.overrideError(),this.attachConsole()}removeOverrideError(){console.error=a(this,v),a(this,T).error=!1}removeOverride({log:e=!0,info:t=!0,warn:o=!0,error:r=!1}={}){e&&(console.log=a(this,b),a(this,T).log=!1),t&&(console.info=a(this,w),a(this,T).info=!1),o&&(console.warn=a(this,N),a(this,T).warn=!1),r&&this.removeOverrideError()}info(...e){return this.log(...e)}warn(...e){return this.log(...e)}table(...e){if(!a(this,T).log){a(this,B).call(this,...e);return}let t=console.log;console.log=a(this,b),a(this,B).call(this,...e),console.log=t}alert(...e){if(!this.isBrowser())return this.log(...e);let t=e.join(" | ");alert(t)}assert(e,t=!0,...o){let r;try{return typeof e=="function"?(r=e(...o),r!==t?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):e!==t?(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:e="",override:t=!1}={}){try{let r={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"}};return this.setDefaultContext(r.DEFAULT),e&&this.setActiveTarget(e),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:6}),t&&(this.overrideConsole(),this.overrideError()),!0}catch(o){console.error({lid:3249},o.message)}return!1}applyPredefinedFormat(e=he.DEFAULT_FORMAT,{activeTarget:t="",override:o=!1}={}){if(e===he.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:t,override:o})}convertToUrl({protocol:e=E.protocol,host:t=E.host,port:o=E.port,pathname:r=E.pathname}={}){let s=new URL("http://localhost");return s.protocol=e,s.host=t,s.port=o,r&&(s.pathname=r),s.toString()}generateLogToRemoteUrl(e=null,{pathname:t=E.pathname}={}){if(typeof e=="string"||e instanceof String)return e;if(!this.isBrowser())return null;let o=this.options.protocol||window.location.protocol+"//",r=this.options.host||window.location.host||E.host,s=this.options.port||E.port;return t=this.options.pathname||t,this.convertToUrl({protocol:o,host:r,port:s,pathname:t})}addPlugin(e,t,o=""){o=o||e,this[e]=t,h.pluginTable[o]={type:Ne.LOCAL,methodName:e,callback:t}}addGlobalPlugin(e,t,o){h[e]=t,h.pluginTable[o]={type:Ne.GLOBAL,methodName:e,callback:t}}getPluginList(){return Object.keys(h.pluginTable)}validatePlugin(e){return h.pluginTable[e]?!0:(console.warn(`The plugin ${e} is not registered`),!1)}},y=h;A=new WeakMap,x=new WeakMap,R=new WeakMap,b=new WeakMap,w=new WeakMap,N=new WeakMap,v=new WeakMap,z=new WeakMap,B=new WeakMap,T=new WeakMap,J=new WeakSet,_e=function(e){let t=this.generateNewContext(),o=Object.assign({},t,e);return o.color.toLowerCase().indexOf("rgb")>-1?o.color=Y.rgbStringToHex(o.color):o.color.indexOf("#")===-1&&(o.color=Y.colorNameToHex(o.color)),o},X=new WeakSet,Se=function(){try{this.setTargets(C),this.setLogLevels(u),this.setContexts(H)}catch(e){console.error({lid:4321},e.message)}return!1},d(y,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),d(y,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),d(y,"instanceCount",0),d(y,"pluginTable",{});var ft=y,Ze=y,dt=Ze,ht=new y;export{ft as AnaLogger,H as DEFAULT_LOG_CONTEXTS,u as DEFAULT_LOG_LEVELS,C as DEFAULT_LOG_TARGETS,ht as anaLogger,dt as default};
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
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
|
|
3
|
-
`),o=[];for(let r=0;r<t.length;++r){let s=t[r];o.push(s)}return o}catch(t){console.rawError(t.message)}return e.message}onDisplayError(...e){try{let t=-1,o=null;for(let r=0;r<e.length;++r){let s=e[r];if(s instanceof Error&&s.stack){t=r,o=this.assistStask(s)||[];break}}if(!o){this.error(...e);return}for(let r=0;r<o.length;++r)e[t]=o[r],this.error(...e)}catch(t){console.rawError(t)}}setLogFormat(e){if(typeof e!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=e.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(e){this.errorTargetHandler=e.bind(this)}setErrorHandlerForUserTarget(e){this.errorUserTargetHandler=e.bind(this)}isContextValid(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null?e.hasOwnProperty("contextName")&&e.hasOwnProperty("target"):!1}setDefaultContext(e){this.setContext(H.DEFAULT.contextName,e)}generateDefaultContext(){let e=a(this,A)[H.DEFAULT.contextName]||{};return e=Object.assign({},{lid:"",contextName:H.DEFAULT.contextName,target:C.ALL,symbol:"\u26A1",color:F[1],logLevel:u.LOG},e),e.name=e.contextName,e.id=this.logIndex++,e}generateNewContext(){let e=this.generateDefaultContext();return e.color=F[this.indexColor++%(F.length-3)+2],e.symbol="",e}generateErrorContext(){let e=this.generateDefaultContext();return e.contextName=H.ERROR.contextName,e.name=e.contextName,e.color=F[0],e.symbol="\u274C",e.error=!0,e.logLevel=u.ERROR,e}setContext(e,t={}){t.contextName=e,t.name=e,t=ne(this,J,Se).call(this,t),a(this,A)[e]=t}getContext(e){return a(this,A)[e]}setContexts(e){Object.keys(e).forEach(o=>{let r=e[o]||{};this.setContext(o,r),e[o]=a(this,A)[o]})}getContexts(){return Object.freeze(a(this,A))}setTargets(e={}){let t={};if(Array.isArray(e))try{for(let o=0;o<e.length;++o){let r=e[o];if(typeof r=="string"||r instanceof String)t[r]=r;else if(typeof r=="object"){let s=null;for(let i in r){let l=r[i];if(i=i.trim(),!i){console.error("Invalid target");break}if(typeof l=="string"||l instanceof String){l=l.trim(),s=[i,l];break}if(typeof l=="number")break}s&&(t[s[0]]=s[1])}}}catch(o){console.error({lid:4321},o.message)}else t=e;re(this,x,Object.assign({},t,{...C}))}addTargets(e){let t=a(this,x),o=Object.assign({},t,e);this.setTargets(o)}getTargets(){return Object.freeze(a(this,x))}setActiveTargets(e=null){if(e===null){this.activeTargets=[C.ALL];return}else if(typeof e=="string"||e instanceof String)e=e.split(",");else if(typeof e=="object"||typeof e=="function")return;for(let t=0;t<e.length;++t)e[t]=e[t].trim();this.activeTargets=e}getActiveTarget(){return this.activeTargets}setActiveTarget(e){this.activeTargets=[],this.setActiveTargets(e),this.activeTargets=[this.activeTargets[0]]}setLogLevel(e,t){a(this,R)[e]=t}getLogLevel(e){return a(this,R)[e]}setLogLevels(e){re(this,R,e)}getLogLevels(){return Object.freeze(a(this,R))}isTargetAllowed(e){return!e||!this.activeTargets||!this.activeTargets.length||e===C.ALL||this.activeTargets.includes(C.ALL)?!0:this.activeTargets.includes(e)}setColumns(e,t,o){let r=0;for(let i in t){if(!["contextName","symbol","lid","text"].includes(i))continue;let l=t[i],c=document.createElement("span");c.classList.add("analogger-col",`analogger-col-${i}`,`analogger-col-${r}`),++r,c.textContent=l,e.append(c)}let s=document.createElement("span");s.classList.add("analogger-col","analogger-col-text",`analogger-col-${r}`),s.textContent=o,e.append(s);for(let i=1;i<=3;++i)s=document.createElement("span"),s.classList.add("analogger-col","analogger-col-extra",`analogger-extra-${i}`),e.append(s)}checkOnLoggingToDom(e,t){try{let o=e.onLoggingToDom;return typeof o!="function"?void 0:o.call(this,e,t)}catch{}}addLineToDom(e,t,{context:o,addType:r,message:s,text:i,args:l}){if(this.checkOnLoggingToDom(o,{message:s,text:i,args:l,logCounter:this.logCounter,$view:e,$line:t,addType:r})===!1)return;if(r===$.BOTTOM?e.append(t):e.insertBefore(t,e.firstChild),this.removeDomOldEntries(e)){if(e.getElementsByClassName(ae).length)return;this.showRemovedNotification(o);return}this.scrollDivToBottom(e)}showRemovedNotification(e){e.contextName=Ae,e.symbol="\u{1F5D1}",e.color="orange",e.className=ae,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(e,"",{addType:$.TOP,message:"Oldest entries removed"})},500)}writeLogToDom(e,t,{addType:o=$.BOTTOM,message:r="",args:s=null}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),t=r||t;for(let i=0;i<this.$containers.length;++i){let l=this.$containers[i],c=l.querySelector("."+ce);c||(c=document.createElement("div"),c.classList.add(ce),c.append(document.createElement("span")),c.append(document.createElement("span")),c.append(document.createElement("span")),l.append(c));let p=l.querySelector("."+fe);p||(p=document.createElement("div"),p.classList.add(fe),l.append(p));let d=l.querySelector("."+de);d||(d=document.createElement("div"),d.classList.add(de),d.append(document.createElement("span")),d.append(document.createElement("span")),d.append(document.createElement("span")),l.append(d));let g=document.createElement("div");g.classList.add(Oe),e.className&&g.classList.add(e.className),g.style.color=e.color,this.setColumns(g,e,t,s),setTimeout(function(L,U,{addType:K,context:Q,message:Z,text:ee,args:G}){this.addLineToDom(L,U,{addType:K,context:Q,message:Z,text:ee,args:G})}.bind(this,p,g,{addType:o,context:e,message:r,text:t,args:s}),0)}}writeLogToFile(e){try{fs.appendFileSync(this.options.logToFilePath,e+this.EOL)}catch(t){console.rawError("LOG_TO_FILE_FAILURE: ",t.message)}}writeLogToRemote(...e){try{let t=this.generateLogToRemoteUrl(this.options.logToRemoteUrl);if(!t)return null;let o=[...e],r=JSON.stringify(o);Ne(t,{method:"post",body:r,headers:{"Content-Type":"application/json"}}).then(s=>s.json()).catch(()=>null)}catch(t){console.rawError("LOG_TO_REMOTE_FAILURE: ",t.message)}}uploadDataToRemote(e,t=null,o=null){try{if(!this.options.logToRemote)return;let r=this.generateLogToRemoteUrl(this.options.logToRemoteBinaryUrl,{pathname:b.binarypathname});if(!r)return null;let s=e;t&&(s=JSON.stringify({raw:e,context:t})),Ne(r,{method:"post",body:s}).then(i=>i.json()).then(i=>o&&o(i)).catch(i=>i)}catch(r){console.rawError("BINARY_TO_REMOTE_FAILURE: ",r.message)}}stringifyEntry(e){let t;try{t=JSON.stringify(e)}catch{}if(!t)try{t=we(e)}catch{}return t}convertEntry(e){try{if(e==null||e==="")return e;if(typeof e=="boolean")return e;if(typeof e=="symbol"||typeof e=="number")return e;if(typeof e=="string"||myVar instanceof e)return e;if(e instanceof Date)return e}catch{}return this.stringifyEntry(e)}convertArgumentsToText(e){let t=[],o,r=e.length;for(let s=0;s<r;++s){let i,l=e[s];i=this.convertEntry(l),t.push(i)}return o=t.join("\u2022"),o}writeToConsole(e,t){let o=[e];this.isBrowser()&&o.push(`color: ${t.color}`);let r=t.contextLevel||u.LOG;r>=u.ERROR?a(this,v).call(this,...o):r>=u.WARN?a(this,N).call(this,...o):r>=u.INFO?a(this,w).call(this,...o):r>=u.LOG?a(this,E).call(this,...o):r>=u.DEBUG&&a(this,z).call(this,...o)}checkPlugins(e,{message:t,text:o,args:r,logCounter:s}){try{if(!Object.keys(h.pluginTable).length)return;let i=!0;for(let l in e){let c=e[l];if(!c)continue;let p=h.pluginTable[l];if(!p||typeof p!="object")continue;let{callback:d,methodName:g,type:L}=p;if(typeof d!="function")continue;d.call(this,e,{message:t,text:o,args:r,logCounter:s,methodName:g,type:L,pluginOptions:c})===!1&&(i=!1)}return i}catch{}}checkOnLogging(e,t){try{let o=e.onLogging;return typeof o!="function"?void 0:o.call(this,e,t)}catch{}}processOutput(e={}){try{let t="";if(this.applySymbolByName(e),!this.isTargetAllowed(e.target)||e.logLevel===u.OFF||this.options.requiredLogLevel>e.logLevel)return;let o=Array.prototype.slice.call(arguments,1);t=this.convertArgumentsToText(o);let r="",s=this.format({...e,message:t});this.keepLog&&this.addToLogHistory({context:e,message:t,text:s}),++this.logCounter;let i;if(i=this.checkOnLogging(e,{message:t,text:s,args:o,logCounter:this.logCounter}),i===!1||(i=this.checkPlugins(e,{message:t,text:s,args:o,logCounter:this.logCounter}),i===!1)||(this.options.logToRemote&&this.writeLogToRemote(e,...o),this.isBrowser()?(e.environnment=h.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(e,s,{message:t,args:o}),r=`%c${s}`):(e.environnment=h.ENVIRONMENT_TYPE.NODE,r=Y.getTextFromColor(s,{fg:e.color,bg:e.bgColor,isBold:e.bold,isUnderline:e.underline,isReversed:e.reversed}),this.options.logToFile&&this.writeLogToFile(s)),this.options.hideLog))return;this.writeToConsole(r,e),this.errorTargetHandler(e,o)}catch(t){console.rawError("AnaLogger:",t.message)}}isExtendedOptionsPassed(e){return typeof e!="object"?!1:e.hasOwnProperty("context")||e.hasOwnProperty("target")||e.hasOwnProperty("color")||e.hasOwnProperty("contextName")||e.hasOwnProperty("lid")}extractContextFromInput(e){return(typeof e=="string"||e instanceof String)&&e.toLowerCase().indexOf("lid:")!==0,e}listSymbols(){for(let e in V)console.rawLog(V[e]+` ${e} `)}applySymbolByName(e){try{e.symbol&&V[e.symbol]&&(e.symbol=V[e.symbol])}catch{}}convertToContext(e,t){e=e||t;let o=e;if(e.context&&typeof e.context=="object"){let r=Object.assign({},e);delete r.context,o=Object.assign({},e.context,r)}return o=Object.assign({},t,o),delete o.context,o}log(e,...t){if(e=this.extractContextFromInput(e),!this.isExtendedOptionsPassed(e)){let s=this.generateDefaultContext();this.processOutput.apply(this,[s,e,...t]);return}let o=this.generateDefaultContext(),r=this.convertToContext(e,o);this.processOutput.apply(this,[r,...t])}error(e,...t){if(this.options.hideError)return;if(e=this.extractContextFromInput(e),!this.isExtendedOptionsPassed(e)){let i=this.generateErrorContext();this.processOutput.apply(this,[i,e,...t]);return}let o=this.generateErrorContext(),r=this.convertToContext(e,o),s=Array.prototype.slice.call(arguments,1);this.log(r,...s)}overrideError(){this.options.hideHookMessage||a(this,E).call(this,"AnaLogger: Hook placed on console.error"),a(this,T).error=!0,console.error=this.onDisplayError.bind(this)}attachConsole(){try{return console.rawLog=a(this,E),console.raw=a(this,E),console.rawInfo=a(this,w),console.rawWarn=a(this,N),console.rawError=a(this,v),console.logHistory=this.logHistory,console.logHistory=this.logHistory,Ze.forEach(e=>{console[e]=function(...t){this[e](...t)}.bind(this)}),!0}catch(e){console.error({lid:4321},e.message)}return!1}overrideConsole({log:e=!0,info:t=!0,warn:o=!0,error:r=!1}={}){this.options.hideHookMessage||a(this,E).call(this,"AnaLogger: Hook placed on console.log"),[{log:e},{info:t},{warn:o}].forEach(function(s){let i=Object.keys(s)[0];s[i]&&(a(this,T)[i]=!0,console[i]=this.onDisplayLog.bind(this))}.bind(this)),r&&this.overrideError(),this.attachConsole()}removeOverrideError(){console.error=a(this,v),a(this,T).error=!1}removeOverride({log:e=!0,info:t=!0,warn:o=!0,error:r=!1}={}){e&&(console.log=a(this,E),a(this,T).log=!1),t&&(console.info=a(this,w),a(this,T).info=!1),o&&(console.warn=a(this,N),a(this,T).warn=!1),r&&this.removeOverrideError()}info(...e){return this.log(...e)}warn(...e){return this.log(...e)}table(...e){if(!a(this,T).log){a(this,B).call(this,...e);return}let t=console.log;console.log=a(this,E),a(this,B).call(this,...e),console.log=t}alert(...e){if(!this.isBrowser())return this.log(...e);let t=e.join(" | ");alert(t)}assert(e,t=!0,...o){let r;try{return typeof e=="function"?(r=e(...o),r!==t?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):e!==t?(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:e="",override:t=!1}={}){try{let r={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"}};return this.setDefaultContext(r.DEFAULT),e&&this.setActiveTarget(e),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:6}),t&&(this.overrideConsole(),this.overrideError()),!0}catch(o){console.error({lid:3249},o.message)}return!1}applyPredefinedFormat(e=he.DEFAULT_FORMAT,{activeTarget:t="",override:o=!1}={}){if(e===he.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:t,override:o})}convertToUrl({protocol:e=b.protocol,host:t=b.host,port:o=b.port,pathname:r=b.pathname}={}){let s=new URL("http://localhost");return s.protocol=e,s.host=t,s.port=o,r&&(s.pathname=r),s.toString()}generateLogToRemoteUrl(e=null,{pathname:t=b.pathname}={}){if(typeof e=="string"||e instanceof String)return e;if(!this.isBrowser())return null;let o=this.options.protocol||window.location.protocol+"//",r=this.options.host||window.location.host||b.host,s=this.options.port||b.port;return t=this.options.pathname||t,this.convertToUrl({protocol:o,host:r,port:s,pathname:t})}addPlugin(e,t,o=""){o=o||e,this[e]=t,h.pluginTable[o]={type:ve.LOCAL,methodName:e,callback:t}}addGlobalPlugin(e,t,o){h[e]=t,h.pluginTable[o]={type:ve.GLOBAL,methodName:e,callback:t}}getPluginList(){return Object.keys(h.pluginTable)}validatePlugin(e){return h.pluginTable[e]?!0:(console.warn(`The plugin ${e} is not registered`),!1)}},y=h;A=new WeakMap,x=new WeakMap,R=new WeakMap,E=new WeakMap,w=new WeakMap,N=new WeakMap,v=new WeakMap,z=new WeakMap,B=new WeakMap,T=new WeakMap,J=new WeakSet,Se=function(e){let t=this.generateNewContext(),o=Object.assign({},t,e);return o.color.toLowerCase().indexOf("rgb")>-1?o.color=Y.rgbStringToHex(o.color):o.color.indexOf("#")===-1&&(o.color=Y.colorNameToHex(o.color)),o},X=new WeakSet,Fe=function(){try{this.setTargets(C),this.setLogLevels(u),this.setContexts(H)}catch(e){console.error({lid:4321},e.message)}return!1},f(y,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),f(y,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),f(y,"instanceCount",0),f(y,"pluginTable",{});var dt=y,et=y,ht=et,ut=new y;export{dt as AnaLogger,H as DEFAULT_LOG_CONTEXTS,u as DEFAULT_LOG_LEVELS,C as DEFAULT_LOG_TARGETS,ut as anaLogger,ht as default};
|
|
1
|
+
var Ie=Object.defineProperty;var He=(n,e,t)=>e in n?Ie(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>(He(n,typeof e!="symbol"?e+"":e,t),t),oe=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var a=(n,e,t)=>(oe(n,e,"read from private field"),t?t.call(n):e.get(n)),m=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},re=(n,e,t,o)=>(oe(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);var ne=(n,e,t)=>(oe(n,e,"access private method"),t);var ue={Foreground:38,Background:48},O="\x1B[1D",ge="\x1B[0m"+O,P={Bold:"\x1B[1m"+O,Underline:"\x1B[4m"+O,Reversed:"\x1B[7m"+O},Be={Bold:"\x1B[1m"+O,Underline:"\x1B[4m"+O,Reversed:"\x1B[7m"+O},se={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 Ue(n){return!!se[n]}var pe=(n,e,t)=>n===e&&e===t?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(e/255*5)+Math.round(t/255*5),me=n=>{let e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(e,function(o,r,s,i){return r+r+s+s+i+i});let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{red:parseInt(t[1],16),blue:parseInt(t[2],16),green:parseInt(t[3],16)}:{}},Le=function({red:n,green:e,blue:t}){let o=n<<16|e<<8|t<<0;return"#"+(16777216+o).toString(16).slice(1)},Ee=function(n){let e=n.matchAll(/\d+/g),t=[];for(let o of e){let r=parseInt(o[0]);if(r>255)return null;t.push(r)}return t.length!==3?null:{red:t[0],green:t[1],blue:t[2]}},Ge=function(n){let e=Ee(n);return e&&Le(e)},j=function(e,t,o){return o<0&&(o+=1),o>1&&(o-=1),o<1/6?e+(t-e)*6*o:o<1/2?t:o<2/3?e+(t-e)*(2/3-o)*6:e},be=({hue:n,saturation:e,lightness:t})=>{let o,r,s;if(e===0)o=r=s=t;else{let i=t<.5?t*(1+e):t+e-t*e,l=2*t-i;o=j(l,i,n+1/3),r=j(l,i,n),s=j(l,i,n-1/3)}return{red:Math.round(o*255),blue:Math.round(s*255),green:Math.round(r*255)}},Te=n=>{let e=n.toLowerCase();return typeof se[e]<"u"?se[e]:""};function S({red:n,blue:e,green:t},o=!0){if(n===void 0||e===void 0||t===void 0)return"";let r=pe(n,e,t);return`\x1B[${o?ue.Foreground:ue.Background};5;`+r+"m "+O}function _(n,e=!0){let{red:t,green:o,blue:r}=me(n);return S({red:t,green:o,blue:r},e)}function q({hue:n,saturation:e,lightness:t},o){let{red:r,green:s,blue:i}=be({hue:n,saturation:e,lightness:t});return S({red:r,green:s,blue:i},o)}function ie(n,e=!0){try{let t;return n=n||"",n?((typeof n=="string"||n instanceof String)&&(n=n.trim()),Ue(n)?(t=Te(n),_(t,e)):typeof n=="object"&&!!n.red&&!!n.blue&&!!n.green?S(n,e):typeof n=="object"&&!!n.hue&&!!n.saturation&&!!n.lightness?q(n,e):n.startsWith("#")?_(n,e):(n=n.toString(),/^[\da-fA-F]+$/.test(n)?_("#"+n,e):"")):""}catch(t){console.error("TO_ANSI_INVALID_ARGUMENT_ERROR",t.message)}}function W(n,{fg:e,bg:t,isUnderline:o=!1,isBold:r=!1,isReversed:s=!1}){let i=!1,l="";return e&&(i=!0,l=l+e),t&&(i=!0,l=l+t),o&&(i=!0,l=l+P.Underline),r&&(i=!0,l=l+P.Bold),s&&(i=!0,l=l+P.Reversed),i?l+n+ge:n}function Pe(n,{fg:e={},bg:t={},isUnderline:o=!1,isBold:r=!1,isReversed:s=!1}){return e&&(e=S({...e})),t&&(t=S({...t},!1)),W(n,{fg:e,bg:t,isUnderline:o,isBold:r,isReversed:s})}function je(n,{fg:e="",bg:t="",isUnderline:o=!1,isBold:r=!1,isReversed:s=!1}){return e&&(e=q({...e})),t&&(t=q({...t},!1)),W(n,{fg:e,bg:t,isUnderline:o,isBold:r,isReversed:s})}function qe(n,{fg:e="",bg:t="",isUnderline:o=!1,isBold:r=!1,isReversed:s=!1}){return e&&(e=_(e)),t&&(t=_(t,!1)),W(n,{fg:e,bg:t,isUnderline:o,isBold:r,isReversed:s})}function We(n,e=null){if(!e)return n;let{fg:t="",bg:o="",isUnderline:r=!1,isBold:s=!1,isReversed:i=!1}=e;return t&&(t=ie(t)),o&&(o=ie(o,!1)),W(n,{fg:t,bg:o,isUnderline:r,isBold:s,isReversed:i})}var Y={fromRgb:S,fromHexa:_,fromHsl:q,fromColor:ie,getTextFromRgb:Pe,getTextFromHsl:je,getTextFromHex:qe,getTextFromColor:We,colorNameToHex:Te,hslToRgb:be,hexToRgb:me,rgbToHex:Le,rgbToAnsi256:pe,rgbStringToRgb:Ee,rgbStringToHex:Ge,hue2rgb:j,RESET:ge,FONT_STYLE:P,STYLE:Be};var ye={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"}},F=ye.COLOR_TABLE,I=ye.SYSTEM,le=2e3,ae="analogger-removed-notif",ce="analogger-header",fe="analogger-view",de="analogger-footer",Oe="to-esm-line",$={TOP:"TOP",BOTTOM:"BOTTOM"},Ae="ANALOGGER",he={DEFAULT_FORMAT:"FORMAT1"};var{parse:rt,stringify:Ye}=JSON,{keys:nt}=Object,$e=String,Ve="string";var xe="object",ze=(n,e)=>e;var Re=(n,e,t)=>{let o=$e(e.push(t)-1);return n.set(t,o),o};var we=(n,e,t)=>{let o=e&&typeof e===xe?(f,g)=>f===""||-1<e.indexOf(f)?g:void 0:e||ze,r=new Map,s=[],i=[],l=+Re(r,s,o.call({"":n},"",n)),c=!l;for(;l<s.length;)c=!0,i[l]=Ye(s[l++],p,t);return"["+i.join(",")+"]";function p(f,g){if(c)return c=!c,g;let L=o.call(this,f,g);switch(typeof L){case xe:if(L===null)return L;case Ve:return r.get(L)||Re(r,s,L)}return L}};var E={moduleName:"analogger",protocol:"http://",host:"localhost",port:12e3,pathname:"analogger",binarypathname:"uploaded",loopback:"localhost",consoleDomId:"#analogger",logFilename:"./analogger.log"},C={ALL:"ALL",USER:"USER"},u={FATAL:5e3,ERROR:4e3,WARN:3e3,INFO:2e3,LOG:1e3,DEBUG:500,ALL:200,OFF:0,INHERIT:-1},Ne={LOCAL:"local",GLOBAL:"global"},H={DEFAULT:{contextName:"DEFAULT",logLevel:u.LOG,symbol:"check"},LOG:{contextName:"LOG",logLevel:u.LOG,symbol:"check"},DEBUG:{contextName:"DEBUG",logLevel:u.DEBUG},INFO:{contextName:"INFO",logLevel:u.INFO,color:"#B18904",symbol:"diamonds"},WARN:{contextName:"WARN",logLevel:u.WARN,color:F[0],symbol:"cross"},ERROR:{contextName:"ERROR",logLevel:u.ERROR},CRITICAL:{contextName:"CRITICAL",logLevel:u.CRITICAL}},Je=`
|
|
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 ve(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"?I.NODE:I.BROWSER}var Xe=ve();function Ke(){return Xe===I.NODE}var Qe=["keepLogHistory","getLogHistory","truncateMessage","truncateMessage","rawLog","removeOverride","removeOverrideError","overrideConsole","overrideError","table","rawInfo","rawWarn","rawError","hasSeenLid"],A,x,R,b,w,N,v,z,B,T,J,_e,X,Se,h=class{constructor({name:e="default"}={}){m(this,J);m(this,X);d(this,"system","");d(this,"instanceId","");d(this,"instanceName","");d(this,"logIndex",0);d(this,"logCounter",0);m(this,A,[]);m(this,x,{});m(this,R,{});d(this,"activeTargets",[]);d(this,"indexColor",0);d(this,"format","");d(this,"keepLog",!1);d(this,"logHistory",[]);d(this,"$containers",null);d(this,"options",{hideHookMessage:!1});m(this,b,console.log);m(this,w,console.info);m(this,N,console.warn);m(this,v,console.error);m(this,z,console.debug);m(this,B,console.table);m(this,T,{log:!1,info:!1,warn:!1,error:!1,debug:!1,table:!1});d(this,"originalFormatFunction");d(this,"removeDomOldEntries",e=>{if(e.childElementCount>le){let o=Math.ceil(le/10);for(let r=0;r<o;++r)e.removeChild(e.firstChild);return o}return 0});d(this,"scrollDivToBottom",e=>{let t=e.scrollHeight-(e.clientHeight+e.scrollTop),o=e.clientHeight||e.offsetHeight;t>o/2||(e.scrollTop=e.scrollHeight)});this.system=ve(),this.format=this.onBuildLog.bind(this),this.originalFormatFunction=this.format,this.instanceName=e,++h.instanceCount,this.instanceId=h.instanceCount+"-"+Date.now(),this.errorTargetHandler=this.onError.bind(this),this.errorUserTargetHandler=this.onErrorForUserTarget.bind(this),this.setOptions(this.options),this.rawLog=a(this,b),this.rawInfo=a(this,w),this.rawWarn=a(this,N),this.rawError=a(this,v),this.ALIGN=h.ALIGN,this.ENVIRONMENT_TYPE=h.ENVIRONMENT_TYPE,ne(this,X,Se).call(this),this.resetLogHistory()}getName(){return this.instanceName}getId(){return this.instanceId}keepLogHistory(){this.keepLog=!0}releaseLogHistory(){this.keepLog=!1}resetLogHistory(){this.logHistory=[]}addToLogHistory(e){e=e||{},this.logHistory.push(Object.assign({},e))}getLogHistory(e=!0,t=Je){let o=this.logHistory||[],r=[];return o.forEach(s=>{let{text:i}=s;r.push(i)}),e?r.join(t):r}getRawLogHistory(){return this.logHistory||[]}hasSeenLid(e){this.logHistory=this.logHistory||[];for(let t=0;t<this.logHistory.length;++t){let r=(this.logHistory[t]||{}).context||{};if(e===r.lid)return!0}return!1}forceEnvironment(e){this.forcedSystem=e}isNode(){return this&&this.forcedSystem?this.forcedSystem===I.NODE:Ke()}isBrowser(){return!this.isNode()}resetLogger(){this.options={},this.options.timeLenMax=10,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.logToRemote=void 0,this.options.logToRemoteUrl=void 0,this.options.logToRemoteBinaryUrl=void 0,this.options.logToDomlogToFile=void 0,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}resetOptions(){this.resetLogger()}setOptions({contextLenMax:e=10,idLenMax:t=5,lidLenMax:o=6,symbolLenMax:r=2,messageLenMax:s=void 0,hideLog:i=void 0,hideError:l=void 0,hideHookMessage:c=void 0,hidePassingTests:p=void 0,logToDom:f=void 0,logToFile:g=void 0,logToRemote:L=void 0,logToRemoteUrl:U=void 0,logToRemoteBinaryUrl:K=void 0,loopback:Q=E.loopback,requiredLogLevel:Z=u.LOG,oneConsolePerContext:ee=void 0,silent:G=void 0,protocol:Fe=void 0,host:Ce=void 0,port:De=void 0,pathname:Me=void 0,binarypathname:ke=void 0}=null){this.options.contextLenMax=e,this.options.idLenMax=t,this.options.lidLenMax=o,this.options.messageLenMax=s,this.options.symbolLenMax=r,this.options.requiredLogLevel=Z;let te;G!==void 0?te=!!G:i!==void 0&&(te=!!i),[{hideLog:te},{oneConsolePerContext:ee},{hideError:l},{hideHookMessage:c},{hidePassingTests:p},{logToRemote:L}].forEach(D=>{let M=Object.keys(D)[0],k=D[M];k!==void 0&&(this.options[M]=!!k)}),[{logToRemoteBinaryUrl:K},{logToRemoteUrl:U},{loopback:Q},{protocol:Fe},{host:Ce},{port:De},{pathname:Me},{binarypathname:ke}].forEach(D=>{let M=Object.keys(D)[0],k=D[M];k!==void 0&&(this.options[M]=k)}),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||E.binarypathname})),f===!1?this.options.logToDom=!1:f!==void 0&&(this.options.logToDom=f===!0?E.consoleDomId:f),g===!1?this.options.logToFile=!1:g!==void 0&&(this.isBrowser()||(this.options.logToFile=g||E.logFilename),a(this,b).call(this,"LogToFile is not supported in this environment. "))}getOptions(){return this.options}truncateMessage(e="",{fit:t=0,align:o=h.ALIGN.LEFT,ellipsis:r="..."}={}){return e=""+e,t&&e.length>t&&(e=e.substring(0,t-r.length)+r),e=o===h.ALIGN.LEFT?e.padEnd(t," "):e.padStart(t," "),e}onBuildLog({contextName:e,message:t="",lid:o="",symbol:r=""}={}){let s=new Date,i=("0"+s.getHours()).slice(-2)+":"+("0"+s.getMinutes()).slice(-2)+":"+("0"+s.getSeconds()).slice(-2);return i=this.truncateMessage(i,{fit:this.options.timeLenMax}),e=this.truncateMessage(e,{fit:this.options.contextLenMax,align:h.ALIGN.RIGHT}),o=this.truncateMessage(o,{fit:this.options.lidLenMax}),this.options.messageLenMax!==void 0&&(t=this.truncateMessage(t,{fit:this.options.messageLenMax})),r=this.truncateMessage(r,{fit:this.options.symbolLenMax}),`[${i}] ${e}: (${o}) ${r} ${t}`}onErrorForUserTarget(e,...t){this.errorUserTargetHandler(e,...t)}onError(e,...t){e.target===a(this,x).USER&&this.onErrorForUserTarget(e,...t)}onDisplayLog(...e){this.log(...e)}assistStask(e){try{let t=e.stack.split(`
|
|
3
|
+
`),o=[];for(let r=0;r<t.length;++r){let s=t[r];o.push(s)}return o}catch(t){console.rawError(t.message)}return e.message}onDisplayError(...e){try{let t=-1,o=null;for(let r=0;r<e.length;++r){let s=e[r];if(s instanceof Error&&s.stack){t=r,o=this.assistStask(s)||[];break}}if(!o){this.error(...e);return}for(let r=0;r<o.length;++r)e[t]=o[r],this.error(...e)}catch(t){console.rawError(t)}}setLogFormat(e){if(typeof e!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=e.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(e){this.errorTargetHandler=e.bind(this)}setErrorHandlerForUserTarget(e){this.errorUserTargetHandler=e.bind(this)}isContextValid(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null?e.hasOwnProperty("contextName")&&e.hasOwnProperty("target"):!1}setDefaultContext(e){this.setContext(H.DEFAULT.contextName,e)}generateDefaultContext(){let e=a(this,A)[H.DEFAULT.contextName]||{};return e=Object.assign({},{lid:"",contextName:H.DEFAULT.contextName,target:C.ALL,symbol:"\u26A1",color:F[1],logLevel:u.LOG},e),e.name=e.contextName,e.id=this.logIndex++,e}generateNewContext(){let e=this.generateDefaultContext();return e.color=F[this.indexColor++%(F.length-3)+2],e.symbol="",e}generateErrorContext(){let e=this.generateDefaultContext();return e.contextName=H.ERROR.contextName,e.name=e.contextName,e.color=F[0],e.symbol="\u274C",e.error=!0,e.logLevel=u.ERROR,e}setContext(e,t={}){t.contextName=e,t.name=e,t=ne(this,J,_e).call(this,t),a(this,A)[e]=t}getContext(e){return a(this,A)[e]}setContexts(e){Object.keys(e).forEach(o=>{let r=e[o]||{};this.setContext(o,r),e[o]=a(this,A)[o]})}getContexts(){return Object.freeze(a(this,A))}setTargets(e={}){let t={};if(Array.isArray(e))try{for(let o=0;o<e.length;++o){let r=e[o];if(typeof r=="string"||r instanceof String)t[r]=r;else if(typeof r=="object"){let s=null;for(let i in r){let l=r[i];if(i=i.trim(),!i){console.error("Invalid target");break}if(typeof l=="string"||l instanceof String){l=l.trim(),s=[i,l];break}if(typeof l=="number")break}s&&(t[s[0]]=s[1])}}}catch(o){console.error({lid:4321},o.message)}else t=e;re(this,x,Object.assign({},t,{...C}))}addTargets(e){let t=a(this,x),o=Object.assign({},t,e);this.setTargets(o)}getTargets(){return Object.freeze(a(this,x))}setActiveTargets(e=null){if(e===null){this.activeTargets=[C.ALL];return}else if(typeof e=="string"||e instanceof String)e=e.split(",");else if(typeof e=="object"||typeof e=="function")return;for(let t=0;t<e.length;++t)e[t]=e[t].trim();this.activeTargets=e}getActiveTarget(){return this.activeTargets}setActiveTarget(e){this.activeTargets=[],this.setActiveTargets(e),this.activeTargets=[this.activeTargets[0]]}setLogLevel(e,t){a(this,R)[e]=t}getLogLevel(e){return a(this,R)[e]}setLogLevels(e){re(this,R,e)}getLogLevels(){return Object.freeze(a(this,R))}isTargetAllowed(e){return!e||!this.activeTargets||!this.activeTargets.length||e===C.ALL||this.activeTargets.includes(C.ALL)?!0:this.activeTargets.includes(e)}setColumns(e,t,o){let r=0;for(let i in t){if(!["contextName","symbol","lid","text"].includes(i))continue;let l=t[i],c=document.createElement("span");c.classList.add("analogger-col",`analogger-col-${i}`,`analogger-col-${r}`),++r,c.textContent=l,e.append(c)}let s=document.createElement("span");s.classList.add("analogger-col","analogger-col-text",`analogger-col-${r}`),s.textContent=o,e.append(s);for(let i=1;i<=3;++i)s=document.createElement("span"),s.classList.add("analogger-col","analogger-col-extra",`analogger-extra-${i}`),e.append(s)}checkOnLoggingToDom(e,t){try{let o=e.onLoggingToDom;return typeof o!="function"?void 0:o.call(this,e,t)}catch{}}addLineToDom(e,t,{context:o,addType:r,message:s,text:i,args:l}){if(this.checkOnLoggingToDom(o,{message:s,text:i,args:l,logCounter:this.logCounter,$view:e,$line:t,addType:r})===!1)return;if(r===$.BOTTOM?e.append(t):e.insertBefore(t,e.firstChild),this.removeDomOldEntries(e)){if(e.getElementsByClassName(ae).length)return;this.showRemovedNotification(o);return}this.scrollDivToBottom(e)}showRemovedNotification(e){e.contextName=Ae,e.symbol="\u{1F5D1}",e.color="orange",e.className=ae,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(e,"",{addType:$.TOP,message:"Oldest entries removed"})},500)}writeLogToDom(e,t,{addType:o=$.BOTTOM,message:r="",args:s=null}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),t=r||t;for(let i=0;i<this.$containers.length;++i){let l=this.$containers[i],c=l.querySelector("."+ce);c||(c=document.createElement("div"),c.classList.add(ce),c.append(document.createElement("span")),c.append(document.createElement("span")),c.append(document.createElement("span")),l.append(c));let p=l.querySelector("."+fe);p||(p=document.createElement("div"),p.classList.add(fe),l.append(p));let f=l.querySelector("."+de);f||(f=document.createElement("div"),f.classList.add(de),f.append(document.createElement("span")),f.append(document.createElement("span")),f.append(document.createElement("span")),l.append(f));let g=document.createElement("div");g.classList.add(Oe),e.className&&g.classList.add(e.className),g.style.color=e.color,this.setColumns(g,e,t,s),setTimeout(function(L,U,{addType:K,context:Q,message:Z,text:ee,args:G}){this.addLineToDom(L,U,{addType:K,context:Q,message:Z,text:ee,args:G})}.bind(this,p,g,{addType:o,context:e,message:r,text:t,args:s}),0)}}writeLogToFile(e){try{fs.appendFileSync(this.options.logToFilePath,e+this.EOL)}catch(t){console.rawError("LOG_TO_FILE_FAILURE: ",t.message)}}writeLogToRemote(...e){try{let t=this.generateLogToRemoteUrl(this.options.logToRemoteUrl);if(!t)return null;let o=[...e],r=JSON.stringify(o);fetch(t,{method:"post",body:r,headers:{"Content-Type":"application/json"}}).then(s=>s.json()).catch(()=>null)}catch(t){console.rawError("LOG_TO_REMOTE_FAILURE: ",t.message)}}uploadDataToRemote(e,t=null,o=null){try{if(!this.options.logToRemote)return;let r=this.generateLogToRemoteUrl(this.options.logToRemoteBinaryUrl,{pathname:E.binarypathname});if(!r)return null;let s=e;t&&(s=JSON.stringify({raw:e,context:t})),fetch(r,{method:"post",body:s}).then(i=>i.json()).then(i=>o&&o(i)).catch(i=>i)}catch(r){console.rawError("BINARY_TO_REMOTE_FAILURE: ",r.message)}}stringifyEntry(e){let t;try{t=JSON.stringify(e)}catch{}if(!t)try{t=we(e)}catch{}return t}convertEntry(e){try{if(e==null||e==="")return e;if(typeof e=="boolean")return e;if(typeof e=="symbol"||typeof e=="number")return e;if(typeof e=="string"||myVar instanceof e)return e;if(e instanceof Date)return e}catch{}return this.stringifyEntry(e)}convertArgumentsToText(e){let t=[],o,r=e.length;for(let s=0;s<r;++s){let i,l=e[s];i=this.convertEntry(l),t.push(i)}return o=t.join("\u2022"),o}writeToConsole(e,t){let o=[e];this.isBrowser()&&o.push(`color: ${t.color}`);let r=t.contextLevel||u.LOG;r>=u.ERROR?a(this,v).call(this,...o):r>=u.WARN?a(this,N).call(this,...o):r>=u.INFO?a(this,w).call(this,...o):r>=u.LOG?a(this,b).call(this,...o):r>=u.DEBUG&&a(this,z).call(this,...o)}checkPlugins(e,{message:t,text:o,args:r,logCounter:s}){try{if(!Object.keys(h.pluginTable).length)return;let i=!0;for(let l in e){let c=e[l];if(!c)continue;let p=h.pluginTable[l];if(!p||typeof p!="object")continue;let{callback:f,methodName:g,type:L}=p;if(typeof f!="function")continue;f.call(this,e,{message:t,text:o,args:r,logCounter:s,methodName:g,type:L,pluginOptions:c})===!1&&(i=!1)}return i}catch{}}checkOnLogging(e,t){try{let o=e.onLogging;return typeof o!="function"?void 0:o.call(this,e,t)}catch{}}processOutput(e={}){try{let t="";if(this.applySymbolByName(e),!this.isTargetAllowed(e.target)||e.logLevel===u.OFF||this.options.requiredLogLevel>e.logLevel)return;let o=Array.prototype.slice.call(arguments,1);t=this.convertArgumentsToText(o);let r="",s=this.format({...e,message:t});this.keepLog&&this.addToLogHistory({context:e,message:t,text:s}),++this.logCounter;let i;if(i=this.checkOnLogging(e,{message:t,text:s,args:o,logCounter:this.logCounter}),i===!1||(i=this.checkPlugins(e,{message:t,text:s,args:o,logCounter:this.logCounter}),i===!1)||(this.options.logToRemote&&this.writeLogToRemote(e,...o),this.isBrowser()?(e.environnment=h.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(e,s,{message:t,args:o}),r=`%c${s}`):(e.environnment=h.ENVIRONMENT_TYPE.NODE,r=Y.getTextFromColor(s,{fg:e.color,bg:e.bgColor,isBold:e.bold,isUnderline:e.underline,isReversed:e.reversed}),this.options.logToFile&&this.writeLogToFile(s)),this.options.hideLog))return;this.writeToConsole(r,e),this.errorTargetHandler(e,o)}catch(t){console.rawError("AnaLogger:",t.message)}}isExtendedOptionsPassed(e){return typeof e!="object"?!1:e.hasOwnProperty("context")||e.hasOwnProperty("target")||e.hasOwnProperty("color")||e.hasOwnProperty("contextName")||e.hasOwnProperty("lid")}extractContextFromInput(e){return(typeof e=="string"||e instanceof String)&&e.toLowerCase().indexOf("lid:")!==0,e}listSymbols(){for(let e in V)console.rawLog(V[e]+` ${e} `)}applySymbolByName(e){try{e.symbol&&V[e.symbol]&&(e.symbol=V[e.symbol])}catch{}}convertToContext(e,t){e=e||t;let o=e;if(e.context&&typeof e.context=="object"){let r=Object.assign({},e);delete r.context,o=Object.assign({},e.context,r)}return o=Object.assign({},t,o),delete o.context,o}log(e,...t){if(e=this.extractContextFromInput(e),!this.isExtendedOptionsPassed(e)){let s=this.generateDefaultContext();this.processOutput.apply(this,[s,e,...t]);return}let o=this.generateDefaultContext(),r=this.convertToContext(e,o);this.processOutput.apply(this,[r,...t])}error(e,...t){if(this.options.hideError)return;if(e=this.extractContextFromInput(e),!this.isExtendedOptionsPassed(e)){let i=this.generateErrorContext();this.processOutput.apply(this,[i,e,...t]);return}let o=this.generateErrorContext(),r=this.convertToContext(e,o),s=Array.prototype.slice.call(arguments,1);this.log(r,...s)}overrideError(){this.options.hideHookMessage||a(this,b).call(this,"AnaLogger: Hook placed on console.error"),a(this,T).error=!0,console.error=this.onDisplayError.bind(this)}attachConsole(){try{return console.rawLog=a(this,b),console.raw=a(this,b),console.rawInfo=a(this,w),console.rawWarn=a(this,N),console.rawError=a(this,v),console.logHistory=this.logHistory,console.logHistory=this.logHistory,Qe.forEach(e=>{console[e]=function(...t){this[e](...t)}.bind(this)}),!0}catch(e){console.error({lid:4321},e.message)}return!1}overrideConsole({log:e=!0,info:t=!0,warn:o=!0,error:r=!1}={}){this.options.hideHookMessage||a(this,b).call(this,"AnaLogger: Hook placed on console.log"),[{log:e},{info:t},{warn:o}].forEach(function(s){let i=Object.keys(s)[0];s[i]&&(a(this,T)[i]=!0,console[i]=this.onDisplayLog.bind(this))}.bind(this)),r&&this.overrideError(),this.attachConsole()}removeOverrideError(){console.error=a(this,v),a(this,T).error=!1}removeOverride({log:e=!0,info:t=!0,warn:o=!0,error:r=!1}={}){e&&(console.log=a(this,b),a(this,T).log=!1),t&&(console.info=a(this,w),a(this,T).info=!1),o&&(console.warn=a(this,N),a(this,T).warn=!1),r&&this.removeOverrideError()}info(...e){return this.log(...e)}warn(...e){return this.log(...e)}table(...e){if(!a(this,T).log){a(this,B).call(this,...e);return}let t=console.log;console.log=a(this,b),a(this,B).call(this,...e),console.log=t}alert(...e){if(!this.isBrowser())return this.log(...e);let t=e.join(" | ");alert(t)}assert(e,t=!0,...o){let r;try{return typeof e=="function"?(r=e(...o),r!==t?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):e!==t?(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:e="",override:t=!1}={}){try{let r={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"}};return this.setDefaultContext(r.DEFAULT),e&&this.setActiveTarget(e),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:6}),t&&(this.overrideConsole(),this.overrideError()),!0}catch(o){console.error({lid:3249},o.message)}return!1}applyPredefinedFormat(e=he.DEFAULT_FORMAT,{activeTarget:t="",override:o=!1}={}){if(e===he.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:t,override:o})}convertToUrl({protocol:e=E.protocol,host:t=E.host,port:o=E.port,pathname:r=E.pathname}={}){let s=new URL("http://localhost");return s.protocol=e,s.host=t,s.port=o,r&&(s.pathname=r),s.toString()}generateLogToRemoteUrl(e=null,{pathname:t=E.pathname}={}){if(typeof e=="string"||e instanceof String)return e;if(!this.isBrowser())return null;let o=this.options.protocol||window.location.protocol+"//",r=this.options.host||window.location.host||E.host,s=this.options.port||E.port;return t=this.options.pathname||t,this.convertToUrl({protocol:o,host:r,port:s,pathname:t})}addPlugin(e,t,o=""){o=o||e,this[e]=t,h.pluginTable[o]={type:Ne.LOCAL,methodName:e,callback:t}}addGlobalPlugin(e,t,o){h[e]=t,h.pluginTable[o]={type:Ne.GLOBAL,methodName:e,callback:t}}getPluginList(){return Object.keys(h.pluginTable)}validatePlugin(e){return h.pluginTable[e]?!0:(console.warn(`The plugin ${e} is not registered`),!1)}},y=h;A=new WeakMap,x=new WeakMap,R=new WeakMap,b=new WeakMap,w=new WeakMap,N=new WeakMap,v=new WeakMap,z=new WeakMap,B=new WeakMap,T=new WeakMap,J=new WeakSet,_e=function(e){let t=this.generateNewContext(),o=Object.assign({},t,e);return o.color.toLowerCase().indexOf("rgb")>-1?o.color=Y.rgbStringToHex(o.color):o.color.indexOf("#")===-1&&(o.color=Y.colorNameToHex(o.color)),o},X=new WeakSet,Se=function(){try{this.setTargets(C),this.setLogLevels(u),this.setContexts(H)}catch(e){console.error({lid:4321},e.message)}return!1},d(y,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),d(y,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),d(y,"instanceCount",0),d(y,"pluginTable",{});var ft=y,Ze=y,dt=Ze,ht=new y;export{ft as AnaLogger,H as DEFAULT_LOG_CONTEXTS,u as DEFAULT_LOG_LEVELS,C as DEFAULT_LOG_TARGETS,ht as anaLogger,dt as default};
|
|
4
4
|
|
package/esm/ana-logger.mjs
CHANGED
|
@@ -21,8 +21,6 @@ import {CONSOLE_HEADER_CLASSNAME, CONSOLE_FOOTER_CLASSNAME} from "./constants.m
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
24
|
const DEFAULT = {
|
|
27
25
|
moduleName: "analogger",
|
|
28
26
|
// Default values for remote-logging
|
|
@@ -558,14 +556,18 @@ class ____AnaLogger
|
|
|
558
556
|
protocol: this.options.protocol,
|
|
559
557
|
host : this.options.host,
|
|
560
558
|
port : this.options.port,
|
|
561
|
-
pathname: this.options.binarypathname
|
|
559
|
+
pathname: this.options.binarypathname || DEFAULT.binarypathname
|
|
562
560
|
});
|
|
563
561
|
}
|
|
564
562
|
|
|
565
563
|
// Special cases
|
|
566
|
-
if (logToDom
|
|
564
|
+
if (logToDom === false)
|
|
565
|
+
{
|
|
566
|
+
this.options.logToDom = false;
|
|
567
|
+
}
|
|
568
|
+
else if (logToDom !== undefined)
|
|
567
569
|
{
|
|
568
|
-
this.options.logToDom = logToDom
|
|
570
|
+
this.options.logToDom = (logToDom === true) ? DEFAULT.consoleDomId : logToDom;
|
|
569
571
|
}
|
|
570
572
|
|
|
571
573
|
if (logToFile === false)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "analogger",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.1",
|
|
4
4
|
"description": "Js Logger",
|
|
5
5
|
"main": "./src/ana-logger.cjs",
|
|
6
6
|
"module": "./esm/src/ana-logger.mjs",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"lint": "eslint.cmd \"src/**/*.{cjs,js}\"",
|
|
24
24
|
"test": "npm run build:demo && nyc --reporter=lcov --reporter=text-summary mocha --exit --sort",
|
|
25
|
-
"manual:check": "genserve.cmd start analogger-
|
|
25
|
+
"manual:check": "genserve.cmd start analogger-manual-check --port 9877 --dir ./demo --openPage ./demo",
|
|
26
|
+
"demo:server": "genserve.cmd restart analogger-demo --port 9880 --dir ./",
|
|
27
|
+
"open:browser:remote": "genserve.cmd restart analogger-demo-remote --port 9882 --dir ./demo/browser-remote --openPage ./index-remote.html",
|
|
26
28
|
"demo:terminal:cjs": "node models/jscode/demo.cjs",
|
|
27
29
|
"*** Pre-Cleaning-1 ****": "# ----------------------------------------------------------------------------------------------------------",
|
|
28
30
|
"*** Pre-Cleaning-2 ****": "# Clean directory",
|
|
@@ -49,12 +51,13 @@
|
|
|
49
51
|
"build:demo:browser": " rimraf ./demo/browser-minified && clonefile --force models/example-1/index.html demo/browser/ && to-esm.cmd models/jscode/demo.cjs --output demo/browser/ --config .toesm.cjs --target browser",
|
|
50
52
|
"build:demo:browser:importmaps": " rimraf ./demo/browser-import-maps && clonefile --force models/example-2/index-maps.html demo/browser-import-maps/ && to-esm.cmd models/jscode/demo.cjs --output demo/browser-import-maps/ --config .toesm.cjs --target browser --html demo/browser-import-maps/*.html --useImportMaps ",
|
|
51
53
|
"build:demo:minified": " rimraf ./demo/browser-minified && clonefile --force models/example-3/index-bundle.html demo/browser-minified/ && to-esm.cmd models/jscode/demo.cjs --config .toesm.cjs --target browser --bundle ./demo/browser-minified/analogger-browser-demo.min.mjs",
|
|
52
|
-
"build:demo:remote": " npx remote-logging --yes && npm run build:esm:browser && rimraf ./demo/browser-remote && clonefile --force models/example-4 demo/browser-remote && clonefile --force browser/ demo/browser-remote/browser/ && genserve.cmd start analogger-demo --port 9877 --dir ./ --open demo/browser-remote/index-remote.html",
|
|
53
54
|
"*** In the Browser with importmap-1 ****": "# ----------------------------------------------------------------------------------------------------------",
|
|
54
55
|
"*** In the Browser with importmap-2 ****": "# Generate models code with import map",
|
|
55
56
|
"*** In the Browser with importmap-3 ****": "# ----------------------------------------------------------------------------------------------------------",
|
|
56
|
-
"build:demo": "npm run
|
|
57
|
-
"quick:run": "node models/jscode/demo.cjs"
|
|
57
|
+
"build:demo": "npm run demo:server && npm run build:demo:terminal && npm run build:demo:browser && npm run build:demo:browser:importmaps && npm run build:demo:minified",
|
|
58
|
+
"quick:run": "node models/jscode/demo.cjs",
|
|
59
|
+
"run:remote:console": "npx remote-logging --yes",
|
|
60
|
+
"run:demo:remote": "npm run build:all && rimraf ./demo/browser-remote && npm run build:esm:browser && clonefile --force --source models/example-4 --sources browser/** demo/browser-remote/ --source dist/analogger.min.css && npm run open:browser:remote"
|
|
58
61
|
},
|
|
59
62
|
"author": "Patrice Thimothee",
|
|
60
63
|
"license": "MIT",
|
|
@@ -83,9 +86,9 @@
|
|
|
83
86
|
"chai-spies": "^1.0.0",
|
|
84
87
|
"chromedriver": "^2.33.0",
|
|
85
88
|
"chromium": "^3.0.3",
|
|
86
|
-
"clonefile": "^3.0
|
|
89
|
+
"clonefile": "^3.1.0",
|
|
87
90
|
"eslint": "^8.8.0",
|
|
88
|
-
"genserve": "^3.6
|
|
91
|
+
"genserve": "^3.7.6",
|
|
89
92
|
"glob": "^8.0.3",
|
|
90
93
|
"html-to-image": "^1.10.8",
|
|
91
94
|
"jsdom": "19.0.0",
|
|
@@ -99,7 +102,7 @@
|
|
|
99
102
|
"to-esm": "^2.22.3"
|
|
100
103
|
},
|
|
101
104
|
"dependencies": {
|
|
102
|
-
"@thimpat/libutils": "1.5
|
|
105
|
+
"@thimpat/libutils": "^1.9.5",
|
|
103
106
|
"commander": "^9.4.0",
|
|
104
107
|
"flatted": "3.2.7",
|
|
105
108
|
"node-fetch": "^3.2.10",
|
package/src/ana-logger.cjs
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/** to-esm-browser: add
|
|
2
|
-
let fetch = null;
|
|
3
|
-
**/
|
|
4
|
-
|
|
5
1
|
/** to-esm-browser: remove **/
|
|
6
2
|
const path = require("path");
|
|
7
3
|
const fs = require("fs");
|
|
@@ -554,14 +550,18 @@ class ____AnaLogger
|
|
|
554
550
|
protocol: this.options.protocol,
|
|
555
551
|
host : this.options.host,
|
|
556
552
|
port : this.options.port,
|
|
557
|
-
pathname: this.options.binarypathname
|
|
553
|
+
pathname: this.options.binarypathname || DEFAULT.binarypathname
|
|
558
554
|
});
|
|
559
555
|
}
|
|
560
556
|
|
|
561
557
|
// Special cases
|
|
562
|
-
if (logToDom
|
|
558
|
+
if (logToDom === false)
|
|
559
|
+
{
|
|
560
|
+
this.options.logToDom = false;
|
|
561
|
+
}
|
|
562
|
+
else if (logToDom !== undefined)
|
|
563
563
|
{
|
|
564
|
-
this.options.logToDom = logToDom
|
|
564
|
+
this.options.logToDom = (logToDom === true) ? DEFAULT.consoleDomId : logToDom;
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
if (logToFile === false)
|