analogger 1.21.4 → 1.22.0

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 CHANGED
@@ -1,5 +1,7 @@
1
- ## [1.21.4](https://github.com/thimpat/analogger/compare/v1.21.3...v1.21.4) (2022-09-14)
1
+ # [1.22.0](https://github.com/thimpat/analogger/compare/v1.21.4...v1.22.0) (2022-09-24)
2
2
 
3
+ ## [1.21.4](https://github.com/thimpat/analogger/compare/v1.21.3...v1.21.4) (2022-09-14)
4
+
3
5
  ## [1.21.3](https://github.com/thimpat/analogger/compare/v1.21.2...v1.21.3) (2022-09-13)
4
6
 
5
7
  ## [1.21.2](https://github.com/thimpat/analogger/compare/v1.21.1...v1.21.2) (2022-09-13)
package/README.md CHANGED
@@ -207,102 +207,6 @@ Analogger.listSymbols()
207
207
  >... (And more)
208
208
  >```
209
209
 
210
-
211
-
212
-
213
- ---
214
-
215
-
216
- ### table()
217
-
218
- Display data in tabular format on the terminal.
219
-
220
- ```javascript
221
- anaLogger.table(data, options)
222
- ```
223
-
224
- <br/>
225
-
226
- ###### Options (for .table)
227
-
228
- | names | Expected | values | Description |
229
- |----------------------|----------|--------|---------------------------------------------------|
230
- | ellipsis | string | "..." | Characters to use when values don't fit |
231
- | ColumnMinChars | number | 6 | Minimum size for a column |
232
- | columnMaxChars | number | 0 | |
233
- | verticalSeparator | string | "│" | Table vertical line symbols |
234
- | horizontalSeparator | string | "─" | Table horizontal line symbols |
235
- | availableLength | number | 0 | Maximum width for table. O for auto size |
236
- | onCompleteHeaders | function | null | Callback to call when headers line is ready |
237
- | onCompleteSeparators | function | null | Callback to call when the separator line is ready |
238
- | onCompleteLines | function | null | Callback to call when a line is complete |
239
-
240
- <br/>
241
-
242
- > The callbacks **onCompleteHeaders, onCompleteSeparators, onCompleteSeparators** must return
243
- > the modified first argument
244
- >
245
- > For instance:
246
- > ```javascript
247
- > anaLogger.table(data, {
248
- > onCompleteLines: (textLine, objectLine) => {
249
- >
250
- > if (objectLine.name === "tom") {
251
- > return textLine;
252
- > }
253
- >
254
- > let newLine = "*" + textLine + "*";
255
- > return newLine;
256
- > }
257
- > })
258
- > ```
259
-
260
- <br/>
261
-
262
- #### Example
263
-
264
- ```javascript
265
- const table = [
266
- {
267
- "serverName" : "Nubia",
268
- "silent" : false,
269
- "defaultPage" : "index.html",
270
- "port" : 10040,
271
- "serverUrl" : "http://localhost:10040/",
272
- },
273
- {
274
- "serverName" : "Lavern",
275
- "silent" : false,
276
- "defaultPage" : "index.html",
277
- "port" : 10050,
278
- "serverUrl" : "http://localhost:10050/",
279
- },
280
- {
281
- "serverName" : "Kristal",
282
- "silent" : false,
283
- "defaultPage" : "index.html",
284
- "host" : "localhost",
285
- "port" : 10060,
286
- "serverUrl" : "http://localhost:10060/",
287
- }
288
- ];
289
- anaLogger.table(table);
290
- ```
291
-
292
- <br/>
293
-
294
- ###### Result:
295
-
296
- ```shell
297
- serverName │ silent │ defaultPage │ port │ serverUrl │
298
- ────────── │ ────── │ ──────────── │ ───── │ ───────────────────────── │
299
- Nubia │ false │ index.html │ 10040 │ http://localhost:10040/ │
300
- Lavern │ false │ index.html │ 10050 │ http://localhost:10050/ │
301
- Kristal │ false │ index.html │ 10060 │ http://localhost:10060/ │
302
- ```
303
-
304
- <br/>
305
-
306
210
  ---
307
211
 
308
212
 
@@ -398,24 +302,24 @@ _The data received by your server may look like this:_
398
302
 
399
303
  ---
400
304
 
401
- ##### Write logs to the Remote Logging module
305
+ ### Write logs to the Remote Logging module
402
306
 
403
307
  You can also use the Remote-Logging module if you don't want to implement the back-end.
404
308
 
405
309
 
406
310
  > ###### https://www.npmjs.com/package/remote-logging
407
311
 
408
-
409
-
410
312
  > ##### Note that Remote Logging is free to use, with no license as there is no use in bundle it in an application.
411
313
 
314
+ <br/>
412
315
 
413
- ## Set up:
414
-
415
- ### 1- Launch Remote-Logging
316
+ #### 1- Launch a remote from the command line
416
317
 
417
318
  ```shell
