standard-log 13.0.0 → 13.0.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.
Files changed (132) hide show
  1. package/cjs/_virtual/_rolldown/runtime.js +23 -0
  2. package/cjs/console.d.ts +10 -7
  3. package/cjs/console.d.ts.map +1 -1
  4. package/cjs/console.js +54 -69
  5. package/cjs/console.js.map +1 -1
  6. package/cjs/errors.d.ts +9 -6
  7. package/cjs/errors.d.ts.map +1 -1
  8. package/cjs/errors.js +22 -45
  9. package/cjs/errors.js.map +1 -1
  10. package/cjs/formatter.d.ts +9 -6
  11. package/cjs/formatter.d.ts.map +1 -1
  12. package/cjs/formatter.js +42 -49
  13. package/cjs/formatter.js.map +1 -1
  14. package/cjs/index.d.ts +8 -9
  15. package/cjs/index.js +26 -28
  16. package/cjs/log_levels.d.ts +76 -73
  17. package/cjs/log_levels.d.ts.map +1 -1
  18. package/cjs/log_levels.js +104 -110
  19. package/cjs/log_levels.js.map +1 -1
  20. package/cjs/log_store.d.ts +20 -17
  21. package/cjs/log_store.d.ts.map +1 -1
  22. package/cjs/log_store.js +44 -39
  23. package/cjs/log_store.js.map +1 -1
  24. package/cjs/logger.d.ts +6 -3
  25. package/cjs/logger.d.ts.map +1 -1
  26. package/cjs/logger.js +66 -87
  27. package/cjs/logger.js.map +1 -1
  28. package/cjs/memory.d.ts +20 -17
  29. package/cjs/memory.d.ts.map +1 -1
  30. package/cjs/memory.js +55 -62
  31. package/cjs/memory.js.map +1 -1
  32. package/cjs/platform.browser.d.ts +7 -4
  33. package/cjs/platform.browser.d.ts.map +1 -1
  34. package/cjs/platform.browser.js +8 -6
  35. package/cjs/platform.browser.js.map +1 -1
  36. package/cjs/platform.d.ts +7 -4
  37. package/cjs/platform.d.ts.map +1 -1
  38. package/cjs/platform.js +9 -7
  39. package/cjs/platform.js.map +1 -1
  40. package/cjs/standard_log.ctx.d.ts +11 -8
  41. package/cjs/standard_log.ctx.d.ts.map +1 -1
  42. package/cjs/standard_log.ctx.js +6 -5
  43. package/cjs/standard_log.ctx.js.map +1 -1
  44. package/cjs/standard_log.d.ts +14 -12
  45. package/cjs/standard_log.d.ts.map +1 -1
  46. package/cjs/standard_log.js +84 -112
  47. package/cjs/standard_log.js.map +1 -1
  48. package/cjs/standard_log.testing.d.ts +16 -13
  49. package/cjs/standard_log.testing.d.ts.map +1 -1
  50. package/cjs/standard_log.testing.js +20 -35
  51. package/cjs/standard_log.testing.js.map +1 -1
  52. package/cjs/testing/index.d.ts +3 -3
  53. package/cjs/testing/index.js +3 -6
  54. package/cjs/types.d.ts +125 -124
  55. package/cjs/types.d.ts.map +1 -1
  56. package/cjs/types.js +0 -3
  57. package/dist/standard-log.esm.js +874 -1401
  58. package/dist/standard-log.esm.js.map +1 -1
  59. package/dist/standard-log.iife.js +952 -0
  60. package/dist/standard-log.iife.js.map +1 -0
  61. package/esm/console.d.ts +10 -7
  62. package/esm/console.d.ts.map +1 -1
  63. package/esm/console.js +54 -62
  64. package/esm/console.js.map +1 -1
  65. package/esm/errors.d.ts +9 -6
  66. package/esm/errors.d.ts.map +1 -1
  67. package/esm/errors.js +21 -21
  68. package/esm/errors.js.map +1 -1
  69. package/esm/formatter.d.ts +9 -6
  70. package/esm/formatter.d.ts.map +1 -1
  71. package/esm/formatter.js +38 -31
  72. package/esm/formatter.js.map +1 -1
  73. package/esm/index.d.ts +8 -9
  74. package/esm/index.js +7 -7
  75. package/esm/log_levels.d.ts +76 -73
  76. package/esm/log_levels.d.ts.map +1 -1
  77. package/esm/log_levels.js +102 -107
  78. package/esm/log_levels.js.map +1 -1
  79. package/esm/log_store.d.ts +20 -17
  80. package/esm/log_store.d.ts.map +1 -1
  81. package/esm/log_store.js +44 -37
  82. package/esm/log_store.js.map +1 -1
  83. package/esm/logger.d.ts +6 -3
  84. package/esm/logger.d.ts.map +1 -1
  85. package/esm/logger.js +66 -65
  86. package/esm/logger.js.map +1 -1
  87. package/esm/memory.d.ts +20 -17
  88. package/esm/memory.d.ts.map +1 -1
  89. package/esm/memory.js +55 -60
  90. package/esm/memory.js.map +1 -1
  91. package/esm/platform.browser.d.ts +7 -4
  92. package/esm/platform.browser.d.ts.map +1 -1
  93. package/esm/platform.browser.js +7 -3
  94. package/esm/platform.browser.js.map +1 -1
  95. package/esm/platform.d.ts +7 -4
  96. package/esm/platform.d.ts.map +1 -1
  97. package/esm/platform.js +8 -4
  98. package/esm/platform.js.map +1 -1
  99. package/esm/standard_log.ctx.d.ts +11 -8
  100. package/esm/standard_log.ctx.d.ts.map +1 -1
  101. package/esm/standard_log.ctx.js +6 -2
  102. package/esm/standard_log.ctx.js.map +1 -1
  103. package/esm/standard_log.d.ts +14 -12
  104. package/esm/standard_log.d.ts.map +1 -1
  105. package/esm/standard_log.js +83 -98
  106. package/esm/standard_log.js.map +1 -1
  107. package/esm/standard_log.testing.d.ts +16 -13
  108. package/esm/standard_log.testing.d.ts.map +1 -1
  109. package/esm/standard_log.testing.js +19 -20
  110. package/esm/standard_log.testing.js.map +1 -1
  111. package/esm/testing/index.d.ts +3 -3
  112. package/esm/testing/index.js +2 -2
  113. package/esm/types.d.ts +125 -124
  114. package/esm/types.d.ts.map +1 -1
  115. package/esm/types.js +0 -1
  116. package/package.json +8 -42
  117. package/cjs/index.d.ts.map +0 -1
  118. package/cjs/index.js.map +0 -1
  119. package/cjs/testing/index.d.ts.map +0 -1
  120. package/cjs/testing/index.js.map +0 -1
  121. package/cjs/types.js.map +0 -1
  122. package/dist/standard-log.es5.js +0 -10628
  123. package/dist/standard-log.es5.js.gz +0 -0
  124. package/dist/standard-log.es5.js.map +0 -1
  125. package/dist/standard-log.es5.js.map.gz +0 -0
  126. package/dist/standard-log.esm.js.gz +0 -0
  127. package/dist/standard-log.esm.js.map.gz +0 -0
  128. package/esm/index.d.ts.map +0 -1
  129. package/esm/index.js.map +0 -1
  130. package/esm/testing/index.d.ts.map +0 -1
  131. package/esm/testing/index.js.map +0 -1
  132. package/esm/types.js.map +0 -1
