analogger 1.20.3 → 1.21.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 +7 -1
- package/README.md +215 -9
- package/browser/src/ana-logger.mjs +360 -102
- package/browser/src/html-to-image-plugin.mjs +69 -15
- package/dist/ana-light.min.css +1 -1
- package/dist/analogger-browser.min.mjs +3 -3
- package/dist/analogger.min.css +1 -1
- package/esm/src/ana-logger.mjs +360 -102
- package/package.json +1 -1
- package/src/ana-logger.cjs +360 -102
- package/src/html-to-image-plugin.cjs +69 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
## [1.
|
|
1
|
+
## [1.21.1](https://github.com/thimpat/analogger/compare/v1.21.0...v1.21.1) (2022-09-13)
|
|
2
2
|
|
|
3
|
+
# [1.21.0](https://github.com/thimpat/analogger/compare/v1.20.4...v1.21.0) (2022-09-10)
|
|
4
|
+
|
|
5
|
+
## [1.20.4](https://github.com/thimpat/analogger/compare/v1.20.3...v1.20.4) (2022-09-07)
|
|
6
|
+
|
|
7
|
+
## [1.20.3](https://github.com/thimpat/analogger/compare/v1.20.2...v1.20.3) (2022-09-07)
|
|
8
|
+
|
|
3
9
|
## [1.20.2](https://github.com/thimpat/analogger/compare/v1.20.1...v1.20.2) (2022-09-07)
|
|
4
10
|
|
|
5
11
|
## [1.20.1](https://github.com/thimpat/analogger/compare/v1.20.0...v1.20.1) (2022-09-06)
|
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ import {anaLogger} from "./node_modules/analogger/dist/analogger-browser.min.mjs
|
|
|
102
102
|

|
|
103
103
|
|
|
104
104
|
#### Remote logging
|
|
105
|
-

