@xylabs/logger 5.0.84 → 5.0.86

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.
Files changed (2) hide show
  1. package/README.md +102 -294
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
  XYLabs Logger Library
17
17
 
18
+
19
+
18
20
  ## Reference
19
21
 
20
22
  **@xylabs/logger**
@@ -23,30 +25,40 @@ XYLabs Logger Library
23
25
 
24
26
  ## Classes
25
27
 
26
- - [ConsoleLogger](#classes/ConsoleLogger)
27
- - [IdLogger](#classes/IdLogger)
28
- - [LevelLogger](#classes/LevelLogger)
29
- - [SilentLogger](#classes/SilentLogger)
28
+ | Class | Description |
29
+ | ------ | ------ |
30
+ | [ConsoleLogger](#classes/ConsoleLogger) | A LevelLogger that delegates to the global `console` object. |
31
+ | [IdLogger](#classes/IdLogger) | A logger wrapper that prefixes every log message with a bracketed identifier. Useful for distinguishing log output from different components or instances. |
32
+ | [LevelLogger](#classes/LevelLogger) | A logger that filters messages based on a configured log level. Methods for levels above the configured threshold return a no-op function. |
33
+ | [SilentLogger](#classes/SilentLogger) | A logger that does not log anything. This is useful when you want to disable logging like when running unit tests or in silent mode. It implements the `Logger` interface but all methods are no-op functions. |
30
34
 
31
35
  ## Interfaces
32
36
 
33
- - [Logger](#interfaces/Logger)
37
+ | Interface | Description |
38
+ | ------ | ------ |
39
+ | [Logger](#interfaces/Logger) | Interface to handle overlap between Winston & `console` with as much congruency as possible. |
34
40
 
35
41
  ## Type Aliases
36
42
 
37
- - [LogFunction](#type-aliases/LogFunction)
38
- - [LogLevelKey](#type-aliases/LogLevelKey)
39
- - [LogVerbosity](#type-aliases/LogVerbosity)
40
- - [LogLevelValue](#type-aliases/LogLevelValue)
43
+ | Type Alias | Description |
44
+ | ------ | ------ |
45
+ | [LogFunction](#type-aliases/LogFunction) | A generic logging function that accepts any number of arguments. |
46
+ | [LogLevelKey](#type-aliases/LogLevelKey) | String key for a log level (e.g. 'error', 'warn', 'info'). |
47
+ | [LogVerbosity](#type-aliases/LogVerbosity) | Alias for LogLevelKey, representing the verbosity setting as a string. |
48
+ | [LogLevelValue](#type-aliases/LogLevelValue) | Numeric value of a log level (1 through 6). |
41
49
 
42
50
  ## Variables
43
51
 
44
- - [LogLevel](#variables/LogLevel)
52
+ | Variable | Description |
53
+ | ------ | ------ |
54
+ | [LogLevel](#variables/LogLevel) | Numeric log level values, from least verbose (error=1) to most verbose (trace=6). |
45
55
 
46
56
  ## Functions
47
57
 
48
- - [NoOpLogFunction](#functions/NoOpLogFunction)
49
- - [getFunctionName](#functions/getFunctionName)
58
+ | Function | Description |
59
+ | ------ | ------ |
60
+ | [NoOpLogFunction](#functions/NoOpLogFunction) | A log function that silently discards all arguments. |
61
+ | [getFunctionName](#functions/getFunctionName) | Retrieves the name of the calling function by inspecting the stack trace. |
50
62
 
51
63
  ### classes
52
64
 
@@ -67,14 +79,14 @@ A LevelLogger that delegates to the global `console` object.
67
79
  ### Constructor
68
80
 
69
81
  ```ts
70
- new ConsoleLogger(level?): ConsoleLogger;
82
+ new ConsoleLogger(level?: LogLevelValue): ConsoleLogger;
71
83
  ```
72
84
 
73
85
  ### Parameters
74
86
 
75
- #### level?
76
-
77
- [`LogLevelValue`](#../type-aliases/LogLevelValue) = `LogLevel.warn`
87
+ | Parameter | Type | Default value |
88
+ | ------ | ------ | ------ |
89
+ | `level` | [`LogLevelValue`](#../type-aliases/LogLevelValue) | `LogLevel.warn` |
78
90
 
79
91
  ### Returns
80
92
 
@@ -86,27 +98,10 @@ new ConsoleLogger(level?): ConsoleLogger;
86
98
 
87
99
  ## Properties
88
100
 
89
- ### level
90
-
91
- ```ts
92
- readonly level: LogLevelValue;
93
- ```
94
-
95
- ### Inherited from
96
-
97
- [`LevelLogger`](#LevelLogger).[`level`](LevelLogger.md#level)
98
-
99
- ***
100
-
101
- ### logger
102
-
103
- ```ts
104
- readonly logger: Logger;
105
- ```
106
-
107
- ### Inherited from
108
-
109
- [`LevelLogger`](#LevelLogger).[`logger`](LevelLogger.md#logger)
101
+ | Property | Modifier | Type | Inherited from |
102
+ | ------ | ------ | ------ | ------ |
103
+ | <a id="level"></a> `level` | `readonly` | [`LogLevelValue`](#../type-aliases/LogLevelValue) | [`LevelLogger`](#LevelLogger).[`level`](LevelLogger.md#level) |
104
+ | <a id="logger"></a> `logger` | `readonly` | [`Logger`](#../interfaces/Logger) | [`LevelLogger`](#LevelLogger).[`logger`](LevelLogger.md#logger) |
110
105
 
111
106
  ## Accessors
112
107
 
@@ -234,18 +229,15 @@ Useful for distinguishing log output from different components or instances.
234
229
  ### Constructor
235
230
 
236
231
  ```ts
237
- new IdLogger(logger, id?): IdLogger;
232
+ new IdLogger(logger: Logger, id?: () => string): IdLogger;
238
233
  ```
239
234
 
240
235
  ### Parameters
241
236
 
242
- #### logger
243
-
244
- [`Logger`](#../interfaces/Logger)
245
-
246
- #### id?
247
-
248
- () => `string`
237
+ | Parameter | Type |
238
+ | ------ | ------ |
239
+ | `logger` | [`Logger`](#../interfaces/Logger) |
240
+ | `id?` | () => `string` |
249
241
 
250
242
  ### Returns
251
243
 
@@ -258,14 +250,14 @@ new IdLogger(logger, id?): IdLogger;
258
250
  ### Set Signature
259
251
 
260
252
  ```ts
261
- set id(id): void;
253
+ set id(id: string): void;
262
254
  ```
263
255
 
264
256
  #### Parameters
265
257
 
266
- ##### id
267
-
268
- `string`
258
+ | Parameter | Type |
259
+ | ------ | ------ |
260
+ | `id` | `string` |
269
261
 
270
262
  #### Returns
271
263
 
@@ -276,14 +268,14 @@ set id(id): void;
276
268
  ### debug()
277
269
 
278
270
  ```ts
279
- debug(...data): void;
271
+ debug(...data: unknown[]): void;
280
272
  ```
281
273
 
282
274
  ### Parameters
283
275
 
284
- #### data
285
-
286
- ...`unknown`[]
276
+ | Parameter | Type |
277
+ | ------ | ------ |
278
+ | ...`data` | `unknown`[] |
287
279
 
288
280
  ### Returns
289
281
 
@@ -300,14 +292,14 @@ Logger.debug
300
292
  ### error()
301
293
 
302
294
  ```ts
303
- error(...data): void;
295
+ error(...data: unknown[]): void;
304
296
  ```
305
297
 
306
298
  ### Parameters
307
299
 
308
- #### data
309
-
310
- ...`unknown`[]
300
+ | Parameter | Type |
301
+ | ------ | ------ |
302
+ | ...`data` | `unknown`[] |
311
303
 
312
304
  ### Returns
313
305
 
@@ -324,14 +316,14 @@ Logger.error
324
316
  ### info()
325
317
 
326
318
  ```ts
327
- info(...data): void;
319
+ info(...data: unknown[]): void;
328
320
  ```
329
321
 
330
322
  ### Parameters
331
323
 
332
- #### data
333
-
334
- ...`unknown`[]
324
+ | Parameter | Type |
325
+ | ------ | ------ |
326
+ | ...`data` | `unknown`[] |
335
327
 
336
328
  ### Returns
337
329
 
@@ -348,14 +340,14 @@ Logger.info
348
340
  ### log()
349
341
 
350
342
  ```ts
351
- log(...data): void;
343
+ log(...data: unknown[]): void;
352
344
  ```
353
345
 
354
346
  ### Parameters
355
347
 
356
- #### data
357
-
358
- ...`unknown`[]
348
+ | Parameter | Type |
349
+ | ------ | ------ |
350
+ | ...`data` | `unknown`[] |
359
351
 
360
352
  ### Returns
361
353
 
@@ -372,14 +364,14 @@ Logger.log
372
364
  ### trace()
373
365
 
374
366
  ```ts
375
- trace(...data): void;
367
+ trace(...data: unknown[]): void;
376
368
  ```
377
369
 
378
370
  ### Parameters
379
371
 
380
- #### data
381
-
382
- ...`unknown`[]
372
+ | Parameter | Type |
373
+ | ------ | ------ |
374
+ | ...`data` | `unknown`[] |
383
375
 
384
376
  ### Returns
385
377
 
@@ -396,14 +388,14 @@ Logger.trace
396
388
  ### warn()
397
389
 
398
390
  ```ts
399
- warn(...data): void;
391
+ warn(...data: unknown[]): void;
400
392
  ```
401
393
 
402
394
  ### Parameters
403
395
 
404
- #### data
405
-
406
- ...`unknown`[]
396
+ | Parameter | Type |
397
+ | ------ | ------ |
398
+ | ...`data` | `unknown`[] |
407
399
 
408
400
  ### Returns
409
401
 
@@ -437,18 +429,15 @@ Methods for levels above the configured threshold return a no-op function.
437
429
  ### Constructor
438
430
 
439
431
  ```ts
440
- new LevelLogger(logger, level?): LevelLogger;
432
+ new LevelLogger(logger: Logger, level?: LogLevelValue): LevelLogger;
441
433
  ```
442
434
 
443
435
  ### Parameters
444
436
 
445
- #### logger
446
-
447
- [`Logger`](#../interfaces/Logger)
448
-
449
- #### level?
450
-
451
- [`LogLevelValue`](#../type-aliases/LogLevelValue) = `LogLevel.warn`
437
+ | Parameter | Type | Default value |
438
+ | ------ | ------ | ------ |
439
+ | `logger` | [`Logger`](#../interfaces/Logger) | `undefined` |
440
+ | `level` | [`LogLevelValue`](#../type-aliases/LogLevelValue) | `LogLevel.warn` |
452
441
 
453
442
  ### Returns
454
443
 
@@ -456,19 +445,10 @@ new LevelLogger(logger, level?): LevelLogger;
456
445
 
457
446
  ## Properties
458
447
 
459
- ### level
460
-
461
- ```ts
462
- readonly level: LogLevelValue;
463
- ```
464
-
465
- ***
466
-
467
- ### logger
468
-
469
- ```ts
470
- readonly logger: Logger;
471
- ```
448
+ | Property | Modifier | Type |
449
+ | ------ | ------ | ------ |
450
+ | <a id="level"></a> `level` | `readonly` | [`LogLevelValue`](#../type-aliases/LogLevelValue) |
451
+ | <a id="logger"></a> `logger` | `readonly` | [`Logger`](#../interfaces/Logger) |
472
452
 
473
453
  ## Accessors
474
454
 
@@ -608,147 +588,14 @@ new SilentLogger(): SilentLogger;
608
588
 
609
589
  ## Properties
610
590
 
611
- ### debug()
612
-
613
- ```ts
614
- readonly debug: (..._data) => undefined = NoOpLogFunction;
615
- ```
616
-
617
- A log function that silently discards all arguments.
618
-
619
- ### Parameters
620
-
621
- #### \_data
622
-
623
- ...`unknown`[]
624
-
625
- ### Returns
626
-
627
- `undefined`
628
-
629
- ### Implementation of
630
-
631
- [`Logger`](#../interfaces/Logger).[`debug`](../interfaces/Logger.md#debug)
632
-
633
- ***
634
-
635
- ### error()
636
-
637
- ```ts
638
- readonly error: (..._data) => undefined = NoOpLogFunction;
639
- ```
640
-
641
- A log function that silently discards all arguments.
642
-
643
- ### Parameters
644
-
645
- #### \_data
646
-
647
- ...`unknown`[]
648
-
649
- ### Returns
650
-
651
- `undefined`
652
-
653
- ### Implementation of
654
-
655
- [`Logger`](#../interfaces/Logger).[`error`](../interfaces/Logger.md#error)
656
-
657
- ***
658
-
659
- ### info()
660
-
661
- ```ts
662
- readonly info: (..._data) => undefined = NoOpLogFunction;
663
- ```
664
-
665
- A log function that silently discards all arguments.
666
-
667
- ### Parameters
668
-
669
- #### \_data
670
-
671
- ...`unknown`[]
672
-
673
- ### Returns
674
-
675
- `undefined`
676
-
677
- ### Implementation of
678
-
679
- [`Logger`](#../interfaces/Logger).[`info`](../interfaces/Logger.md#info)
680
-
681
- ***
682
-
683
- ### log()
684
-
685
- ```ts
686
- readonly log: (..._data) => undefined = NoOpLogFunction;
687
- ```
688
-
689
- A log function that silently discards all arguments.
690
-
691
- ### Parameters
692
-
693
- #### \_data
694
-
695
- ...`unknown`[]
696
-
697
- ### Returns
698
-
699
- `undefined`
700
-
701
- ### Implementation of
702
-
703
- [`Logger`](#../interfaces/Logger).[`log`](../interfaces/Logger.md#log)
704
-
705
- ***
706
-
707
- ### trace()
708
-
709
- ```ts
710
- readonly trace: (..._data) => undefined = NoOpLogFunction;
711
- ```
712
-
713
- A log function that silently discards all arguments.
714
-
715
- ### Parameters
716
-
717
- #### \_data
718
-
719
- ...`unknown`[]
720
-
721
- ### Returns
722
-
723
- `undefined`
724
-
725
- ### Implementation of
726
-
727
- [`Logger`](#../interfaces/Logger).[`trace`](../interfaces/Logger.md#trace)
728
-
729
- ***
730
-
731
- ### warn()
732
-
733
- ```ts
734
- readonly warn: (..._data) => undefined = NoOpLogFunction;
735
- ```
736
-
737
- A log function that silently discards all arguments.
738
-
739
- ### Parameters
740
-
741
- #### \_data
742
-
743
- ...`unknown`[]
744
-
745
- ### Returns
746
-
747
- `undefined`
748
-
749
- ### Implementation of
750
-
751
- [`Logger`](#../interfaces/Logger).[`warn`](../interfaces/Logger.md#warn)
591
+ | Property | Modifier | Type | Default value |
592
+ | ------ | ------ | ------ | ------ |
593
+ | <a id="debug"></a> `debug` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` |
594
+ | <a id="error"></a> `error` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` |
595
+ | <a id="info"></a> `info` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` |
596
+ | <a id="log"></a> `log` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` |
597
+ | <a id="trace"></a> `trace` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` |
598
+ | <a id="warn"></a> `warn` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` |
752
599
 
753
600
  ### functions
754
601
 
@@ -759,16 +606,16 @@ A log function that silently discards all arguments.
759
606
  ***
760
607
 
761
608
  ```ts
762
- function NoOpLogFunction(..._data): undefined;
609
+ function NoOpLogFunction(..._data: unknown[]): undefined;
763
610
  ```
764
611
 
765
612
  A log function that silently discards all arguments.
766
613
 
767
614
  ## Parameters
768
615
 
769
- ### \_data
770
-
771
- ...`unknown`[]
616
+ | Parameter | Type |
617
+ | ------ | ------ |
618
+ | ...`_data` | `unknown`[] |
772
619
 
773
620
  ## Returns
774
621
 
@@ -781,18 +628,16 @@ A log function that silently discards all arguments.
781
628
  ***
782
629
 
783
630
  ```ts
784
- function getFunctionName(depth?): string;
631
+ function getFunctionName(depth?: number): string;
785
632
  ```
786
633
 
787
634
  Retrieves the name of the calling function by inspecting the stack trace.
788
635
 
789
636
  ## Parameters
790
637
 
791
- ### depth?
792
-
793
- `number` = `2`
794
-
795
- The stack frame depth to inspect (default: 2, the caller's caller).
638
+ | Parameter | Type | Default value | Description |
639
+ | ------ | ------ | ------ | ------ |
640
+ | `depth` | `number` | `2` | The stack frame depth to inspect (default: 2, the caller's caller). |
796
641
 
797
642
  ## Returns
798
643
 
@@ -813,51 +658,14 @@ Interface to handle overlap between Winston &
813
658
 
814
659
  ## Properties
815
660
 
816
- ### debug
817
-
818
- ```ts
819
- debug: LogFunction;
820
- ```
821
-
822
- ***
823
-
824
- ### error
825
-
826
- ```ts
827
- error: LogFunction;
828
- ```
829
-
830
- ***
831
-
832
- ### info
833
-
834
- ```ts
835
- info: LogFunction;
836
- ```
837
-
838
- ***
839
-
840
- ### log
841
-
842
- ```ts
843
- log: LogFunction;
844
- ```
845
-
846
- ***
847
-
848
- ### trace
849
-
850
- ```ts
851
- trace: LogFunction;
852
- ```
853
-
854
- ***
855
-
856
- ### warn
857
-
858
- ```ts
859
- warn: LogFunction;
860
- ```
661
+ | Property | Type |
662
+ | ------ | ------ |
663
+ | <a id="debug"></a> `debug` | [`LogFunction`](#../type-aliases/LogFunction) |
664
+ | <a id="error"></a> `error` | [`LogFunction`](#../type-aliases/LogFunction) |
665
+ | <a id="info"></a> `info` | [`LogFunction`](#../type-aliases/LogFunction) |
666
+ | <a id="log"></a> `log` | [`LogFunction`](#../type-aliases/LogFunction) |
667
+ | <a id="trace"></a> `trace` | [`LogFunction`](#../type-aliases/LogFunction) |
668
+ | <a id="warn"></a> `warn` | [`LogFunction`](#../type-aliases/LogFunction) |
861
669
 
862
670
  ### type-aliases
863
671
 
@@ -868,16 +676,16 @@ warn: LogFunction;
868
676
  ***
869
677
 
870
678
  ```ts
871
- type LogFunction = (...data) => void;
679
+ type LogFunction = (...data: unknown[]) => void;
872
680
  ```
873
681
 
874
682
  A generic logging function that accepts any number of arguments.
875
683
 
876
684
  ## Parameters
877
685
 
878
- ### data
879
-
880
- ...`unknown`[]
686
+ | Parameter | Type |
687
+ | ------ | ------ |
688
+ | ...`data` | `unknown`[] |
881
689
 
882
690
  ## Returns
883
691
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/logger",
3
- "version": "5.0.84",
3
+ "version": "5.0.86",
4
4
  "description": "XYLabs Logger Library",
5
5
  "keywords": [
6
6
  "logger",
@@ -42,14 +42,14 @@
42
42
  "!**/*.test.*"
43
43
  ],
44
44
  "dependencies": {
45
- "@xylabs/enum": "~5.0.84",
46
- "@xylabs/error": "~5.0.84",
47
- "@xylabs/typeof": "~5.0.84"
45
+ "@xylabs/enum": "~5.0.86",
46
+ "@xylabs/error": "~5.0.86",
47
+ "@xylabs/typeof": "~5.0.86"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/node": "~25.4.0",
51
- "@xylabs/ts-scripts-yarn3": "~7.4.13",
52
- "@xylabs/tsconfig": "~7.4.13",
51
+ "@xylabs/ts-scripts-yarn3": "~7.4.16",
52
+ "@xylabs/tsconfig": "~7.4.16",
53
53
  "typescript": "~5.9.3",
54
54
  "vitest": "~4.0.18"
55
55
  },