@@ -1,81 +1,84 @@
1
- export declare const logLevels: {
2
- /**
3
- * none: 0
4
- */
5
- none: 0;
6
- /**
7
- * emergency: 100
8
- *
9
- * emergency -> alert
10
- */
11
- emergency: 100;
12
- /**
13
- * alert: 200
14
- *
15
- * emergency -> alert -> critical
16
- */
17
- alert: 200;
18
- /**
19
- * critical: 300
20
- *
21
- * alert -> critical -> error
22
- */
23
- critical: 300;
24
- /**
25
- * error: 400
26
- *
27
- * critical -> error -> warn
28
- */
29
- error: 400;
30
- /**
31
- * warn: 500
32
- *
33
- * error -> warn -> notice
34
- */
35
- warn: 500;
36
- /**
37
- * notice: 600
38
- *
39
- * warn -> notice -> info
40
- */
41
- notice: 600;
42
- /**
43
- * info: 700
44
- *
45
- * notice -> info -> debug
46
- */
47
- info: 700;
48
- /**
49
- * debug: 800
50
- *
51
- * info -> debug -> trace
52
- */
53
- debug: 800;
54
- /**
55
- * trace: 900
56
- *
57
- * debug -> trace -> planck
58
- */
59
- trace: 900;
60
- /**
61
- * planck: Infinity
62
- * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
63
- *
64
- * trace -> planck
65
- */
66
- planck: number;
67
- /**
68
- * all: Infinity
69
- */
70
- all: number;
1
+ //#region ts/log_levels.d.ts
2
+ declare const logLevels: {
3
+ /**
4
+ * none: 0
5
+ */
6
+ none: 0;
7
+ /**
8
+ * emergency: 100
9
+ *
10
+ * emergency -> alert
11
+ */
12
+ emergency: 100;
13
+ /**
14
+ * alert: 200
15
+ *
16
+ * emergency -> alert -> critical
17
+ */
18
+ alert: 200;
19
+ /**
20
+ * critical: 300
21
+ *
22
+ * alert -> critical -> error
23
+ */
24
+ critical: 300;
25
+ /**
26
+ * error: 400
27
+ *
28
+ * critical -> error -> warn
29
+ */
30
+ error: 400;
31
+ /**
32
+ * warn: 500
33
+ *
34
+ * error -> warn -> notice
35
+ */
36
+ warn: 500;
37
+ /**
38
+ * notice: 600
39
+ *
40
+ * warn -> notice -> info
41
+ */
42
+ notice: 600;
43
+ /**
44
+ * info: 700
45
+ *
46
+ * notice -> info -> debug
47
+ */
48
+ info: 700;
49
+ /**
50
+ * debug: 800
51
+ *
52
+ * info -> debug -> trace
53
+ */
54
+ debug: 800;
55
+ /**
56
+ * trace: 900
57
+ *
58
+ * debug -> trace -> planck
59
+ */
60
+ trace: 900;
61
+ /**
62
+ * planck: Infinity
63
+ * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
64
+ *
65
+ * trace -> planck
66
+ */
67
+ planck: number;
68
+ /**
69
+ * all: Infinity
70
+ */
71
+ all: number;
71
72
  };
72
73
  /**
73
74
  * Convert default log level value to log level name.
74
75
  */
75
- export declare function toLogLevelName(level: number): "emergency" | "alert" | "critical" | "error" | "warn" | "notice" | "info" | "debug" | "trace" | "planck";
76
+ declare function toLogLevelName(level: number): "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "planck" | "trace" | "warn";
76
77
  /**
77
78
  * Convert default log level name to log level value.
78
79
  */
79
- export declare function toLogLevel(name: string): number | undefined;
80
- export declare const DEFAULT_LOG_METHOD_NAMES: string[];
80
+ declare function toLogLevel(name: string): number | undefined;
81
+ declare const DEFAULT_LOG_METHOD_NAMES: string[];
82
+ //#endregion
83
+ export { DEFAULT_LOG_METHOD_NAMES, logLevels, toLogLevel, toLogLevelName };
81
84
  //# sourceMappingURL=log_levels.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"log_levels.d.ts","sourceRoot":"","sources":["../ts/log_levels.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACrB;;OAEG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;OAEG;;CAEH,CAAA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,4GAW3C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE3D;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAM,EAW5C,CAAA"}
1
+ {"version":3,"file":"log_levels.d.ts","names":[],"sources":["../ts/log_levels.ts"],"mappings":";cAAa;;;;EAIZ;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;;EAOA;;;;EAIA;;;;;iBAMe,eAAe;;;;iBAgBf,WAAW;cAId"}
package/esm/log_levels.js CHANGED
@@ -1,114 +1,109 @@
1
- export const logLevels = {
2
- /**
3
- * none: 0
4
- */
5
- none: 0,
6
- /**
7
- * emergency: 100
8
- *
9
- * emergency -> alert
10
- */
11
- emergency: 100,
12
- /**
13
- * alert: 200
14
- *
15
- * emergency -> alert -> critical
16
- */
17
- alert: 200,
18
- /**
19
- * critical: 300
20
- *
21
- * alert -> critical -> error
22
- */
23
- critical: 300,
24
- /**
25
- * error: 400
26
- *
27
- * critical -> error -> warn
28
- */
29
- error: 400,
30
- /**
31
- * warn: 500
32
- *
33
- * error -> warn -> notice
34
- */
35
- warn: 500,
36
- /**
37
- * notice: 600
38
- *
39
- * warn -> notice -> info
40
- */
41
- notice: 600,
42
- /**
43
- * info: 700
44
- *
45
- * notice -> info -> debug
46
- */
47
- info: 700,
48
- /**
49
- * debug: 800
50
- *
51
- * info -> debug -> trace
52
- */
53
- debug: 800,
54
- /**
55
- * trace: 900
56
- *
57
- * debug -> trace -> planck
58
- */
59
- trace: 900,
60
- /**
61
- * planck: Infinity
62
- * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
63
- *
64
- * trace -> planck
65
- */
66
- planck: Number.POSITIVE_INFINITY,
67
- /**
68
- * all: Infinity
69
- */
70
- all: Number.POSITIVE_INFINITY
1
+ //#region ts/log_levels.ts
2
+ const logLevels = {
3
+ /**
4
+ * none: 0
5
+ */
6
+ none: 0,
7
+ /**
8
+ * emergency: 100
9
+ *
10
+ * emergency -> alert
11
+ */
12
+ emergency: 100,
13
+ /**
14
+ * alert: 200
15
+ *
16
+ * emergency -> alert -> critical
17
+ */
18
+ alert: 200,
19
+ /**
20
+ * critical: 300
21
+ *
22
+ * alert -> critical -> error
23
+ */
24
+ critical: 300,
25
+ /**
26
+ * error: 400
27
+ *
28
+ * critical -> error -> warn
29
+ */
30
+ error: 400,
31
+ /**
32
+ * warn: 500
33
+ *
34
+ * error -> warn -> notice
35
+ */
36
+ warn: 500,
37
+ /**
38
+ * notice: 600
39
+ *
40
+ * warn -> notice -> info
41
+ */
42
+ notice: 600,
43
+ /**
44
+ * info: 700
45
+ *
46
+ * notice -> info -> debug
47
+ */
48
+ info: 700,
49
+ /**
50
+ * debug: 800
51
+ *
52
+ * info -> debug -> trace
53
+ */
54
+ debug: 800,
55
+ /**
56
+ * trace: 900
57
+ *
58
+ * debug -> trace -> planck
59
+ */
60
+ trace: 900,
61
+ /**
62
+ * planck: Infinity
63
+ * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
64
+ *
65
+ * trace -> planck
66
+ */
67
+ planck: Number.POSITIVE_INFINITY,
68
+ /**
69
+ * all: Infinity
70
+ */
71
+ all: Number.POSITIVE_INFINITY
71
72
  };
72
73
  /**
73
- * Convert default log level value to log level name.
74
- */
75
- export function toLogLevelName(level) {
76
- if (level <= 100)
77
- return 'emergency';
78
- if (level <= 200)
79
- return 'alert';
80
- if (level <= 300)
81
- return 'critical';
82
- if (level <= 400)
83
- return 'error';
84
- if (level <= 500)
85
- return 'warn';
86
- if (level <= 600)
87
- return 'notice';
88
- if (level <= 700)
89
- return 'info';
90
- if (level <= 800)
91
- return 'debug';
92
- if (level <= 900)
93
- return 'trace';
94
- return 'planck';
74
+ * Convert default log level value to log level name.
75
+ */
76
+ function toLogLevelName(level) {
77
+ if (level <= 100) return "emergency";
78
+ if (level <= 200) return "alert";
79
+ if (level <= 300) return "critical";
80
+ if (level <= 400) return "error";
81
+ if (level <= 500) return "warn";
82
+ if (level <= 600) return "notice";
83
+ if (level <= 700) return "info";
84
+ if (level <= 800) return "debug";
85
+ if (level <= 900) return "trace";
86
+ return "planck";
95
87
  }
96
88
  /**
97
- * Convert default log level name to log level value.
98
- */
99
- export function toLogLevel(name) {
100
- return logLevels[name.toLocaleLowerCase()];
89
+ * Convert default log level name to log level value.
90
+ */
91
+ function toLogLevel(name) {
92
+ return logLevels[name.toLocaleLowerCase()];
101
93
  }
102
- export const DEFAULT_LOG_METHOD_NAMES = [
103
- 'emergency',
104
- 'alert',
105
- 'critical',
106
- 'error',
107
- 'warn',
108
- 'notice',
109
- 'info',
110
- 'debug',
111
- 'trace',
112
- 'planck'
94
+ const DEFAULT_LOG_METHOD_NAMES = [
95
+ "emergency",
96
+ "alert",
97
+ "critical",
98
+ "error",
99
+ "warn",
100
+ "notice",
101
+ "info",
102
+ "debug",
103
+ "trace",
104
+ "planck"
113
105
  ];
106
+ //#endregion
107
+ export { DEFAULT_LOG_METHOD_NAMES, logLevels, toLogLevel, toLogLevelName };
108
+
114
109
  //# sourceMappingURL=log_levels.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"log_levels.js","sourceRoot":"","sources":["../ts/log_levels.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,CAAU;IAChB;;;;OAIG;IACH,SAAS,EAAE,GAAY;IACvB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,QAAQ,EAAE,GAAY;IACtB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,IAAI,EAAE,GAAY;IAClB;;;;OAIG;IACH,MAAM,EAAE,GAAY;IACpB;;;;OAIG;IACH,IAAI,EAAE,GAAY;IAClB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC,iBAAiB;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC,iBAAiB;CAC7B,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC3C,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,WAAW,CAAA;IACpC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,UAAU,CAAA;IACnC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,QAAQ,CAAA;IACjC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,OAAO,QAAQ,CAAA;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACtC,OAAQ,SAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;AACpD,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAa;IACjD,WAAW;IACX,OAAO;IACP,UAAU;IACV,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;CACR,CAAA","sourcesContent":["export const logLevels = {\n\t/**\n\t * none: 0\n\t */\n\tnone: 0 as const,\n\t/**\n\t * emergency: 100\n\t *\n\t * emergency -> alert\n\t */\n\temergency: 100 as const,\n\t/**\n\t * alert: 200\n\t *\n\t * emergency -> alert -> critical\n\t */\n\talert: 200 as const,\n\t/**\n\t * critical: 300\n\t *\n\t * alert -> critical -> error\n\t */\n\tcritical: 300 as const,\n\t/**\n\t * error: 400\n\t *\n\t * critical -> error -> warn\n\t */\n\terror: 400 as const,\n\t/**\n\t * warn: 500\n\t *\n\t * error -> warn -> notice\n\t */\n\twarn: 500 as const,\n\t/**\n\t * notice: 600\n\t *\n\t * warn -> notice -> info\n\t */\n\tnotice: 600 as const,\n\t/**\n\t * info: 700\n\t *\n\t * notice -> info -> debug\n\t */\n\tinfo: 700 as const,\n\t/**\n\t * debug: 800\n\t *\n\t * info -> debug -> trace\n\t */\n\tdebug: 800 as const,\n\t/**\n\t * trace: 900\n\t *\n\t * debug -> trace -> planck\n\t */\n\ttrace: 900 as const,\n\t/**\n\t * planck: Infinity\n\t * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.\n\t *\n\t * trace -> planck\n\t */\n\tplanck: Number.POSITIVE_INFINITY,\n\t/**\n\t * all: Infinity\n\t */\n\tall: Number.POSITIVE_INFINITY\n}\n\n/**\n * Convert default log level value to log level name.\n */\nexport function toLogLevelName(level: number) {\n\tif (level <= 100) return 'emergency'\n\tif (level <= 200) return 'alert'\n\tif (level <= 300) return 'critical'\n\tif (level <= 400) return 'error'\n\tif (level <= 500) return 'warn'\n\tif (level <= 600) return 'notice'\n\tif (level <= 700) return 'info'\n\tif (level <= 800) return 'debug'\n\tif (level <= 900) return 'trace'\n\treturn 'planck'\n}\n\n/**\n * Convert default log level name to log level value.\n */\nexport function toLogLevel(name: string): number | undefined {\n\treturn (logLevels as any)[name.toLocaleLowerCase()]\n}\n\nexport const DEFAULT_LOG_METHOD_NAMES: string[] = [\n\t'emergency',\n\t'alert',\n\t'critical',\n\t'error',\n\t'warn',\n\t'notice',\n\t'info',\n\t'debug',\n\t'trace',\n\t'planck'\n]\n"]}
1
+ {"version":3,"file":"log_levels.js","names":[],"sources":["../ts/log_levels.ts"],"sourcesContent":["export const logLevels = {\n\t/**\n\t * none: 0\n\t */\n\tnone: 0 as const,\n\t/**\n\t * emergency: 100\n\t *\n\t * emergency -> alert\n\t */\n\temergency: 100 as const,\n\t/**\n\t * alert: 200\n\t *\n\t * emergency -> alert -> critical\n\t */\n\talert: 200 as const,\n\t/**\n\t * critical: 300\n\t *\n\t * alert -> critical -> error\n\t */\n\tcritical: 300 as const,\n\t/**\n\t * error: 400\n\t *\n\t * critical -> error -> warn\n\t */\n\terror: 400 as const,\n\t/**\n\t * warn: 500\n\t *\n\t * error -> warn -> notice\n\t */\n\twarn: 500 as const,\n\t/**\n\t * notice: 600\n\t *\n\t * warn -> notice -> info\n\t */\n\tnotice: 600 as const,\n\t/**\n\t * info: 700\n\t *\n\t * notice -> info -> debug\n\t */\n\tinfo: 700 as const,\n\t/**\n\t * debug: 800\n\t *\n\t * info -> debug -> trace\n\t */\n\tdebug: 800 as const,\n\t/**\n\t * trace: 900\n\t *\n\t * debug -> trace -> planck\n\t */\n\ttrace: 900 as const,\n\t/**\n\t * planck: Infinity\n\t * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.\n\t *\n\t * trace -> planck\n\t */\n\tplanck: Number.POSITIVE_INFINITY,\n\t/**\n\t * all: Infinity\n\t */\n\tall: Number.POSITIVE_INFINITY\n}\n\n/**\n * Convert default log level value to log level name.\n */\nexport function toLogLevelName(level: number) {\n\tif (level <= 100) return 'emergency'\n\tif (level <= 200) return 'alert'\n\tif (level <= 300) return 'critical'\n\tif (level <= 400) return 'error'\n\tif (level <= 500) return 'warn'\n\tif (level <= 600) return 'notice'\n\tif (level <= 700) return 'info'\n\tif (level <= 800) return 'debug'\n\tif (level <= 900) return 'trace'\n\treturn 'planck'\n}\n\n/**\n * Convert default log level name to log level value.\n */\nexport function toLogLevel(name: string): number | undefined {\n\treturn (logLevels as any)[name.toLocaleLowerCase()]\n}\n\nexport const DEFAULT_LOG_METHOD_NAMES: string[] = [\n\t'emergency',\n\t'alert',\n\t'critical',\n\t'error',\n\t'warn',\n\t'notice',\n\t'info',\n\t'debug',\n\t'trace',\n\t'planck'\n]\n"],"mappings":";AAAA,MAAa,YAAY;;;;CAIxB,MAAM;;;;;;CAMN,WAAW;;;;;;CAMX,OAAO;;;;;;CAMP,UAAU;;;;;;CAMV,OAAO;;;;;;CAMP,MAAM;;;;;;CAMN,QAAQ;;;;;;CAMR,MAAM;;;;;;CAMN,OAAO;;;;;;CAMP,OAAO;;;;;;;CAOP,QAAQ,OAAO;;;;CAIf,KAAK,OAAO;AACb;;;;AAKA,SAAgB,eAAe,OAAe;CAC7C,IAAI,SAAS,KAAK,OAAO;CACzB,IAAI,SAAS,KAAK,OAAO;CACzB,IAAI,SAAS,KAAK,OAAO;CACzB,IAAI,SAAS,KAAK,OAAO;CACzB,IAAI,SAAS,KAAK,OAAO;CACzB,IAAI,SAAS,KAAK,OAAO;CACzB,IAAI,SAAS,KAAK,OAAO;CACzB,IAAI,SAAS,KAAK,OAAO;CACzB,IAAI,SAAS,KAAK,OAAO;CACzB,OAAO;AACR;;;;AAKA,SAAgB,WAAW,MAAkC;CAC5D,OAAQ,UAAkB,KAAK,kBAAkB;AAClD;AAEA,MAAa,2BAAqC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD"}
@@ -1,21 +1,24 @@
1
- import type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js';
2
- export declare function createLogStore<N extends string = LogMethodNames>(options: Required<StandardLogOptions<N>>): LogStore;
3
- export interface LogStore {
4
- loggers: Record<string, Logger>;
5
- nonConsoleLoggers: Record<string, Logger>;
6
- reporters: LogReporter[];
7
- logLevel: LogLevel;
8
- logLevelStore: ReturnType<typeof logLevelStore>;
1
+ import { LogLevel, LogMethodNames, LogReporter, Logger, StandardLogOptions } from "./types.js";
2
+ //#region ts/log_store.d.ts
3
+ declare function createLogStore<N extends string = LogMethodNames>(options: Required<StandardLogOptions<N>>): LogStore;
4
+ interface LogStore {
5
+ loggers: Record<string, Logger>;
6
+ nonConsoleLoggers: Record<string, Logger>;
7
+ reporters: LogReporter[];
8
+ logLevel: LogLevel;
9
+ logLevelStore: ReturnType<typeof logLevelStore>;
9
10
  }
10
- export interface LogLevelStoreOptions {
11
- customLevels?: Record<string, number>;
11
+ interface LogLevelStoreOptions {
12
+ customLevels?: Record<string, number>;
12
13
  }
13
- export declare function logLevelStore(options: LogLevelStoreOptions): {
14
- getName(level: number): string;
15
- getLevel(name: string): number;
16
- getAllLevels(): {
17
- name: string;
18
- level: number;
19
- }[];
14
+ declare function logLevelStore(options: LogLevelStoreOptions): {
15
+ getName(level: number): string;
16
+ getLevel(name: string): number;
17
+ getAllLevels(): {
18
+ name: string;
19
+ level: number;
20
+ }[];
20
21
  };
22
+ //#endregion
23
+ export { LogLevelStoreOptions, LogStore, createLogStore, logLevelStore };
21
24
  //# sourceMappingURL=log_store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"log_store.d.ts","sourceRoot":"","sources":["../ts/log_store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEnG,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAC/D,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GACtC,QAAQ,CAQV;AAED,MAAM,WAAW,QAAQ;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;CAC/C;AAED,MAAM,WAAW,oBAAoB;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;mBAe1C,MAAM;mBAGN,MAAM;;;;;EAetB"}
1
+ {"version":3,"file":"log_store.d.ts","names":[],"sources":["../ts/log_store.ts"],"mappings":";;iBAKgB,eAAe,mBAAmB,gBACjD,SAAS,SAAS,mBAAmB,MACnC;UAUc;EAChB,SAAS,eAAe;EACxB,mBAAmB,eAAe;EAClC,WAAW;EACX,UAAU;EACV,eAAe,kBAAkB;;UAGjB;EAChB,eAAe;;iBAGA,cAAc,SAAS;EAerC,QAAO;EAGP,SAAQ;EAGR"}
package/esm/log_store.js CHANGED
@@ -1,40 +1,47 @@
1
- import { mapKey, record, reduceByKey, reduceKey } from 'type-plus';
2
- import { createConsoleLogReporter } from './console.js';
3
- import { logLevels, toLogLevel, toLogLevelName } from './log_levels.js';
4
- export function createLogStore(options) {
5
- return {
6
- loggers: record(),
7
- nonConsoleLoggers: record(),
8
- reporters: options.reporters || [createConsoleLogReporter()],
9
- logLevel: options.logLevel,
10
- logLevelStore: logLevelStore(options)
11
- };
1
+ import { logLevels, toLogLevel, toLogLevelName } from "./log_levels.js";
2
+ import { createConsoleLogReporter } from "./console.js";
3
+ import { mapKey, record, reduceByKey, reduceKey } from "type-plus";
4
+ //#region ts/log_store.ts
5
+ function createLogStore(options) {
6
+ return {
7
+ loggers: record(),
8
+ nonConsoleLoggers: record(),
9
+ reporters: options.reporters || [createConsoleLogReporter()],
10
+ logLevel: options.logLevel,
11
+ logLevelStore: logLevelStore(options)
12
+ };
12
13
  }
13
- export function logLevelStore(options) {
14
- const customLevels = options.customLevels || record();
15
- const store = {
16
- customLevels,
17
- customLevelsReverse: reduceByKey(customLevels, (p, k) => {
18
- p[customLevels[k]] = k;
19
- return p;
20
- }, {})
21
- };
22
- return {
23
- getName(level) {
24
- var _a;
25
- return (_a = store.customLevelsReverse[level]) !== null && _a !== void 0 ? _a : toLogLevelName(level);
26
- },
27
- getLevel(name) {
28
- var _a;
29
- return (_a = store.customLevels[name]) !== null && _a !== void 0 ? _a : toLogLevel(name);
30
- },
31
- getAllLevels() {
32
- return reduceKey(logLevels, (result, name) => {
33
- if (name !== 'none' && name !== 'all')
34
- result.push({ name, level: logLevels[name] });
35
- return result;
36
- }, mapKey(store.customLevels, name => ({ name, level: store.customLevels[name] })));
37
- }
38
- };
14
+ function logLevelStore(options) {
15
+ const customLevels = options.customLevels || record();
16
+ const store = {
17
+ customLevels,
18
+ customLevelsReverse: reduceByKey(customLevels, (p, k) => {
19
+ p[customLevels[k]] = k;
20
+ return p;
21
+ }, {})
22
+ };
23
+ return {
24
+ getName(level) {
25
+ return store.customLevelsReverse[level] ?? toLogLevelName(level);
26
+ },
27
+ getLevel(name) {
28
+ return store.customLevels[name] ?? toLogLevel(name);
29
+ },
30
+ getAllLevels() {
31
+ return reduceKey(logLevels, (result, name) => {
32
+ if (name !== "none" && name !== "all") result.push({
33
+ name,
34
+ level: logLevels[name]
35
+ });
36
+ return result;
37
+ }, mapKey(store.customLevels, (name) => ({
38
+ name,
39
+ level: store.customLevels[name]
40
+ })));
41
+ }
42
+ };
39
43
  }
44
+ //#endregion
45
+ export { createLogStore, logLevelStore };
46
+
40
47
  //# sourceMappingURL=log_store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"log_store.js","sourceRoot":"","sources":["../ts/log_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGvE,MAAM,UAAU,cAAc,CAC7B,OAAwC;IAExC,OAAO;QACN,OAAO,EAAE,MAAM,EAAE;QACjB,iBAAiB,EAAE,MAAM,EAAE;QAC3B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC;KACrC,CAAA;AACF,CAAC;AAcD,MAAM,UAAU,aAAa,CAAC,OAA6B;IAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,MAAM,EAAE,CAAA;IAErD,MAAM,KAAK,GAAG;QACb,YAAY;QACZ,mBAAmB,EAAE,WAAW,CAC/B,YAAY,EACZ,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACR,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YACtB,OAAO,CAAC,CAAA;QACT,CAAC,EACD,EAA4B,CAC5B;KACD,CAAA;IACD,OAAO;QACN,OAAO,CAAC,KAAa;;YACpB,OAAO,MAAA,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,mCAAI,cAAc,CAAC,KAAK,CAAC,CAAA;QACjE,CAAC;QACD,QAAQ,CAAC,IAAY;;YACpB,OAAO,MAAA,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,mCAAI,UAAU,CAAC,IAAI,CAAC,CAAA;QACpD,CAAC;QACD,YAAY;YACX,OAAO,SAAS,CACf,SAAS,EACT,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;gBAChB,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK;oBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAEpF,OAAO,MAAM,CAAA;YACd,CAAC,EACD,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAC/E,CAAA;QACF,CAAC;KACD,CAAA;AACF,CAAC","sourcesContent":["import { mapKey, record, reduceByKey, reduceKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(\n\toptions: Required<StandardLogOptions<N>>\n): LogStore {\n\treturn {\n\t\tloggers: record(),\n\t\tnonConsoleLoggers: record(),\n\t\treporters: options.reporters || [createConsoleLogReporter()],\n\t\tlogLevel: options.logLevel,\n\t\tlogLevelStore: logLevelStore(options)\n\t}\n}\n\nexport interface LogStore {\n\tloggers: Record<string, Logger>\n\tnonConsoleLoggers: Record<string, Logger>\n\treporters: LogReporter[]\n\tlogLevel: LogLevel\n\tlogLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n\tcustomLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n\tconst customLevels = options.customLevels || record()\n\n\tconst store = {\n\t\tcustomLevels,\n\t\tcustomLevelsReverse: reduceByKey(\n\t\t\tcustomLevels,\n\t\t\t(p, k) => {\n\t\t\t\tp[customLevels[k]] = k\n\t\t\t\treturn p\n\t\t\t},\n\t\t\t{} as Record<number, string>\n\t\t)\n\t}\n\treturn {\n\t\tgetName(level: number) {\n\t\t\treturn store.customLevelsReverse[level] ?? toLogLevelName(level)\n\t\t},\n\t\tgetLevel(name: string) {\n\t\t\treturn store.customLevels[name] ?? toLogLevel(name)\n\t\t},\n\t\tgetAllLevels() {\n\t\t\treturn reduceKey(\n\t\t\t\tlogLevels,\n\t\t\t\t(result, name) => {\n\t\t\t\t\tif (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t\tmapKey(store.customLevels, name => ({ name, level: store.customLevels[name] }))\n\t\t\t)\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"log_store.js","names":[],"sources":["../ts/log_store.ts"],"sourcesContent":["import { mapKey, record, reduceByKey, reduceKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(\n\toptions: Required<StandardLogOptions<N>>\n): LogStore {\n\treturn {\n\t\tloggers: record(),\n\t\tnonConsoleLoggers: record(),\n\t\treporters: options.reporters || [createConsoleLogReporter()],\n\t\tlogLevel: options.logLevel,\n\t\tlogLevelStore: logLevelStore(options)\n\t}\n}\n\nexport interface LogStore {\n\tloggers: Record<string, Logger>\n\tnonConsoleLoggers: Record<string, Logger>\n\treporters: LogReporter[]\n\tlogLevel: LogLevel\n\tlogLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n\tcustomLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n\tconst customLevels = options.customLevels || record()\n\n\tconst store = {\n\t\tcustomLevels,\n\t\tcustomLevelsReverse: reduceByKey(\n\t\t\tcustomLevels,\n\t\t\t(p, k) => {\n\t\t\t\tp[customLevels[k]] = k\n\t\t\t\treturn p\n\t\t\t},\n\t\t\t{} as Record<number, string>\n\t\t)\n\t}\n\treturn {\n\t\tgetName(level: number) {\n\t\t\treturn store.customLevelsReverse[level] ?? toLogLevelName(level)\n\t\t},\n\t\tgetLevel(name: string) {\n\t\t\treturn store.customLevels[name] ?? toLogLevel(name)\n\t\t},\n\t\tgetAllLevels() {\n\t\t\treturn reduceKey(\n\t\t\t\tlogLevels,\n\t\t\t\t(result, name) => {\n\t\t\t\t\tif (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t\tmapKey(store.customLevels, name => ({ name, level: store.customLevels[name] }))\n\t\t\t)\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAKA,SAAgB,eACf,SACW;CACX,OAAO;EACN,SAAS,OAAO;EAChB,mBAAmB,OAAO;EAC1B,WAAW,QAAQ,aAAa,CAAC,yBAAyB,CAAC;EAC3D,UAAU,QAAQ;EAClB,eAAe,cAAc,OAAO;CACrC;AACD;AAcA,SAAgB,cAAc,SAA+B;CAC5D,MAAM,eAAe,QAAQ,gBAAgB,OAAO;CAEpD,MAAM,QAAQ;EACb;EACA,qBAAqB,YACpB,eACC,GAAG,MAAM;GACT,EAAE,aAAa,MAAM;GACrB,OAAO;EACR,GACA,CAAC,CACF;CACD;CACA,OAAO;EACN,QAAQ,OAAe;GACtB,OAAO,MAAM,oBAAoB,UAAU,eAAe,KAAK;EAChE;EACA,SAAS,MAAc;GACtB,OAAO,MAAM,aAAa,SAAS,WAAW,IAAI;EACnD;EACA,eAAe;GACd,OAAO,UACN,YACC,QAAQ,SAAS;IACjB,IAAI,SAAS,UAAU,SAAS,OAAO,OAAO,KAAK;KAAE;KAAM,OAAO,UAAU;IAAM,CAAC;IAEnF,OAAO;GACR,GACA,OAAO,MAAM,eAAc,UAAS;IAAE;IAAM,OAAO,MAAM,aAAa;GAAM,EAAE,CAC/E;EACD;CACD;AACD"}
package/esm/logger.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import type { LogStore } from './log_store.js';
2
- import type { Logger, LoggerOptions, LogMethodNames } from './types.js';
3
- export declare function createLogger<N extends string = LogMethodNames>(store: LogStore, id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
1
+ import { LogMethodNames, Logger, LoggerOptions } from "./types.js";
2
+ import { LogStore } from "./log_store.js";
3
+ //#region ts/logger.d.ts
4
+ declare function createLogger<N extends string = LogMethodNames>(store: LogStore, id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
5
+ //#endregion
6
+ export { createLogger };
4
7
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAGX,MAAM,EACN,aAAa,EAEb,cAAc,EAEd,MAAM,YAAY,CAAA;AAEnB,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAC7D,KAAK,EAAE,QAAQ,EACf,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,aAAa,GACrB,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,CA4D5B"}
1
+ {"version":3,"file":"logger.d.ts","names":[],"sources":["../ts/logger.ts"],"mappings":";;;iBAYgB,aAAa,mBAAmB,gBAC/C,OAAO,UACP,YACA,UAAU,gBACR,OAAO,IAAI"}