418
319
  $> npx remote-logging
320
+
321
+ # or if AnaLogger is installed globally
322
+ $> analogger
419
323
  ```
420
324
 
421
325
  > ##### If you're on Windows, the system may ask you permission to reach the port. Select private access.
@@ -423,7 +327,7 @@ $> npx remote-logging
423
327
  > ##### On Linux, You will have to open port 12000 by default. To change it, pass the option --port number to the command above.
424
328
 
425
329
 
426
- ### 2- Copy the server URL in the AnaLogger options (In your client code)
330
+ #### 2- Copy the server URL in the AnaLogger options (In your client code)
427
331
 
428
332
  ![Copy URL](https://github.com/thimpat/analogger/blob/main/docs/images/img_7.png "Remote Logs")
429
333
 
@@ -434,7 +338,6 @@ anaLogger.setOptions({logToRemote: true}); // <= By default, if
434
338
  // logToRemote will be set to "http://localhost:12000/analogger"
435
339
 
436
340
 
437
-
438
341
  // Enter server URLs
439
342
  anaLogger.setOptions({logToRemoteUrl: "http://192.168.1.20:2000/analogger"}); // Standard message
440
343
  anaLogger.setOptions({logToRemoteBinaryUrl: "http://192.168.1.20:2000/uploaded"}); // Screenshots
@@ -443,7 +346,7 @@ anaLogger.setOptions({logToRemoteBinaryUrl: "http://192.168.1.20:2000/uploaded"}
443
346
  <br/>
444
347
 
445
348
 
446
- ### 3- That's it
349
+ #### 3- That's it
447
350
 
448
351
 
449
352
  Every call to anaLogger.log will send the log to your server
@@ -458,7 +361,7 @@ anaLogger.lid({takeScreenshot: true, lid: 1000}, `Example 1`)
458
361
  ```
459
362
 
460
363
  ```shell
461
- # Test the server is listening
364
+ # Test the server is listening from the command line
462
365
  > 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
366
  ```
464
367
 
@@ -872,35 +775,91 @@ anaLoggerInstance2.setOptions({logToFile: "./logme.log"});
872
775
  ### takeScreenshot()
873
776
 
874
777
  You can take a screenshot via the "html-to-image" plugin (integrated in the module).
875
- html-to-image is an external module that this module uses to take screenshots.
876
778
 
