analogger 1.12.4 → 1.12.5
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 -3
- package/README.md +62 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
## [1.12.4](https://github.com/thimpat/analogger/compare/v1.12.3...v1.12.4) (2022-05-04)
|
|
2
|
-
|
|
1
|
+
## [1.12.4](https://github.com/thimpat/analogger/compare/v1.12.3...v1.12.4) (2022-05-04)
|
|
2
|
+
|
|
3
3
|
## [1.12.3](https://github.com/thimpat/analogger/compare/v1.12.2...v1.12.3) (2022-05-04)
|
|
4
4
|
|
|
5
5
|
## [1.12.2](https://github.com/thimpat/analogger/compare/v1.12.1...v1.12.2) (2022-05-04)
|
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
|
|
57
57
|
## [1.3.1](https://github.com/thimpat/analogger/compare/v1.3.0...v1.3.1) (2022-02-09)
|
|
58
58
|
|
|
59
|
-
# [1.3.0](https://github.com/thimpat/analogger/compare/v1.2.0...v1.3.0) (2022-02-08)
|
|
59
|
+
# [1.3.0](https://github.com/thimpat/analogger/compare/v1.2.0...v1.3.0) (2022-02-08)
|
package/README.md
CHANGED
|
@@ -368,10 +368,20 @@ const LOG_CONTEXTS = {STANDARD: null, TEST: {color: "#B18904", symbol: "⏰"}, C
|
|
|
368
368
|
const LOG_TARGETS = {ALL: "ALL", DEV1: "TOM", DEV2: "TIM", USER: "USER"};
|
|
369
369
|
|
|
370
370
|
anaLogger.setContexts(LOG_CONTEXTS);
|
|
371
|
-
anaLogger.
|
|
371
|
+
anaLogger.setTargets(LOG_TARGETS); // Allowed targets = "ALL", "TOM", "TIM", "USER"
|
|
372
372
|
|
|
373
|
+
// Many ways to assign an active target
|
|
374
|
+
anaLogger.setActiveTarget(LOG_TARGETS.DEV1); // <- You are "TOM"
|
|
375
|
+
|
|
376
|
+
// Seen as TOM
|
|
373
377
|
anaLogger.log({target: LOG_TARGETS.DEV1}, `Testing log 1`); // You will see this
|
|
378
|
+
anaLogger.log({target: "TOM"}, `Testing log 1`); // You will see this
|
|
379
|
+
|
|
380
|
+
// Not seen (only for TIM)
|
|
374
381
|
anaLogger.log({target: LOG_TARGETS.DEV2}, `Testing log 2`); // You will not see this
|
|
382
|
+
anaLogger.log({target: "TIM"}, `Testing log 2`); // You will not see this
|
|
383
|
+
|
|
384
|
+
// No target defined. Everybody sees this
|
|
375
385
|
anaLogger.log({context: LOG_CONTEXTS.STANDARD}, `Testing log 3`); // You will see this
|
|
376
386
|
anaLogger.log(`Testing log 4`); // You will see this. No context = LOG_CONTEXTS.ALL
|
|
377
387
|
|
|
@@ -379,6 +389,57 @@ anaLogger.log(`Testing log 4`); // You wil
|
|
|
379
389
|
anaLogger.log(LOG_CONTEXTS.C1, `Test Log example C1`); // You will see this
|
|
380
390
|
```
|
|
381
391
|
|
|
392
|
+
To assign the active target, you could use IPs, read a file, read an environment variable, etc.
|
|
393
|
+
It is all up to your implement.
|
|
394
|
+
|
|
395
|
+
Examples:
|
|
396
|
+
|
|
397
|
+
###### IP Based
|
|
398
|
+
|
|
399
|
+
```javascript
|
|
400
|
+
anaLogger.setTargets({DEV1: "192.168.12.45", DEV: "192.168.12.46"});
|
|
401
|
+
anaLogger.setActiveTarget(require('ip').address());
|
|
402
|
+
```
|
|
403
|
+
<br/>
|
|
404
|
+
|
|
405
|
+
###### File based
|
|
406
|
+
|
|
407
|
+
```javascript
|
|
408
|
+
// Example 2: File
|
|
409
|
+
anaLogger.setTargets({DEV1: "fg890234ru20u93r2303092pkid0293"});
|
|
410
|
+
anaLogger.setActiveTarget(require('./something.json').key);
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
<br/>
|
|
414
|
+
|
|
415
|
+
###### Fetch
|
|
416
|
+
```javascript
|
|
417
|
+
// Example 3: Fetch
|
|
418
|
+
anaLogger.setTargets({DEV1: "fg890234ru20u93r2303092pkid0293"});
|
|
419
|
+
const key = (await (await fetch('/private-api/me')).json()).key
|
|
420
|
+
anaLogger.setActiveTarget(key);
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
<br/>
|
|
424
|
+
|
|
425
|
+
###### Environment system based
|
|
426
|
+
|
|
427
|
+
```javascript
|
|
428
|
+
// Example 4: Environment variables
|
|
429
|
+
anaLogger.setActiveTarget(process.env.DEVELOPER); // <= Assuming it has been set on the system host
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
<br/>
|
|
433
|
+
|
|
434
|
+
> Note that there are two targets that cannot be overriden: {ALL: "ALL", USER: "USER"}.
|
|
435
|
+
They are always added by the system in the allowed list, so even if a call to setTargets is empty,
|
|
436
|
+
they will still be set.
|
|
437
|
+
|
|
438
|
+
```javascript
|
|
439
|
+
// Two implicit targets "ALL" and "USER"
|
|
440
|
+
analogger.setTargets()
|
|
441
|
+
```
|
|
442
|
+
|
|
382
443
|
<br/>
|
|
383
444
|
|
|
384
445
|
---
|