analogger 1.10.1 → 1.10.2
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/.genserverc.cjs +26 -0
- package/CHANGELOG.md +5 -3
- package/README.md +66 -9
- package/dist/analogger-browser.min.mjs +5 -0
- package/package.json +5 -8
- package/src/cjs/ana-logger.cjs +12 -3
package/.genserverc.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"protocol": "http://",
|
|
3
|
+
"host": "localhost",
|
|
4
|
+
"strictPort": false,
|
|
5
|
+
"staticDirs": [],
|
|
6
|
+
"API": {
|
|
7
|
+
"EDITOR": "",
|
|
8
|
+
"PASS": "re5fd212er4554gf223ds545",
|
|
9
|
+
"STRICT_PORT": false,
|
|
10
|
+
"SERVER_API_HOST": "localhost",
|
|
11
|
+
"ALIVE_PERIOD": 5000,
|
|
12
|
+
"LOG_FOLDER_NAME": "genserve-log",
|
|
13
|
+
"LOG_PATH": ".",
|
|
14
|
+
"GREETINGS": "Hello Server!",
|
|
15
|
+
"HOT_RELOAD_AGREEMENT_MESSAGE": "Code updated",
|
|
16
|
+
"HOT_RELOAD_QUERY": "hot_reload=true",
|
|
17
|
+
"NOT_HOT_RELOAD_QUERY": "hot_reload=false",
|
|
18
|
+
"TIMEOUT_ON_START_SERVER": 5000,
|
|
19
|
+
"SERVER_STATUS": {
|
|
20
|
+
"SERVER_STARTED": "SERVER_STARTED",
|
|
21
|
+
"SERVER_RUNNING": "SERVER_RUNNING",
|
|
22
|
+
"GET_SERVER_INFO": "GET_SERVER_INFO"
|
|
23
|
+
},
|
|
24
|
+
"PER_MESSAGE_DEFLATE": false
|
|
25
|
+
}
|
|
26
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
## [1.10.
|
|
2
|
-
|
|
3
|
-
# [1.10.0](https://github.com/thimpat/analogger/compare/v1.9.1...v1.10.0) (2022-03-16)
|
|
1
|
+
## [1.10.2](https://github.com/thimpat/analogger/compare/v1.10.1...v1.10.2) (2022-04-22)
|
|
4
2
|
|
|
3
|
+
## [1.10.1](https://github.com/thimpat/analogger/compare/v1.10.0...v1.10.1) (2022-04-16)
|
|
4
|
+
|
|
5
|
+
# [1.10.0](https://github.com/thimpat/analogger/compare/v1.9.1...v1.10.0) (2022-03-16)
|
|
6
|
+
|
|
5
7
|
## [1.9.1](https://github.com/thimpat/analogger/compare/v1.9.0...v1.9.1) (2022-03-14)
|
|
6
8
|
|
|
7
9
|
# [1.9.0](https://github.com/thimpat/analogger/compare/v1.8.5...v1.9.0) (2022-03-06)
|
package/README.md
CHANGED
|
@@ -17,6 +17,10 @@ It serves as a packaging example of **hybrid (CJS/ESM) module**.
|
|
|
17
17
|
npm install analogger
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
<br/>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
20
24
|
## Usage
|
|
21
25
|
|
|
22
26
|
### In NodeJS
|
|
@@ -39,6 +43,9 @@ import {anaLogger} from "analogger"
|
|
|
39
43
|
|
|
40
44
|
<br/>
|
|
41
45
|
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
|
|
42
49
|
### Preview
|
|
43
50
|
|
|
44
51
|
#### Terminal
|
|
@@ -55,6 +62,9 @@ import {anaLogger} from "analogger"
|
|
|
55
62
|
|
|
56
63
|
<br/>
|
|
57
64
|
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
|
|
58
68
|
## API
|
|
59
69
|
|
|
60
70
|
<br/>
|
|
@@ -71,6 +81,9 @@ anaLogger.error(`I'am some log`);
|
|
|
71
81
|
```
|
|
72
82
|
<br/>
|
|
73
83
|
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
|
|
74
87
|
### table()
|
|
75
88
|
|
|
76
89
|
Display data in tabular format on the terminal.
|
|
@@ -117,6 +130,9 @@ Kristal │ false │ index.html │ 10060 │ http://localhost:10060/
|
|
|
117
130
|
|
|
118
131
|
<br/>
|
|
119
132
|
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
|
|
120
136
|
### alert()
|
|
121
137
|
|
|
122
138
|
```javascript
|
|
@@ -130,23 +146,44 @@ Display the browser native message box if run from it; otherwise, it displays th
|
|
|
130
146
|
### setOptions()
|
|
131
147
|
|
|
132
148
|
|
|
133
|
-
| **Options** | **default** | **Expect**
|
|
134
|
-
|
|
135
|
-
| silent | false |
|
|
136
|
-
|
|
|
137
|
-
|
|
|
138
|
-
|
|
|
149
|
+
| **Options** | **default** | **Expect** | **Description** |
|
|
150
|
+
|------------------|-------------|-----------------------|------------------------------------------------------------------------------------|
|
|
151
|
+
| silent | false | boolean | _No log will be displayed (only errors)_ |
|
|
152
|
+
| hideLog | false | boolean | _Hide logs from console_ |
|
|
153
|
+
| hideError | false | boolean | _Hide errors from console_ |
|
|
154
|
+
| hideHookMessage | false | boolean | _Hide the automatic message shown when some native console methods are overridden_ |
|
|
155
|
+
| hidePassingTests | false | boolean | _Hide Live test results_ |
|
|
139
156
|
| logToDom | false | string (DOM Selector) | _display log in a DOM container_ |
|
|
140
|
-
| logToFile | false | string (File path)
|
|
157
|
+
| logToFile | false | string (File path) | _write log to a file if running from Node_ |
|
|
141
158
|
|
|
142
159
|
|
|
143
160
|
```javascript
|
|
144
161
|
// No hook alert message + Log messages in the div #analogger
|
|
145
162
|
anaLogger.setOptions({hideHookMessage: true, logToDom: "#analogger"})
|
|
146
163
|
```
|
|
164
|
+
<br/>
|
|
165
|
+
<br/>
|
|
166
|
+
|
|
167
|
+
#### Examples
|
|
168
|
+
|
|
169
|
+
##### Write logs to file only
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
anaLogger.setOptions({silent: true, logToFile: logFilePath});
|
|
173
|
+
```
|
|
147
174
|
|
|
148
175
|
<br/>
|
|
149
176
|
|
|
177
|
+
##### Write logs to both file and console
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
anaLogger.setOptions({silent: false, logToFile: logFilePath});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
<br/>
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
150
187
|
### overrideConsole()
|
|
151
188
|
|
|
152
189
|
```javascript
|
|
@@ -163,18 +200,26 @@ either.
|
|
|
163
200
|
|
|
164
201
|
<br/>
|
|
165
202
|
|
|
203
|
+
---
|
|
204
|
+
|
|
166
205
|
### overrideError()
|
|
167
206
|
|
|
168
207
|
Same as above, but for errors (console.error)
|
|
169
208
|
|
|
170
209
|
<br/>
|
|
171
210
|
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
|
|
172
214
|
### removeOverride() | removeOverrideError()
|
|
173
215
|
|
|
174
216
|
Remove overridden console methods
|
|
175
217
|
|
|
176
218
|
<br/>
|
|
177
219
|
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
|
|
178
223
|
### rawLog() | rawInfo() | rawWarn() | rawInfo()
|
|
179
224
|
|
|
180
225
|
Use native console format after overrides.
|
|
@@ -187,6 +232,9 @@ console.rawLog(`Example 2`); // <= Will use native format
|
|
|
187
232
|
|
|
188
233
|
<br/>
|
|
189
234
|
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
|
|
190
238
|
### setContexts()
|
|
191
239
|
|
|
192
240
|
#### Contexts
|
|
@@ -224,6 +272,9 @@ The "Testing log 2" log will not show up in the console or the terminal.
|
|
|
224
272
|
|
|
225
273
|
<br/>
|
|
226
274
|
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
|
|
227
278
|
### setTargets() / setActiveTarget()
|
|
228
279
|
|
|
229
280
|
#### Targets
|
|
@@ -249,7 +300,10 @@ anaLogger.log(`Testing log 4`); // You wil
|
|
|
249
300
|
anaLogger.log(LOG_CONTEXTS.C1, `Test Log example C1`); // You will see this
|
|
250
301
|
```
|
|
251
302
|
|
|
252
|
-
<br
|
|
303
|
+
<br/>
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
253
307
|
|
|
254
308
|
### assert()
|
|
255
309
|
|
|
@@ -264,7 +318,10 @@ anaLogger.assert(()=>true, true)
|
|
|
264
318
|
anaLogger.assert((a, b)=> a === b, true, 2, 2)
|
|
265
319
|
```
|
|
266
320
|
|
|
267
|
-
<br
|
|
321
|
+
<br/>
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
268
325
|
|
|
269
326
|
### setErrorHandlerForUserTarget()
|
|
270
327
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const r={};{r.c2ab651f80fb492fbe78eb68d2de2259ff02b9c2b6c247f509c80a3717b221ee={};const{parse:b,stringify:g}=JSON,h=Object["keys"],u=String,p="string",m={},T="object",E=(e,o)=>o,L=e=>e instanceof u?u(e):e,x=(e,o)=>typeof o===p?new u(o):o,v=(r,a,s,n)=>{const i=[];for(let e=h(s),o=e["length"],t=0;t<o;t++){var c,f=e[t],l=s[f];l instanceof u?typeof(c=r[l])!==T||a.has(c)?s[f]=n.call(s,f,c):(a.add(c),s[f]=m,i.push({k:f,a:[r,a,c,n]})):s[f]!==m&&(s[f]=n.call(s,f,l))}for(let e=i["length"],o=0;o<e;o++){var{k:t,a:d}=i[o];s[t]=n.call(s,t,v.apply(null,d))}return s},C=(e,o,t)=>{o=u(o.push(t)-1);return e.set(t,o),o},y=(e,o)=>{var e=b(e,x).map(L),t=e[0];const r=o||E;o=typeof t===T&&t?v(e,new Set,t,r):t;return r.call({"":o},"",o)},O=(e,t,o)=>{const r=t&&typeof t===T?(e,o)=>""===e||-1<t.indexOf(e)?o:void 0:t||E,a=new Map,s=[],n=[];let i=+C(a,s,r.call({"":e},"",e)),c=!i;for(;i<s.length;)c=!0,n[i]=g(s[i++],f,o);return"["+n.join(",")+"]";function f(e,o){if(c)return c=!c,o;var t=r.call(this,e,o);switch(typeof t){case T:if(null===t)return t;case p:return a.get(t)||C(a,s,t)}return t}};r.c2ab651f80fb492fbe78eb68d2de2259ff02b9c2b6c247f509c80a3717b221ee.parse=y,r.c2ab651f80fb492fbe78eb68d2de2259ff02b9c2b6c247f509c80a3717b221ee.stringify=O,r.c2ab651f80fb492fbe78eb68d2de2259ff02b9c2b6c247f509c80a3717b221ee.toJSON=e=>b(O(e)),r.c2ab651f80fb492fbe78eb68d2de2259ff02b9c2b6c247f509c80a3717b221ee.fromJSON=e=>y(g(e))}{r["6a5da197dfd806673b1bcbadb3c7aa12c8f7b1cea215c2ad8c7de9c4035c7a58"]={};const B=["#d2466e","#FFA07A","#FF7F50","#FF6347","#FFE4B5","#ADFF2F","#808000","#40E0D0","#1E90FF","#EE82EE","#708090","#DEB887","#FE642E","#210B61","#088A4B","#5E610B","#FA8258","#088A68","#B40431"],U={BROWSER:"BROWSER",NODE:"NODE"};var e=B,a=U;r["6a5da197dfd806673b1bcbadb3c7aa12c8f7b1cea215c2ad8c7de9c4035c7a58"].COLOR_TABLE=e,r["6a5da197dfd806673b1bcbadb3c7aa12c8f7b1cea215c2ad8c7de9c4035c7a58"].COLOR_TABLE=e,r["6a5da197dfd806673b1bcbadb3c7aa12c8f7b1cea215c2ad8c7de9c4035c7a58"].SYSTEM=a,r["6a5da197dfd806673b1bcbadb3c7aa12c8f7b1cea215c2ad8c7de9c4035c7a58"].SYSTEM=a}r.c9b7ccd633a2afdc912a334e9d6e2f81b36188e2c7f947552f00f8686614416d={},r.c9b7ccd633a2afdc912a334e9d6e2f81b36188e2c7f947552f00f8686614416d.default=function(e,o,t,r){var a=(e+(r||"")).toString().includes("%");if("string"==typeof e?[e,o,t,r]=e.match(/(0?\.?\d{1,3})%?\b/g).map(e=>Number(e)):void 0!==r&&(r=Number.parseFloat(r)),"number"!=typeof e||"number"!=typeof o||"number"!=typeof t||255<e||255<o||255<t)throw new TypeError("Expected three numbers below 256");if("number"==typeof r){if(!a&&0<=r&&r<=1)r=Math.round(255*r);else{if(!(a&&0<=r&&r<=100))throw new TypeError(`Expected alpha value (${r}) as a fraction or percentage`);r=Math.round(255*r/100)}r=(256|r).toString(16).slice(1)}else r="";return(t|o<<8|e<<16|1<<24).toString(16).slice(1)+r};{r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"]={};const R={Foreground:38,Background:48},w="[1D",F="[0m"+w,S={Bold:"[1m"+w,Underline:"[4m"+w,Reversed:"[7m"+w},M=(e={Bold:"[1m"+w,Underline:"[4m"+w,Reversed:"[7m"+w},{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"}),A=(e,o,t)=>e===o&&o===t?e<8?16:248<e?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(o/255*5)+Math.round(t/255*5),N=e=>{e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,o,t,r){return o+o+t+t+r+r});e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return e?{red:parseInt(e[1],16),blue:parseInt(e[2],16),green:parseInt(e[3],16)}:{}},D=function(e,o,t){return t<0&&(t+=1),1<t&&--t,t<1/6?e+6*(o-e)*t:t<.5?o:t<2/3?e+(o-e)*(2/3-t)*6:e};function n({red:e,blue:o,green:t},r=!0){if(void 0===e||void 0===o||void 0===t)return"";e=A(e,o,t);return`[${r?R.Foreground:R.Background};5;`+e+"m "+w}function i(e,o){var{red:e,green:t,blue:r}=N(e);return n({red:e,green:t,blue:r},o)}function c({hue:e,saturation:o,lightness:t},r){var{red:e,green:o,blue:t}=(({hue:e,saturation:o,lightness:t})=>{let r,a,s;return 0===o?r=a=s=t:(o=2*t-(t=t<.5?t*(1+o):t+o-t*o),r=D(o,t,e+1/3),a=D(o,t,e),s=D(o,t,e-1/3)),{red:Math.round(255*r),blue:Math.round(255*s),green:Math.round(255*a)}})({hue:e,saturation:o,lightness:t});return n({red:e,green:o,blue:t},r)}function f(e,o){e=(e=>{e=e.toLowerCase();return void 0!==M[e]&&M[e]})(e);return e?i(e,o):""}function l(e,{fg:o,bg:t,isUnderline:r=!1,isBold:a=!1,isReversed:s=!1}){let n="";return o&&(n+=o),t&&(n+=t),r&&(n+=S.Underline),a&&(n+=S.Bold),s&&(n+=S.Reversed),n+e+F}function o(e,{fg:o={},bg:t={},isUnderline:r=!1,isBold:a=!1,isReversed:s=!1}){return l(e,{fg:o=o&&n({...o}),bg:t=t&&n({...t},!1),isUnderline:r,isBold:a,isReversed:s})}function t(e,{fg:o="",bg:t="",isUnderline:r=!1,isBold:a=!1,isReversed:s=!1}){return l(e,{fg:o=o&&c({...o}),bg:t=t&&c({...t},!1),isUnderline:r,isBold:a,isReversed:s})}function s(e,{fg:o="",bg:t="",isUnderline:r=!1,isBold:a=!1,isReversed:s=!1}){return l(e,{fg:o=o&&i(o),bg:t=t&&i(t,!1),isUnderline:r,isBold:a,isReversed:s})}function d(e,{fg:o="",bg:t="",isUnderline:r=!1,isBold:a=!1,isReversed:s=!1}){return l(e,{fg:o=o&&f(o),bg:t=t&&f(t,!1),isUnderline:r,isBold:a,isReversed:s})}r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].default={fromRgb:n,fromHexa:i,fromHsl:c,fromColor:f,getTextFromRgb:o,getTextFromHsl:t,getTextFromHex:s,getTextFromColor:d,hexToRgb:N,rgbToAnsi256:A,hue2rgb:D,RESET:F,FONT_STYLE:S,STYLE:e},r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromRgb=n,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromRgb=n,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromRgb=n,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromHexa=i,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromHexa=i,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromHexa=i,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromHsl=c,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromHsl=c,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromHsl=c,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromColor=f,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromColor=f,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].fromColor=f,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromRgb=o,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromRgb=o,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromRgb=o,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromHsl=t,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromHsl=t,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromHsl=t,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromHex=s,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromHex=s,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromHex=s,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromColor=d,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromColor=d,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].getTextFromColor=d,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].hexToRgb=N,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].hexToRgb=N,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].hexToRgb=N,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].rgbToAnsi256=A,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].rgbToAnsi256=A,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].rgbToAnsi256=A,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].hue2rgb=D,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].hue2rgb=D,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].hue2rgb=D,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].RESET=F,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].RESET=F,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].RESET=F,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].FONT_STYLE=S,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].FONT_STYLE=S,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].FONT_STYLE=S,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].STYLE=e,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].STYLE=e,r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].STYLE=e}{r.fdca3cc4106dc9ab218bbfdcd9068a9c76b71967b0894f3a805ed42b9b279e7a={};let s=r["18fe8cadb35cbe57fc3273397d9b1f522e4538f6ebec2ac10f7999293a0299b6"].default,t=r.c9b7ccd633a2afdc912a334e9d6e2f81b36188e2c7f947552f00f8686614416d.default,{COLOR_TABLE:o,SYSTEM:e}=r["6a5da197dfd806673b1bcbadb3c7aa12c8f7b1cea215c2ad8c7de9c4035c7a58"],n=r.c2ab651f80fb492fbe78eb68d2de2259ff02b9c2b6c247f509c80a3717b221ee["stringify"],v={};v={};const k={DEFAULT:"DEFAULT",ERROR:"ERROR"};class H{system="";logIndex=0;logCounter=0;contexts=[];targets={};activeTarget=null;indexColor=0;format="";keepLog=!1;logHistory=[];$containers=null;options={hideHookMessage:!1};#realConsoleLog=console.log;#realConsoleInfo=console.info;#realConsoleWarn=console.warn;#realConsoleError=console.error;isBrowser0=null;static ALIGN={LEFT:"LEFT",RIGHT:"RIGHT"};static ENVIRONMENT_TYPE={BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"};originalFormatFunction;constructor(){if(H.Instance)return H.Instance;(H.Instance=this).system="object"==typeof process?e.NODE:e.BROWSER,this.format=this.onBuildLog.bind(this),this.originalFormatFunction=this.format,this.errorTargetHandler=this.onError.bind(this),this.errorUserTargetHandler=this.onErrorForUserTarget.bind(this),this.setOptions(this.options),this.rawLog=this.#realConsoleLog,this.rawInfo=this.#realConsoleInfo,this.rawWarn=this.#realConsoleWarn,this.rawError=this.#realConsoleError,console.rawLog=this.#realConsoleLog,console.rawInfo=this.#realConsoleInfo,console.rawWarn=this.#realConsoleWarn,console.rawError=this.#realConsoleError,console.table=this.table,console.buildTable=this.buildTable,console.isNode=this.isNode,console.isBrowser=this.isBrowser,console.truncateMessage=this.truncateMessage,console.rawLog=this.rawLog,console.rawInfo=this.rawInfo,console.rawWarn=this.rawWarn,console.rawError=this.rawError,console.isBrowser0=this.system===e.BROWSER,this.ALIGN=H.ALIGN,this.ENVIRONMENT_TYPE=H.ENVIRONMENT_TYPE}keepLogHistory(){this.keepLog=!0}releaseLogHistory(){this.keepLog=!1}resetLogHistory(){this.logHistory=[]}getLogHistory(e=!0,o=`
|
|
2
|
+
`){const t=JSON.parse(JSON.stringify(this.logHistory.slice(0)));return e?t.join(o):t}isNode(){return this.system===e.NODE}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.logToDomlogToFile=void 0,this.options.silent=!1}resetOptions(){this.resetLogger()}setOptions({contextLenMax:e=10,idLenMax:o=5,lidLenMax:t=6,symbolLenMax:r=2,messageLenMax:a=void 0,hideLog:s=void 0,hideError:n=void 0,hideHookMessage:i=void 0,hidePassingTests:c=void 0,logToDom:f=void 0,logToFile:l=void 0,oneConsolePerContext:d=void 0,silent:b=void 0}=null){this.options.contextLenMax=e,this.options.idLenMax=o,this.options.lidLenMax=t,this.options.messageLenMax=a,this.options.symbolLenMax=r,void 0!==c&&(this.options.hidePassingTests=!!c),void 0!==i&&(this.options.hideHookMessage=!!i),void 0!==s&&(this.options.hideLog=!!s),void 0!==n&&(this.options.hideError=!!n),void 0!==d&&(this.options.oneConsolePerContext=!!d),void 0!==f&&(this.options.logToDom=f||"#analogger"),void 0!==l&&(this.isBrowser()||(this.options.logToFile=l||"./analogger.log"),this.#realConsoleLog("LogToFile is not supported in this environment. ")),void 0!==b&&(this.options.silent=!!b,this.options.hideLog=this.options.silent)}getOptions(){return this.options}truncateMessage(e="",{fit:o=0,align:t=H.ALIGN.LEFT,ellipsis:r="..."}={}){return e=""+e,o&&e.length>o&&(e=e.substring(0,o-r.length)+r),e=t===H.ALIGN.LEFT?e.padEnd(o," "):e.padStart(o," ")}buildTable(o,{ellipsis:t="...",ColumnMinChars:r=6,columnMaxChars:e=0,verticalSeparator:a=" │ ",horizontalSeparator:s="─",availableLength:n=0}={}){let i="";if(!(o=Array.isArray(o)?o:Object.values(Object.values(o)))||!o.length)return"";var c=o[0],f=Object.keys(c);o.unshift(f),s=s.repeat(100);const l={};for(let e=1;e<o.length;++e){var d=o[e];for(let o=0;o<f.length;++o){var b=f[o];const T=d[b];l[b]=l[b]||0;let e;try{e=JSON.stringify(T).length}catch(e){}e=e||r,l[b]=Math.max(l[b],e,b.length)}}this.isBrowser0||(v=v||{},n=n||(v.width||process.stdout.columns||120-a.length-1-5)),n-=4;c=Object.values(l).reduce((e,o)=>e+o,0);if(n<c){var g,h=n/c;for(g in l)l[g]=Math.floor(l[g]*h)-1,r&&l[g]<r&&(l[g]=r),e&&l[g]>e&&(l[g]=e),l[g]=l[g]}let u;u="";for(let e=0;e<f.length;++e){var p=f[e],m=l[p];u=u+this.truncateMessage(p,{fit:m,ellipsis:t})+a}i=i+this.truncateMessage(u,{fit:n})+`
|
|
3
|
+
`,u="";const T=s;for(let e=0;e<f.length;++e){var E=f[e],E=l[E];u=u+this.truncateMessage(T,{fit:E,ellipsis:""})+a}i=i+this.truncateMessage(u,{fit:n})+`
|
|
4
|
+
`;for(let e=1;e<o.length;++e){u="";var L=o[e];for(let e=0;e<f.length;++e){var x=f[e];const T=L[x];x=l[x];u=u+this.truncateMessage(T,{fit:x,ellipsis:t})+a}i=i+this.truncateMessage(u,{fit:n})+`
|
|
5
|
+
`}return this.rawLog(i),i}onBuildLog({contextName:e,message:o="",lid:t="",symbol:r=""}={}){const a=new Date;var s=("0"+a.getHours()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2),s=this.truncateMessage(s,{fit:this.options.timeLenMax});return e=this.truncateMessage(e,{fit:this.options.contextLenMax,align:H.ALIGN.RIGHT}),t=this.truncateMessage(t,{fit:this.options.lidLenMax}),void 0!==this.options.messageLenMax&&(o=this.truncateMessage(o,{fit:this.options.messageLenMax})),`[${s}] ${e}: (${t}) ${r=this.truncateMessage(r,{fit:this.options.symbolLenMax})} `+o}onErrorForUserTarget(e,...o){this.errorUserTargetHandler(e,...o)}onError(e,...o){e.target===this.targets.USER&&this.onErrorForUserTarget(e,...o)}onDisplayLog(...e){this.log(...e)}onDisplayError(...e){this.error(...e)}setLogFormat(e){if("function"!=typeof e)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"object"==typeof e&&!Array.isArray(e)&&null!==e&&(e.hasOwnProperty("contextName")&&e.hasOwnProperty("target"))}setContext(e,o){this.contexts[e]=o}setDefaultContext(e){this.setContext(k.DEFAULT,e)}generateDefaultContext(){let e=this.contexts[k.DEFAULT]||{};return(e=Object.assign({},{name:k.DEFAULT,contextName:k.DEFAULT,target:"ALL",symbol:"⚡",color:o[1]},e)).id=this.logIndex++,e}generateNewContext(){const e=this.generateDefaultContext();return e.color=o[this.indexColor++%(o.length-3)+2],e.symbol="",e}generateErrorContext(){const e=this.generateDefaultContext();return e.name=k.ERROR,e.contextName=k.ERROR,e.color=o[0],e.symbol="❌",e.error=!0,e}#allegeProperties(e){let o=e;e=this.generateNewContext();return-1<(o=Object.assign({},e,o)).color.toLowerCase().indexOf("rgb")?o.color="#"+t(o.color):-1===o.color.indexOf("#")&&0,o}setContexts(t){const e=Object.keys(t);t[k.DEFAULT]=this.contexts[k.DEFAULT]=this.generateDefaultContext(),t[k.ERROR]=this.contexts[k.ERROR]=this.generateErrorContext(),e.forEach(e=>{const o=t[e]||{};o.contextName=e,o.name=e,this.contexts[e]=this.#allegeProperties(o),t[e]=this.contexts[e]})}setTargets(e={}){this.targets=Object.assign({},e,{ALL:"ALL",USER:"USER"})}setActiveTarget(e){this.activeTarget=e}isTargetAllowed(e){return!e||!this.activeTarget||(e===this.targets.ALL||this.activeTarget===e)}setColumns(e,o,t){let r=0;for(var a in o)if("name"!==a){var s=o[a];const n=document.createElement("span");n.classList.add("analogger-col","analogger-col-"+a,"analogger-col-"+r),++r,n.textContent=s,e.append(n)}const n=document.createElement("span");n.classList.add("analogger-col","analogger-col-text","analogger-col-"+r),n.textContent=t,e.append(n)}writeLogToDom(t,r){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom);for(let o=0;o<this.$containers.length;++o){const a=this.$containers[o];let e=a.querySelector(".analogger-view");e||((e=document.createElement("div")).classList.add("analogger-view"),a.append(e));const s=document.createElement("div");s.classList.add("to-esm-line"),s.style.color=t.color,s.setAttribute("data-log-counter",this.logCounter),s.setAttribute("data-log-index",this.logIndex),this.setColumns(s,t,r),e.append(s)}}writeLogToFile(e){try{fs.appendFileSync(this.options.logToFilePath,e+this.EOL)}catch(e){console.rawError("LOG_TO_FILE_FAILURE: ",e.message)}}convertArgumentsToText(t){const r=[];var e=t.length;for(let o=0;o<e;++o){let e;var a=t[o];try{e=JSON.stringify(a)}catch(e){}if(!e)try{e=n(a)}catch(e){}r.push(e)}return r.join("•")}processOutput(t={}){try{var r;if(!this.isTargetAllowed(t.target))return;let e=Array.prototype.slice.call(arguments),o=(e.shift(),r=this.convertArgumentsToText(e),"");var a=this.format({...t,message:r});if(++this.logCounter,this.isBrowser()?(t.environnment=H.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(t,a),o="%c"+a):(t.environnment=H.ENVIRONMENT_TYPE.NODE,o=s.getTextFromHex(a,{fg:t.color}),this.options.logToFile&&this.writeLogToFile(a)),this.keepLog&&this.logHistory.push(o),this.options.hideLog)return;this.isBrowser()?this.#realConsoleLog(o,"color: "+t.color):this.#realConsoleLog(o),this.errorTargetHandler(t,e)}catch(e){console.error("AnaLogger:",e.message)}}isExtendedOptionsPassed(e){return"object"==typeof e&&(e.hasOwnProperty("context")||e.hasOwnProperty("target")||e.hasOwnProperty("color")||e.hasOwnProperty("lid"))}convertToContext(e,o){o=o||this.generateDefaultContext();let t=e=e||o;if(e.context&&"object"==typeof e.context){const r=Object.assign({},e);delete r.context,t=Object.assign({},e.context,r)}return delete(t=Object.assign({},o,t)).context,t}log(e,...o){if(!this.isExtendedOptionsPassed(e))return t=this.generateDefaultContext(),void this.processOutput.apply(this,[t,e,...o]);var t=this.convertToContext(e);this.processOutput.apply(this,[t,...o])}error(e,...o){if(!this.options.hideError){if(!this.isExtendedOptionsPassed(e))return t=this.generateErrorContext(),void this.processOutput.apply(this,[t,e,...o]);var t=this.generateErrorContext(),t=this.convertToContext(e,t),r=Array.prototype.slice.call(arguments,1);this.log(t,...r)}}overrideError(){this.options.hideHookMessage||this.#realConsoleLog("AnaLogger: Hook placed on console.error"),console.error=this.onDisplayError.bind(this)}overrideConsole({log:e=!0,info:o=!0,warn:t=!0,error:r=!1}={}){this.options.hideHookMessage||this.#realConsoleLog("AnaLogger: Hook placed on console.log"),e&&(console.log=this.onDisplayLog.bind(this)),o&&(console.info=this.onDisplayLog.bind(this)),t&&(console.warn=this.onDisplayLog.bind(this)),r&&this.overrideError()}removeOverrideError(){console.warn=this.#realConsoleError}removeOverride({log:e=!0,info:o=!0,warn:t=!0,error:r=!1}={}){e&&(console.log=this.#realConsoleLog),o&&(console.info=this.#realConsoleInfo),t&&(console.warn=this.#realConsoleWarn),r&&this.removeOverrideError()}info(...e){return this.log(...e)}warn(...e){return this.log(...e)}table(...e){return this.buildTable(...e)}alert(...e){if(this.isNode())return this.log(...e);e=e.join(" | ");alert(e)}assert(e,o=!0,...t){try{return"function"==typeof e?e(...t)!==o?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0):e!==o?(this.error("Assert failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)}catch(e){this.error("Unexpected error in assert")}return!1}}a=new H,r.fdca3cc4106dc9ab218bbfdcd9068a9c76b71967b0894f3a805ed42b9b279e7a.default=a,r.fdca3cc4106dc9ab218bbfdcd9068a9c76b71967b0894f3a805ed42b9b279e7a.anaLogger=a,r.fdca3cc4106dc9ab218bbfdcd9068a9c76b71967b0894f3a805ed42b9b279e7a.anaLogger=a,r.fdca3cc4106dc9ab218bbfdcd9068a9c76b71967b0894f3a805ed42b9b279e7a.anaLogger=a}r["02a13848aa1c91a4f43bd5a4475b37cb9e24aa798021414c390eed16e0655312"]={},e={STANDARD:{},TEST:{color:"#B18904",symbol:"⏰"},TEST2:{color:"rgb(127, 127, 127)",symbol:"⏰"},TEST3:{color:"blue",symbol:"⏰"},C1:null,C2:null,C3:null,DEFAULT:{}},a={ALL:"ALL",DEV1:"TOM",DEV2:"TIM",DEV3:"ME",USER:"USER"},r["02a13848aa1c91a4f43bd5a4475b37cb9e24aa798021414c390eed16e0655312"].LOG_CONTEXTS=e,r["02a13848aa1c91a4f43bd5a4475b37cb9e24aa798021414c390eed16e0655312"].LOG_CONTEXTS=e,r["02a13848aa1c91a4f43bd5a4475b37cb9e24aa798021414c390eed16e0655312"].LOG_TARGETS=a,r["02a13848aa1c91a4f43bd5a4475b37cb9e24aa798021414c390eed16e0655312"].LOG_TARGETS=a;{r["792f8fd2c559b9e29dd6933388aead7d27d0df34181f0c7d0506b12c0c80c091"]={};var{LOG_CONTEXTS:e,LOG_TARGETS:a}=r["02a13848aa1c91a4f43bd5a4475b37cb9e24aa798021414c390eed16e0655312"];let o=r.fdca3cc4106dc9ab218bbfdcd9068a9c76b71967b0894f3a805ed42b9b279e7a["anaLogger"];o.keepLogHistory(),o.setContexts(e),o.setTargets(a),o.setActiveTarget(a.DEV3),o.setOptions({logToDom:".analogger"}),o.setOptions({silent:!0}),console.log("=========================="),o.log(e.C1,"You should not see this C1"),o.log(e.C2,"You should not see this C2"),o.log(e.C3,"You should not see this C3"),o.setOptions({silent:!1,hideError:!1,logToFile:"./logme.log"}),o.log(e.C1,"You should see this C100"),o.log(e.C2,"You should see this C200"),o.log(e.C3,"You should see this C300"),console.log("============= From History ==========================="),console.log(o.getLogHistory()),console.log("============= From History (Closed) =================="),o.assert(!0),o.assert(!1),o.assert(()=>!0,!0),o.assert((e,o)=>e===o,!0,2,2),console.log("-------------------------- console.log is about to be overridden"),o.overrideConsole(),console.log("Log After override <= Console.log is overridden"),console.error("-------------------------- console.error is about to be overridden"),o.overrideError(),console.error("Hook on Error placed after override <= Console.error is also overridden"),console.log("=========================="),o.log(e.STANDARD,"Basic Log example 2","+Something 0","+Something 1"),o.log({context:e.TEST,lid:1e5},"Test Log example"),o.log({context:e.TEST,target:a.DEV3,lid:100001},"Test Log example with active target"),o.log({context:e.TEST,target:a.DEV1,lid:100002},"Test Log example with DEV1 target"),o.log({context:e.TEST,target:a.DEV2,lid:100003},"Test Log example with DEV2 target"),o.log("Test Log example with DEFAULT target"),o.log(e.TEST,"Test Log example","+Something 3"),o.log(e.C1,"Test Log example C1"),o.log(e.C2,"Test Log example C2"),o.log(e.C3,"Test Log example C3"),console.log(e.C1,"Test Log example C4"),console.log(e.C1,"Test Log example C5"),console.log(e.C1,"Test Log example C6"),console.error({context:e.ERROR,lid:2e5},"Testing Error 1"),console.error(e.ERROR,"Testing Error 2"),console.error("Testing Error 3"),console.error(void 0,"Testing Error 4"),console.error({context:e.ERROR,target:a.USER,lid:200010},"Testing Error 4"),o.info("Hello from alert",{aaa:1012}),o.setActiveTarget(a.USER),o.setErrorHandlerForUserTarget(function(e){o.log("User explicitly see this message"),o.info("User explicitly see this message",e)}),console.error({context:e.ERROR,target:a.USER,lid:200020},"Testing Error that triggers a special handler"),o.setLogFormat(function({contextName:e,message:o}){return e+": "+o}),console.log(e.C1,"Test Log example C4 with new format"),console.log(e.C1,"Test Log example C5 with new format"),console.log(e.C1,"Test Log example C6 with new format"),o.log("Basic Log example 1")}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "analogger",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"description": "Js Logger",
|
|
5
5
|
"main": "./src/cjs/ana-logger.cjs",
|
|
6
6
|
"module": "./generated/browser/ana-logger.mjs",
|
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"lint": "eslint.cmd \"src/**/*.{cjs,js}\"",
|
|
16
|
-
"test": "npm run build:
|
|
17
|
-
"
|
|
18
|
-
"manual:check": "http-server.cmd -c-1 -p 9877 -o example/index.html ./ ",
|
|
19
|
-
"manual:test": "concurrently --success first --kill-others \"npm run test\" \"npm run server:start\"",
|
|
16
|
+
"test": "npm run build:browser:demo && nyc --reporter=lcov --reporter=text-summary mocha --exit --sort",
|
|
17
|
+
"manual:check": "genserve.cmd start --port 9877 --dir ./ --open example/index.html",
|
|
20
18
|
"demo:terminal:cjs": "node example/cjs/demo.cjs",
|
|
21
19
|
"*** Pre-Cleaning-1 ****": "# ----------------------------------------------------------------------------------------------------------",
|
|
22
20
|
"*** Pre-Cleaning-2 ****": "# Clean directory",
|
|
@@ -73,9 +71,8 @@
|
|
|
73
71
|
"chai-spies": "^1.0.0",
|
|
74
72
|
"chromedriver": "^2.33.0",
|
|
75
73
|
"chromium": "^3.0.3",
|
|
76
|
-
"concurrently": "^7.0.0",
|
|
77
74
|
"eslint": "^8.8.0",
|
|
78
|
-
"
|
|
75
|
+
"genserve": "^1.5.0",
|
|
79
76
|
"jsdom": "19.0.0",
|
|
80
77
|
"jsdom-global": "3.0.2",
|
|
81
78
|
"mocha": "^9.2.0",
|
|
@@ -96,7 +93,7 @@
|
|
|
96
93
|
"pretty-js": "^0.2.2",
|
|
97
94
|
"rgb-hex": "^4.0.0",
|
|
98
95
|
"rgb-hex-cjs": "npm:rgb-hex@^3.0.0",
|
|
99
|
-
"to-ansi": "^1.
|
|
96
|
+
"to-ansi": "^1.1.2",
|
|
100
97
|
"uglify-js": "^3.15.1",
|
|
101
98
|
"window-size": "^1.1.1"
|
|
102
99
|
}
|
package/src/cjs/ana-logger.cjs
CHANGED
|
@@ -242,7 +242,6 @@ class AnaLogger
|
|
|
242
242
|
/** to-esm-browser: remove **/
|
|
243
243
|
// these require won't get compiled by to-esm
|
|
244
244
|
this.options.logToFilePath = path.resolve(this.options.logToFile);
|
|
245
|
-
this.logFile = fs.createWriteStream(this.options.logToFilePath, {flags: "a"});
|
|
246
245
|
this.EOL = os.EOL;
|
|
247
246
|
/** to-esm-browser: end-remove **/
|
|
248
247
|
}
|
|
@@ -304,7 +303,7 @@ class AnaLogger
|
|
|
304
303
|
{
|
|
305
304
|
table = Object.values(Object.values(table));
|
|
306
305
|
}
|
|
307
|
-
|
|
306
|
+
|
|
308
307
|
if (!table || !table.length)
|
|
309
308
|
{
|
|
310
309
|
return "";
|
|
@@ -353,6 +352,8 @@ class AnaLogger
|
|
|
353
352
|
availableLength = availableLength - 4;
|
|
354
353
|
|
|
355
354
|
let totalLength = Object.values(fits).reduce((a, b) => a + b, 0);
|
|
355
|
+
|
|
356
|
+
/* istanbul ignore next */
|
|
356
357
|
if (availableLength < totalLength)
|
|
357
358
|
{
|
|
358
359
|
const ratio = (availableLength) / totalLength;
|
|
@@ -711,7 +712,15 @@ class AnaLogger
|
|
|
711
712
|
|
|
712
713
|
writeLogToFile(text)
|
|
713
714
|
{
|
|
714
|
-
|
|
715
|
+
try
|
|
716
|
+
{
|
|
717
|
+
fs.appendFileSync(this.options.logToFilePath, text + this.EOL);
|
|
718
|
+
}
|
|
719
|
+
catch (e)
|
|
720
|
+
{
|
|
721
|
+
/* istanbul ignore next */
|
|
722
|
+
console.rawError("LOG_TO_FILE_FAILURE: ", e.message);
|
|
723
|
+
}
|
|
715
724
|
}
|
|
716
725
|
|
|
717
726
|
convertArgumentsToText(args)
|