779
+ > **"html-to-image"** is an external npm package that this module uses to take screenshots.
780
+
781
+ <br/>
782
+
783
+ 1. **Run a logging server from the command line**
784
+
785
+ ```shell
786
+ $> analogger --port 8754
787
+ ```
788
+ <br/>
789
+
790
+ 2. **Report the address displayed in the console into your client code**
791
+
792
+ ![Browser to Remote Logging view](https://github.com/thimpat/demos/blob/main/remote-logging/images/rl-setup-1.png)
793
+
794
+ <br/>
795
+
796
+ 3. **Link AnaLogger to the remote**
877
797
 
878
798
  ```javascript
879
- // Load an AnaLogger instance
799
+ // Load an AnaLogger instance (We use "import" here because the client is a browser)
880
800
  import {anaLogger} from "./node_modules/analogger/browser/src/ana-logger.mjs";
881
801
 
882
802
  // Register the plugin
883
- import "./node_modules/analogger/browser/src/html-to-image-plugin.mjs";
803
+ import {PLUGIN_NAME} from "./node_modules/analogger/browser/src/html-to-image-plugin.mjs";
884
804
 
885
- // Ask AnaLogger to upload the image to the predefined server
886
- // logToRemote
805
+ // Set AnaLogger to upload logs and images to the remote
887
806
  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
807
+ logToRemote: true, // Tells AnaLogger to also log to a remote
808
+ logToRemoteUrl: "http://192.168.2.12:8754/analogger", // To log standard entries (log, errors) to this url
809
+ logToRemoteBinaryUrl: "http://192.168.2.12/uploaded" // To process screenshot data on this url
891
810
  });
892
811
 
812
+ ```
813
+
814
+ <br/>
815
+
816
+ 4. **Add the code for taking a screenshot**
817
+
818
+ * Method 1
819
+
820
+ ```javascript
821
+ // Trigger the plugin
822
+ anaLogger.log({
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...`);
849
+
850
+ ```
851
+
852
+ * Method 2 (May no longer be supported in the future)
853
+
854
+ ```javascript
893
855
  // Take a screenshot then upload to the server
894
856
  anaLogger.takeScreenshot({callback: (data) =>
895
857
  {
896
858
  console.log(`Uploaded`)
897
859
  }});
898
860
 
899
-
900
861
  ```
901
862
 
902
- <br/>
903
-
904
863
  ---
905
864
 
906
865
  ## Plugins
@@ -927,3 +886,64 @@ anaLogger.addPlugin("doSomething", doSomething);
927
886
  ---
928
887
 
929
888
 
889
+
890
+
891
+ ## Changelog
892
+
893
+ ##### current:
894
+ * Review display for js primitive types
895
+ * Use native console table
896
+ * Set up AnaLogger as a Mocha reporter
897
+ * Launch a remote from AnaLogger
898
+ * Fix remote-related options passed to the setOptions method
899
+ * Launch a remote server from the CLI
900
+
901
+
902
+ ##### 1.21.4:
903
+ * Default the remote to localhost when enabled
904
+
905
+ ##### 1.21.0:
906
+ * Restore the same behaviour as before for getLogHistory
907
+ * Add functionalities to AnaLogger instances
908
+
909
+
910
+ ##### 1.20.4:
911
+ * Fix log level applied one level down
912
+ * Update themes
913
+
914
+
915
+ ##### 1.20.3:
916
+ * Apply empty log id by default for contexts
917
+ * Apply missing symbols
918
+
919
+
920
+ ##### 1.20.2:
921
+ * Add missing files from the build
922
+ * Recolor title bar
923
+ * Add a theme file
924
+ * Add a header and o footer to the layout
925
+ * Use native console table on browsers
926
+ * Apply better environment detection
927
+ * Review logToRemote option
928
+
929
+
930
+ ##### 1.20.1:
931
+ * Review sentence failure for screenshot
932
+ * Fix plugin validation
933
+ * Export and validate plugin names
934
+
935
+
936
+ ##### 1.20.0:
937
+ * Fix default address for remote binary
938
+ * Fix error on a missing callback
939
+ * Fix log displayed twice
940
+ * Add takeScreenshot plugin
941
+
942
+
943
+ ##### 1.19.0:
944
+ * Add context levels
945
+ * Add a logToRemote option
946
+
947
+
948
+
949
+ ---