|
|
106
106
|
|
|
107
107
|
<br/>
|
|
108
108
|
|
|
@@ -360,6 +360,9 @@ anaLogger.setOptions({silent: false, logToFile: logFilePath});
|
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
<br/>
|
|
363
|
+
<br/>
|
|
364
|
+
|
|
365
|
+
---
|
|
363
366
|
|
|
364
367
|
##### Write logs to a remote server
|
|
365
368
|
|
|
@@ -367,8 +370,139 @@ anaLogger.setOptions({silent: false, logToFile: logFilePath});
|
|
|
367
370
|
// Use a predefined remote server
|
|
368
371
|
anaLogger.setOptions({logToRemote: true});
|
|
369
372
|
|
|
370
|
-
// Use your remote server (You are
|
|
371
|
-
anaLogger.setOptions({
|
|
373
|
+
// Use your remote server (You are responsible for the back-end implementation)
|
|
374
|
+
anaLogger.setOptions({logToRemoteUrl: "http://your.server.com/data"});
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
> Your server must support the POST method.
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
<br/>
|
|
381
|
+
|
|
382
|
+
##### Example
|
|
383
|
+
|
|
384
|
+
_The data received by your server may look like this:_
|
|
385
|
+
|
|
386
|
+
```json
|
|
387
|
+
[
|
|
388
|
+
[{"lid": 123888, "color": "blue"}, "My message 1"],
|
|
389
|
+
[{"lid": 123999, "color": "#654785"}, "My message 2"]
|
|
390
|
+
]
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
> Your server must support the POST method.
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
<br/>
|
|
397
|
+
<br/>
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
##### Write logs to the Remote Logging module
|
|
402
|
+
|
|
403
|
+
If you don't want to implement the back-end, you can also use the Remote-Logging module.
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
> ###### https://www.npmjs.com/package/remote-logging
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
> ##### Note that Remote Logging is free to use, with no license as there is no use in bundle it in an application.
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
## Set up:
|
|
414
|
+
|
|
415
|
+
### 1- Launch Remote-Logging
|
|
416
|
+
|
|
417
|
+
```shell
|
|
418
|
+
$> npm remote-logging
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
> ##### If you're on Windows, the system may ask you the permission to reach the port. Select private access.
|
|
422
|
+
|
|
423
|
+
> ##### On Linux, You will have to open the port 12000 by default. To change it, pass the option --port number to the command above
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
### 2- Copy the server URL in the AnaLogger options (In your client code)
|
|
427
|
+
|
|
428
|
+

|
|
429
|
+
|
|
430
|
+
```javascript
|
|
431
|
+
|
|
432
|
+
// Enable log to remote
|
|
433
|
+
anaLogger.setOptions({logToRemote: true}); // <= By default, if only this option is set,
|
|
434
|
+
// logToRemote will be set to "http://localhost:12000/analogger"
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
// Enter server URLs
|
|
439
|
+
anaLogger.setOptions({logToRemoteUrl: "http://192.168.1.20:2000/analogger"}); // Standard message
|
|
440
|
+
anaLogger.setOptions({logToRemoteBinaryUrl: "http://192.168.1.20:2000/uploaded"}); // Screenshots
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
<br/>
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
### 3- That's it
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
Every call to anaLogger.log will send the log to your server
|
|
450
|
+
|
|
451
|
+
```javascript
|
|
452
|
+
anaLogger.log({lid: 1000}, `Example 1`)
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
```javascript
|
|
456
|
+
// See in the screensht section below, how to enable the plugin
|
|
457
|
+
anaLogger.lid({takeScreenshot: true, lid: 1000}, `Example 1`)
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
```shell
|
|
461
|
+
# Test the server is listening
|
|
462
|
+
> curl --request POST 'http://localhost:12000/analogger' --header 'Content-Type: application/json' --data-raw '[[{"lid": 123888, "color": "blue"}, "My message 1"], [{"lid": 123999, "color": "blue"}, "My message 2"]]
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
> 
|
|
466
|
+
|
|
467
|
+
<br/>
|
|
468
|
+
|
|
469
|
+
##### Example
|
|
470
|
+
|
|
471
|
+
_Data received by your server may look like this:_
|
|
472
|
+
|
|
473
|
+
```json
|
|
474
|
+
[
|
|
475
|
+
[{"lid": 123888, "color": "blue"}, "My message 1"],
|
|
476
|
+
[{"lid": 123999, "color": "#654785"}, "My message 2"]
|
|
477
|
+
]
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
<br/>
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
### attachConsole();
|
|
485
|
+
|
|
486
|
+
Allows to use the methods defined in the anaLogger instance directly from the console
|
|
487
|
+
|
|
488
|
+
```javascript
|
|
489
|
+
|
|
490
|
+
// Attach methods like keepLogHistory(), hasSeenLid(), etc. to the console
|
|
491
|
+
anaLogger.attachConsole();
|
|
492
|
+
|
|
493
|
+
console.keepLogHistory();
|
|
494
|
+
|
|
495
|
+
[1, -1, 3, -1, -1].forEach((n) =>
|
|
496
|
+
{
|
|
497
|
+
if (n === -1)
|
|
498
|
+
{
|
|
499
|
+
if (!console.hasSeenLid(3000))
|
|
500
|
+
{
|
|
501
|
+
console.log({lid: 3000}, `-1 is not allowed`);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
})
|
|
505
|
+
|
|
372
506
|
```
|
|
373
507
|
|
|
374
508
|
<br/>
|
|
@@ -623,6 +757,76 @@ anaLogger.assert((a, b)=> a === b, true, 2, 2)
|
|
|
623
757
|
---
|
|
624
758
|
|
|
625
759
|
|
|
760
|
+
### setErrorHandlerForUserTarget()
|
|
761
|
+
|
|
762
|
+
Tells whether a log has already been displayed. keepLogHistory must be activated
|
|
763
|
+
|
|
764
|
+
```javascript
|
|
765
|
+
anaLogger.keepLogHistory()
|
|
766
|
+
|
|
767
|
+
anaLogger.log({lid: 1234}, `My name is log`)
|
|
768
|
+
anaLogger.hasSeenLid(1234) // true
|
|
769
|
+
anaLogger.hasSeenLid(1000) // false
|
|
770
|
+
|
|
771
|
+
// Optional
|
|
772
|
+
anaLogger.releaseLogHistory()
|
|
773
|
+
```
|
|
774
|
+
<br/>
|
|
775
|
+
---
|
|
776
|
+
|
|
777
|
+
### isBrowser()()
|
|
778
|
+
|
|
779
|
+
Tells whether the console runs from the browser
|
|
780
|
+
|
|
781
|
+
```javascript
|
|
782
|
+
anaLogger.isBrowser()
|
|
783
|
+
```
|
|
784
|
+
<br/>
|
|
785
|
+
|
|
786
|
+
---
|
|
787
|
+
### keepLogHistory()
|
|
788
|
+
|
|
789
|
+
Keeps log entries in memory
|
|
790
|
+
|
|
791
|
+
```javascript
|
|
792
|
+
anaLogger.keepLogHistory()
|
|
793
|
+
```
|
|
794
|
+
<br/>
|
|
795
|
+
---
|
|
796
|
+
|
|
797
|
+
### releaseLogHistory()
|
|
798
|
+
|
|
799
|
+
Tells the system to no longer keep log entries in memory
|
|
800
|
+
|
|
801
|
+
```javascript
|
|
802
|
+
anaLogger.releaseLogHistory()
|
|
803
|
+
```
|
|
804
|
+
<br/>
|
|
805
|
+
---
|
|
806
|
+
|
|
807
|
+
### resetLogHistory()
|
|
808
|
+
|
|
809
|
+
Delete memorized log entries
|
|
810
|
+
|
|
811
|
+
```javascript
|
|
812
|
+
anaLogger.resetLogHistory()
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
<br/>
|
|
816
|
+
---
|
|
817
|
+
|
|
818
|
+
### getLogHistory()
|
|
819
|
+
|
|
820
|
+
Returns log entries
|
|
821
|
+
|
|
822
|
+
```javascript
|
|
823
|
+
anaLogger.getLogHistory()
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
<br/>
|
|
827
|
+
---
|
|
828
|
+
|
|
829
|
+
|
|
626
830
|
### setErrorHandlerForUserTarget()
|
|
627
831
|
|
|
628
832
|
When an error is detected and should be seen by your app consumers explicitly (for instance, you want to display a
|
|
@@ -678,16 +882,18 @@ import {anaLogger} from "./node_modules/analogger/browser/src/ana-logger.mjs";
|
|
|
678
882
|
// Register the plugin
|
|
679
883
|
import "./node_modules/analogger/browser/src/html-to-image-plugin.mjs";
|
|
680
884
|
|
|
681
|
-
// Ask AnaLogger to upload the image to the predefined server
|
|
682
|
-
|
|
885
|
+
// Ask AnaLogger to upload the image to the predefined server
|
|
886
|
+
// logToRemote
|
|
887
|
+
anaLogger.setOptions({
|
|
888
|
+
logToRemote: true, // Tells AnaLogger to also log to a remote
|
|
889
|
+
logToRemoteUrl: "http://192.168.2.12/endpoint1", // Standard log message
|
|
890
|
+
logToRemoteBinaryUrl: "http://192.168.2.12/enpoint2" // Binary data for images
|
|
891
|
+
});
|
|
683
892
|
|
|
684
893
|
// Take a screenshot then upload to the server
|
|
685
894
|
anaLogger.takeScreenshot({callback: (data) =>
|
|
686
895
|
{
|
|
687
|
-
|
|
688
|
-
const img = new Image();
|
|
689
|
-
img.src = data;
|
|
690
|
-
document.body.appendChild(img);
|
|
896
|
+
console.log(`Uploaded`)
|
|
691
897
|
}});
|
|
692
898
|
|
|
693
899
|
|