@wgtechlabs/log-engine 2.0.0 → 2.1.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.
Files changed (182) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +869 -608
  3. package/dist/cjs/__tests__/async-test-utils.cjs +276 -0
  4. package/dist/cjs/__tests__/async-test-utils.d.ts +51 -0
  5. package/dist/cjs/__tests__/async-test-utils.d.ts.map +1 -0
  6. package/dist/cjs/__tests__/async-test-utils.js.map +1 -0
  7. package/dist/cjs/__tests__/redaction/test-utils.cjs +72 -0
  8. package/dist/cjs/__tests__/redaction/test-utils.d.ts +33 -0
  9. package/dist/cjs/__tests__/redaction/test-utils.d.ts.map +1 -0
  10. package/dist/cjs/__tests__/redaction/test-utils.js.map +1 -0
  11. package/dist/cjs/__tests__/test-utils.cjs +49 -0
  12. package/dist/cjs/__tests__/test-utils.d.ts +41 -0
  13. package/dist/cjs/__tests__/test-utils.d.ts.map +1 -0
  14. package/dist/cjs/__tests__/test-utils.js.map +1 -0
  15. package/dist/{formatter/colors.js → cjs/formatter/colors.cjs} +1 -0
  16. package/dist/cjs/formatter/colors.d.ts.map +1 -0
  17. package/dist/cjs/formatter/colors.js.map +1 -0
  18. package/dist/{formatter/data-formatter.js → cjs/formatter/data-formatter.cjs} +2 -1
  19. package/dist/{formatter → cjs/formatter}/data-formatter.d.ts +2 -1
  20. package/dist/cjs/formatter/data-formatter.d.ts.map +1 -0
  21. package/dist/cjs/formatter/data-formatter.js.map +1 -0
  22. package/dist/{formatter/index.js → cjs/formatter/index.cjs} +6 -5
  23. package/dist/cjs/formatter/index.d.ts.map +1 -0
  24. package/dist/cjs/formatter/index.js.map +1 -0
  25. package/dist/{formatter/message-formatter.js → cjs/formatter/message-formatter.cjs} +28 -27
  26. package/dist/cjs/formatter/message-formatter.d.ts +41 -0
  27. package/dist/cjs/formatter/message-formatter.d.ts.map +1 -0
  28. package/dist/cjs/formatter/message-formatter.js.map +1 -0
  29. package/dist/{formatter/timestamp.js → cjs/formatter/timestamp.cjs} +1 -0
  30. package/dist/cjs/formatter/timestamp.d.ts.map +1 -0
  31. package/dist/cjs/formatter/timestamp.js.map +1 -0
  32. package/dist/cjs/index.cjs +202 -0
  33. package/dist/cjs/index.d.ts +180 -0
  34. package/dist/cjs/index.d.ts.map +1 -0
  35. package/dist/cjs/index.js.map +1 -0
  36. package/dist/cjs/logger/advanced-outputs.cjs +587 -0
  37. package/dist/cjs/logger/advanced-outputs.d.ts +159 -0
  38. package/dist/cjs/logger/advanced-outputs.d.ts.map +1 -0
  39. package/dist/cjs/logger/advanced-outputs.js.map +1 -0
  40. package/dist/{logger/config.js → cjs/logger/config.cjs} +36 -32
  41. package/dist/cjs/logger/config.d.ts +42 -0
  42. package/dist/cjs/logger/config.d.ts.map +1 -0
  43. package/dist/cjs/logger/config.js.map +1 -0
  44. package/dist/cjs/logger/core.cjs +371 -0
  45. package/dist/cjs/logger/core.d.ts +152 -0
  46. package/dist/cjs/logger/core.d.ts.map +1 -0
  47. package/dist/cjs/logger/core.js.map +1 -0
  48. package/dist/{logger/environment.js → cjs/logger/environment.cjs} +17 -16
  49. package/dist/cjs/logger/environment.d.ts +36 -0
  50. package/dist/cjs/logger/environment.d.ts.map +1 -0
  51. package/dist/cjs/logger/environment.js.map +1 -0
  52. package/dist/cjs/logger/filtering.cjs +81 -0
  53. package/dist/cjs/logger/filtering.d.ts +36 -0
  54. package/dist/cjs/logger/filtering.d.ts.map +1 -0
  55. package/dist/cjs/logger/filtering.js.map +1 -0
  56. package/dist/{logger/index.js → cjs/logger/index.cjs} +6 -5
  57. package/dist/cjs/logger/index.d.ts.map +1 -0
  58. package/dist/cjs/logger/index.js.map +1 -0
  59. package/dist/cjs/package.json +3 -0
  60. package/dist/{redaction/config.js → cjs/redaction/config.cjs} +9 -8
  61. package/dist/{redaction → cjs/redaction}/config.d.ts +8 -8
  62. package/dist/cjs/redaction/config.d.ts.map +1 -0
  63. package/dist/cjs/redaction/config.js.map +1 -0
  64. package/dist/{redaction/index.js → cjs/redaction/index.cjs} +3 -2
  65. package/dist/cjs/redaction/index.d.ts.map +1 -0
  66. package/dist/cjs/redaction/index.js.map +1 -0
  67. package/dist/cjs/redaction/redactor.cjs +263 -0
  68. package/dist/cjs/redaction/redactor.d.ts +99 -0
  69. package/dist/cjs/redaction/redactor.d.ts.map +1 -0
  70. package/dist/cjs/redaction/redactor.js.map +1 -0
  71. package/dist/{types/index.js → cjs/types/index.cjs} +1 -0
  72. package/dist/{types → cjs/types}/index.d.ts +98 -16
  73. package/dist/cjs/types/index.d.ts.map +1 -0
  74. package/dist/cjs/types/index.js.map +1 -0
  75. package/dist/esm/__tests__/async-test-utils.d.ts +51 -0
  76. package/dist/esm/__tests__/async-test-utils.d.ts.map +1 -0
  77. package/dist/esm/__tests__/async-test-utils.js +231 -0
  78. package/dist/esm/__tests__/async-test-utils.js.map +1 -0
  79. package/dist/esm/__tests__/redaction/test-utils.d.ts +33 -0
  80. package/dist/esm/__tests__/redaction/test-utils.d.ts.map +1 -0
  81. package/dist/esm/__tests__/redaction/test-utils.js +65 -0
  82. package/dist/esm/__tests__/redaction/test-utils.js.map +1 -0
  83. package/dist/esm/__tests__/test-utils.d.ts +41 -0
  84. package/dist/esm/__tests__/test-utils.d.ts.map +1 -0
  85. package/dist/esm/__tests__/test-utils.js +42 -0
  86. package/dist/esm/__tests__/test-utils.js.map +1 -0
  87. package/dist/esm/formatter/colors.d.ts +32 -0
  88. package/dist/esm/formatter/colors.d.ts.map +1 -0
  89. package/dist/esm/formatter/colors.js +32 -0
  90. package/dist/esm/formatter/colors.js.map +1 -0
  91. package/dist/esm/formatter/data-formatter.d.ts +26 -0
  92. package/dist/esm/formatter/data-formatter.d.ts.map +1 -0
  93. package/dist/esm/formatter/data-formatter.js +50 -0
  94. package/dist/esm/formatter/data-formatter.js.map +1 -0
  95. package/dist/esm/formatter/index.d.ts +10 -0
  96. package/dist/esm/formatter/index.d.ts.map +1 -0
  97. package/dist/esm/formatter/index.js +11 -0
  98. package/dist/esm/formatter/index.js.map +1 -0
  99. package/dist/esm/formatter/message-formatter.d.ts +41 -0
  100. package/dist/esm/formatter/message-formatter.d.ts.map +1 -0
  101. package/dist/esm/formatter/message-formatter.js +84 -0
  102. package/dist/esm/formatter/message-formatter.js.map +1 -0
  103. package/dist/esm/formatter/timestamp.d.ts +27 -0
  104. package/dist/esm/formatter/timestamp.d.ts.map +1 -0
  105. package/dist/esm/formatter/timestamp.js +36 -0
  106. package/dist/esm/formatter/timestamp.js.map +1 -0
  107. package/dist/esm/index.d.ts +180 -0
  108. package/dist/esm/index.d.ts.map +1 -0
  109. package/dist/esm/index.js +194 -0
  110. package/dist/esm/index.js.map +1 -0
  111. package/dist/esm/logger/advanced-outputs.d.ts +159 -0
  112. package/dist/esm/logger/advanced-outputs.d.ts.map +1 -0
  113. package/dist/esm/logger/advanced-outputs.js +542 -0
  114. package/dist/esm/logger/advanced-outputs.js.map +1 -0
  115. package/dist/esm/logger/config.d.ts +42 -0
  116. package/dist/esm/logger/config.d.ts.map +1 -0
  117. package/dist/esm/logger/config.js +101 -0
  118. package/dist/esm/logger/config.js.map +1 -0
  119. package/dist/esm/logger/core.d.ts +152 -0
  120. package/dist/esm/logger/core.d.ts.map +1 -0
  121. package/dist/esm/logger/core.js +367 -0
  122. package/dist/esm/logger/core.js.map +1 -0
  123. package/dist/esm/logger/environment.d.ts +36 -0
  124. package/dist/esm/logger/environment.d.ts.map +1 -0
  125. package/dist/esm/logger/environment.js +58 -0
  126. package/dist/esm/logger/environment.js.map +1 -0
  127. package/dist/esm/logger/filtering.d.ts +36 -0
  128. package/dist/esm/logger/filtering.d.ts.map +1 -0
  129. package/dist/esm/logger/filtering.js +77 -0
  130. package/dist/esm/logger/filtering.js.map +1 -0
  131. package/dist/esm/logger/index.d.ts +10 -0
  132. package/dist/esm/logger/index.d.ts.map +1 -0
  133. package/dist/esm/logger/index.js +11 -0
  134. package/dist/esm/logger/index.js.map +1 -0
  135. package/dist/esm/redaction/config.d.ts +29 -0
  136. package/dist/esm/redaction/config.d.ts.map +1 -0
  137. package/dist/esm/redaction/config.js +92 -0
  138. package/dist/esm/redaction/config.js.map +1 -0
  139. package/dist/esm/redaction/index.d.ts +8 -0
  140. package/dist/esm/redaction/index.d.ts.map +1 -0
  141. package/dist/esm/redaction/index.js +7 -0
  142. package/dist/esm/redaction/index.js.map +1 -0
  143. package/dist/esm/redaction/redactor.d.ts +99 -0
  144. package/dist/esm/redaction/redactor.d.ts.map +1 -0
  145. package/dist/esm/redaction/redactor.js +259 -0
  146. package/dist/esm/redaction/redactor.js.map +1 -0
  147. package/dist/esm/types/index.d.ts +310 -0
  148. package/dist/esm/types/index.d.ts.map +1 -0
  149. package/dist/esm/types/index.js +41 -0
  150. package/dist/esm/types/index.js.map +1 -0
  151. package/package.json +94 -68
  152. package/dist/formatter/colors.d.ts.map +0 -1
  153. package/dist/formatter/data-formatter.d.ts.map +0 -1
  154. package/dist/formatter/index.d.ts.map +0 -1
  155. package/dist/formatter/message-formatter.d.ts +0 -41
  156. package/dist/formatter/message-formatter.d.ts.map +0 -1
  157. package/dist/formatter/timestamp.d.ts.map +0 -1
  158. package/dist/index.d.ts +0 -186
  159. package/dist/index.d.ts.map +0 -1
  160. package/dist/index.js +0 -201
  161. package/dist/logger/config.d.ts +0 -42
  162. package/dist/logger/config.d.ts.map +0 -1
  163. package/dist/logger/core.d.ts +0 -108
  164. package/dist/logger/core.d.ts.map +0 -1
  165. package/dist/logger/core.js +0 -185
  166. package/dist/logger/environment.d.ts +0 -36
  167. package/dist/logger/environment.d.ts.map +0 -1
  168. package/dist/logger/filtering.d.ts +0 -36
  169. package/dist/logger/filtering.d.ts.map +0 -1
  170. package/dist/logger/filtering.js +0 -65
  171. package/dist/logger/index.d.ts.map +0 -1
  172. package/dist/redaction/config.d.ts.map +0 -1
  173. package/dist/redaction/index.d.ts.map +0 -1
  174. package/dist/redaction/redactor.d.ts +0 -99
  175. package/dist/redaction/redactor.d.ts.map +0 -1
  176. package/dist/redaction/redactor.js +0 -257
  177. package/dist/types/index.d.ts.map +0 -1
  178. /package/dist/{formatter → cjs/formatter}/colors.d.ts +0 -0
  179. /package/dist/{formatter → cjs/formatter}/index.d.ts +0 -0
  180. /package/dist/{formatter → cjs/formatter}/timestamp.d.ts +0 -0
  181. /package/dist/{logger → cjs/logger}/index.d.ts +0 -0
  182. /package/dist/{redaction → cjs/redaction}/index.d.ts +0 -0
@@ -1,108 +0,0 @@
1
- /**
2
- * Core Logger class that handles log message output with configurable levels
3
- * Supports DEBUG, INFO, WARN, ERROR, and LOG levels with intelligent filtering
4
- * LOG level always outputs regardless of configuration
5
- * Uses colorized console output with timestamps for better readability
6
- * Includes automatic data redaction for sensitive information
7
- */
8
- import { LoggerConfig } from '../types';
9
- /**
10
- * Logger class responsible for managing log output and configuration
11
- * Provides mode-based filtering and formatted console output
12
- */
13
- export declare class Logger {
14
- private configManager;
15
- /**
16
- * Logger constructor - sets up environment-based auto-configuration
17
- */
18
- constructor();
19
- /**
20
- * Updates logger configuration with new settings
21
- * Also updates redaction configuration based on environment
22
- * @param config - Partial configuration object to apply
23
- */
24
- configure(config: Partial<LoggerConfig>): void;
25
- /**
26
- * Get current logger configuration
27
- * @returns Current logger configuration
28
- */
29
- getConfig(): LoggerConfig;
30
- /**
31
- * Determines if a message should be logged based on current log mode
32
- * @param level - The log level of the message to check
33
- * @returns true if message should be logged, false otherwise
34
- */
35
- private shouldLog;
36
- /**
37
- * Log a debug message with DEBUG level formatting
38
- * Uses console.log for output with purple/magenta coloring
39
- * Automatically redacts sensitive data when provided
40
- * @param message - The debug message to log
41
- * @param data - Optional data object to log (will be redacted)
42
- */
43
- debug(message: string, data?: any): void;
44
- /**
45
- * Log an informational message with INFO level formatting
46
- * Uses console.log for output with blue coloring
47
- * Automatically redacts sensitive data when provided
48
- * @param message - The info message to log
49
- * @param data - Optional data object to log (will be redacted)
50
- */
51
- info(message: string, data?: any): void;
52
- /**
53
- * Log a warning message with WARN level formatting
54
- * Uses console.warn for output with yellow coloring
55
- * Automatically redacts sensitive data when provided
56
- * @param message - The warning message to log
57
- * @param data - Optional data object to log (will be redacted)
58
- */
59
- warn(message: string, data?: any): void;
60
- /**
61
- * Log an error message with ERROR level formatting
62
- * Uses console.error for output with red coloring
63
- * Automatically redacts sensitive data when provided
64
- * @param message - The error message to log
65
- * @param data - Optional data object to log (will be redacted)
66
- */
67
- error(message: string, data?: any): void;
68
- /**
69
- * Log a message with LOG level formatting (always outputs unless mode is OFF)
70
- * Uses console.log for output with green coloring
71
- * LOG level bypasses normal filtering and always outputs (except when OFF is set)
72
- * Automatically redacts sensitive data when provided
73
- * @param message - The log message to output
74
- * @param data - Optional data object to log (will be redacted)
75
- */
76
- log(message: string, data?: any): void;
77
- /**
78
- * Log a debug message without data redaction
79
- * @param message - The debug message to log
80
- * @param data - Optional data object to log (no redaction applied)
81
- */
82
- debugRaw(message: string, data?: any): void;
83
- /**
84
- * Log an info message without data redaction
85
- * @param message - The info message to log
86
- * @param data - Optional data object to log (no redaction applied)
87
- */
88
- infoRaw(message: string, data?: any): void;
89
- /**
90
- * Log a warning message without data redaction
91
- * @param message - The warning message to log
92
- * @param data - Optional data object to log (no redaction applied)
93
- */
94
- warnRaw(message: string, data?: any): void;
95
- /**
96
- * Log an error message without data redaction
97
- * @param message - The error message to log
98
- * @param data - Optional data object to log (no redaction applied)
99
- */
100
- errorRaw(message: string, data?: any): void;
101
- /**
102
- * Log a message without data redaction (always outputs unless mode is OFF)
103
- * @param message - The log message to output
104
- * @param data - Optional data object to log (no redaction applied)
105
- */
106
- logRaw(message: string, data?: any): void;
107
- }
108
- //# sourceMappingURL=core.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/logger/core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAqB,YAAY,EAAE,MAAM,UAAU,CAAC;AAM3D;;;GAGG;AACH,qBAAa,MAAM;IACf,OAAO,CAAC,aAAa,CAAsB;IAE3C;;OAEG;;IAKH;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAU9C;;;OAGG;IACH,SAAS,IAAI,YAAY;IAIzB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAMjB;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAQxC;;;;;;OAMG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAQvC;;;;;;OAMG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAQvC;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAQxC;;;;;;;OAOG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAStC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAO3C;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAO1C;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAO1C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAO3C;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;CAM5C"}
@@ -1,185 +0,0 @@
1
- "use strict";
2
- /**
3
- * Core Logger class that handles log message output with configurable levels
4
- * Supports DEBUG, INFO, WARN, ERROR, and LOG levels with intelligent filtering
5
- * LOG level always outputs regardless of configuration
6
- * Uses colorized console output with timestamps for better readability
7
- * Includes automatic data redaction for sensitive information
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Logger = void 0;
11
- const types_1 = require("../types");
12
- const formatter_1 = require("../formatter");
13
- const redaction_1 = require("../redaction");
14
- const config_1 = require("./config");
15
- const filtering_1 = require("./filtering");
16
- /**
17
- * Logger class responsible for managing log output and configuration
18
- * Provides mode-based filtering and formatted console output
19
- */
20
- class Logger {
21
- /**
22
- * Logger constructor - sets up environment-based auto-configuration
23
- */
24
- constructor() {
25
- this.configManager = new config_1.LoggerConfigManager();
26
- }
27
- /**
28
- * Updates logger configuration with new settings
29
- * Also updates redaction configuration based on environment
30
- * @param config - Partial configuration object to apply
31
- */
32
- configure(config) {
33
- this.configManager.updateConfig(config);
34
- // Update redaction configuration based on current environment
35
- redaction_1.DataRedactor.updateConfig({
36
- ...redaction_1.defaultRedactionConfig,
37
- ...redaction_1.RedactionController.getEnvironmentConfig()
38
- });
39
- }
40
- /**
41
- * Get current logger configuration
42
- * @returns Current logger configuration
43
- */
44
- getConfig() {
45
- return this.configManager.getConfig();
46
- }
47
- /**
48
- * Determines if a message should be logged based on current log mode
49
- * @param level - The log level of the message to check
50
- * @returns true if message should be logged, false otherwise
51
- */
52
- shouldLog(level) {
53
- const currentConfig = this.configManager.getConfig();
54
- const currentMode = currentConfig.mode !== undefined ? currentConfig.mode : types_1.LogMode.INFO;
55
- return filtering_1.LogFilter.shouldLog(level, currentMode);
56
- }
57
- /**
58
- * Log a debug message with DEBUG level formatting
59
- * Uses console.log for output with purple/magenta coloring
60
- * Automatically redacts sensitive data when provided
61
- * @param message - The debug message to log
62
- * @param data - Optional data object to log (will be redacted)
63
- */
64
- debug(message, data) {
65
- if (this.shouldLog(types_1.LogLevel.DEBUG)) {
66
- const processedData = redaction_1.DataRedactor.redactData(data);
67
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.DEBUG, message, processedData);
68
- console.log(formatted);
69
- }
70
- }
71
- /**
72
- * Log an informational message with INFO level formatting
73
- * Uses console.log for output with blue coloring
74
- * Automatically redacts sensitive data when provided
75
- * @param message - The info message to log
76
- * @param data - Optional data object to log (will be redacted)
77
- */
78
- info(message, data) {
79
- if (this.shouldLog(types_1.LogLevel.INFO)) {
80
- const processedData = redaction_1.DataRedactor.redactData(data);
81
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.INFO, message, processedData);
82
- console.log(formatted);
83
- }
84
- }
85
- /**
86
- * Log a warning message with WARN level formatting
87
- * Uses console.warn for output with yellow coloring
88
- * Automatically redacts sensitive data when provided
89
- * @param message - The warning message to log
90
- * @param data - Optional data object to log (will be redacted)
91
- */
92
- warn(message, data) {
93
- if (this.shouldLog(types_1.LogLevel.WARN)) {
94
- const processedData = redaction_1.DataRedactor.redactData(data);
95
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.WARN, message, processedData);
96
- console.warn(formatted);
97
- }
98
- }
99
- /**
100
- * Log an error message with ERROR level formatting
101
- * Uses console.error for output with red coloring
102
- * Automatically redacts sensitive data when provided
103
- * @param message - The error message to log
104
- * @param data - Optional data object to log (will be redacted)
105
- */
106
- error(message, data) {
107
- if (this.shouldLog(types_1.LogLevel.ERROR)) {
108
- const processedData = redaction_1.DataRedactor.redactData(data);
109
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.ERROR, message, processedData);
110
- console.error(formatted);
111
- }
112
- }
113
- /**
114
- * Log a message with LOG level formatting (always outputs unless mode is OFF)
115
- * Uses console.log for output with green coloring
116
- * LOG level bypasses normal filtering and always outputs (except when OFF is set)
117
- * Automatically redacts sensitive data when provided
118
- * @param message - The log message to output
119
- * @param data - Optional data object to log (will be redacted)
120
- */
121
- log(message, data) {
122
- if (this.shouldLog(types_1.LogLevel.LOG)) {
123
- const processedData = redaction_1.DataRedactor.redactData(data);
124
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.LOG, message, processedData);
125
- console.log(formatted);
126
- }
127
- }
128
- // Raw logging methods (bypass redaction for debugging)
129
- /**
130
- * Log a debug message without data redaction
131
- * @param message - The debug message to log
132
- * @param data - Optional data object to log (no redaction applied)
133
- */
134
- debugRaw(message, data) {
135
- if (this.shouldLog(types_1.LogLevel.DEBUG)) {
136
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.DEBUG, message, data);
137
- console.log(formatted);
138
- }
139
- }
140
- /**
141
- * Log an info message without data redaction
142
- * @param message - The info message to log
143
- * @param data - Optional data object to log (no redaction applied)
144
- */
145
- infoRaw(message, data) {
146
- if (this.shouldLog(types_1.LogLevel.INFO)) {
147
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.INFO, message, data);
148
- console.log(formatted);
149
- }
150
- }
151
- /**
152
- * Log a warning message without data redaction
153
- * @param message - The warning message to log
154
- * @param data - Optional data object to log (no redaction applied)
155
- */
156
- warnRaw(message, data) {
157
- if (this.shouldLog(types_1.LogLevel.WARN)) {
158
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.WARN, message, data);
159
- console.warn(formatted);
160
- }
161
- }
162
- /**
163
- * Log an error message without data redaction
164
- * @param message - The error message to log
165
- * @param data - Optional data object to log (no redaction applied)
166
- */
167
- errorRaw(message, data) {
168
- if (this.shouldLog(types_1.LogLevel.ERROR)) {
169
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.ERROR, message, data);
170
- console.error(formatted);
171
- }
172
- }
173
- /**
174
- * Log a message without data redaction (always outputs unless mode is OFF)
175
- * @param message - The log message to output
176
- * @param data - Optional data object to log (no redaction applied)
177
- */
178
- logRaw(message, data) {
179
- if (this.shouldLog(types_1.LogLevel.LOG)) {
180
- const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.LOG, message, data);
181
- console.log(formatted);
182
- }
183
- }
184
- }
185
- exports.Logger = Logger;
@@ -1,36 +0,0 @@
1
- /**
2
- * Environment detection utilities for logging configuration
3
- * Handles automatic environment-based configuration
4
- */
5
- import { LogMode } from '../types';
6
- /**
7
- * Environment detection and configuration utilities
8
- */
9
- export declare class EnvironmentDetector {
10
- /**
11
- * Get the normalized NODE_ENV value
12
- * @returns Normalized NODE_ENV (trimmed and lowercase)
13
- */
14
- private static getNormalizedNodeEnv;
15
- /**
16
- * Determines the appropriate log mode based on NODE_ENV
17
- * @returns LogMode appropriate for current environment
18
- */
19
- static getEnvironmentMode(): LogMode;
20
- /**
21
- * Check if we're in a test environment
22
- * @returns true if NODE_ENV is 'test'
23
- */
24
- static isTestEnvironment(): boolean;
25
- /**
26
- * Check if we're in a development environment
27
- * @returns true if NODE_ENV is 'development'
28
- */
29
- static isDevelopmentEnvironment(): boolean;
30
- /**
31
- * Check if we're in a production environment
32
- * @returns true if NODE_ENV is 'production'
33
- */
34
- static isProductionEnvironment(): boolean;
35
- }
36
- //# sourceMappingURL=environment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/logger/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC;;GAEG;AACH,qBAAa,mBAAmB;IAC5B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC;;;OAGG;IACH,MAAM,CAAC,kBAAkB,IAAI,OAAO;IAiBpC;;;OAGG;IACH,MAAM,CAAC,iBAAiB,IAAI,OAAO;IAInC;;;OAGG;IACH,MAAM,CAAC,wBAAwB,IAAI,OAAO;IAI1C;;;OAGG;IACH,MAAM,CAAC,uBAAuB,IAAI,OAAO;CAG5C"}
@@ -1,36 +0,0 @@
1
- /**
2
- * Log level and mode filtering logic
3
- * Handles the decision logic for whether messages should be logged
4
- */
5
- import { LogLevel, LogMode } from '../types';
6
- /**
7
- * Filtering logic for log messages based on levels and modes
8
- * Determines whether a message should be output based on current configuration
9
- */
10
- export declare class LogFilter {
11
- private static readonly SEVERITY_RANKS;
12
- private static readonly MODE_THRESHOLDS;
13
- /**
14
- * Determines if a message should be logged based on current log mode
15
- * Messages are shown only if their level is appropriate for the configured mode
16
- * LOG level is special - it always outputs regardless of configured mode (except when OFF is set)
17
- * OFF mode disables all logging including LOG level messages
18
- * @param level - The log level of the message to check
19
- * @param currentMode - The current logging mode
20
- * @returns true if message should be logged, false otherwise
21
- */
22
- static shouldLog(level: LogLevel, currentMode: LogMode): boolean;
23
- /**
24
- * Get the severity rank for a log level
25
- * @param level - The log level to get rank for
26
- * @returns Numeric severity rank
27
- */
28
- static getSeverityRank(level: LogLevel): number;
29
- /**
30
- * Get the threshold for a log mode
31
- * @param mode - The log mode to get threshold for
32
- * @returns Numeric threshold value
33
- */
34
- static getModeThreshold(mode: LogMode): number;
35
- }
36
- //# sourceMappingURL=filtering.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../src/logger/filtering.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE7C;;;GAGG;AACH,qBAAa,SAAS;IAElB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAMpC;IAGF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAOrC;IAEF;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO;IAWhE;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM;IAI/C;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;CAGjD"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- /**
3
- * Log level and mode filtering logic
4
- * Handles the decision logic for whether messages should be logged
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.LogFilter = void 0;
8
- const types_1 = require("../types");
9
- /**
10
- * Filtering logic for log messages based on levels and modes
11
- * Determines whether a message should be output based on current configuration
12
- */
13
- class LogFilter {
14
- /**
15
- * Determines if a message should be logged based on current log mode
16
- * Messages are shown only if their level is appropriate for the configured mode
17
- * LOG level is special - it always outputs regardless of configured mode (except when OFF is set)
18
- * OFF mode disables all logging including LOG level messages
19
- * @param level - The log level of the message to check
20
- * @param currentMode - The current logging mode
21
- * @returns true if message should be logged, false otherwise
22
- */
23
- static shouldLog(level, currentMode) {
24
- // Get the severity rank for the message level
25
- const messageSeverity = this.SEVERITY_RANKS[level];
26
- // Get the minimum severity threshold for the current mode
27
- const modeThreshold = this.MODE_THRESHOLDS[currentMode];
28
- // Allow the message if its severity meets or exceeds the mode threshold
29
- return messageSeverity >= modeThreshold;
30
- }
31
- /**
32
- * Get the severity rank for a log level
33
- * @param level - The log level to get rank for
34
- * @returns Numeric severity rank
35
- */
36
- static getSeverityRank(level) {
37
- return this.SEVERITY_RANKS[level];
38
- }
39
- /**
40
- * Get the threshold for a log mode
41
- * @param mode - The log mode to get threshold for
42
- * @returns Numeric threshold value
43
- */
44
- static getModeThreshold(mode) {
45
- return this.MODE_THRESHOLDS[mode];
46
- }
47
- }
48
- exports.LogFilter = LogFilter;
49
- // Maps LogLevel values to severity ranks for consistent comparison
50
- LogFilter.SEVERITY_RANKS = {
51
- [types_1.LogLevel.DEBUG]: 0,
52
- [types_1.LogLevel.INFO]: 1,
53
- [types_1.LogLevel.WARN]: 2,
54
- [types_1.LogLevel.ERROR]: 3,
55
- [types_1.LogLevel.LOG]: 99 // Special case - always outputs (except when OFF)
56
- };
57
- // Maps LogMode values to minimum severity rank required for output
58
- LogFilter.MODE_THRESHOLDS = {
59
- [types_1.LogMode.DEBUG]: 0, // Shows DEBUG and above
60
- [types_1.LogMode.INFO]: 1, // Shows INFO and above
61
- [types_1.LogMode.WARN]: 2, // Shows WARN and above
62
- [types_1.LogMode.ERROR]: 3, // Shows ERROR and above
63
- [types_1.LogMode.SILENT]: 99, // Only shows LOG messages
64
- [types_1.LogMode.OFF]: 100 // Shows nothing
65
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/redaction/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,eAyCpC,CAAC;AAEF;;;GAGG;AACH,qBAAa,mBAAmB;IAC5B;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,IAAI,OAAO;IAUrC;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,IAAI,OAAO,CAAC,eAAe,CAAC;CA4B1D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redaction/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACvE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
@@ -1,99 +0,0 @@
1
- /**
2
- * Core data redaction engine
3
- * Handles automatic detection and redaction of sensitive information in log data
4
- */
5
- import { RedactionConfig } from '../types';
6
- /**
7
- * DataRedactor class - Core redaction logic for processing log data
8
- * Automatically detects and redacts sensitive information while preserving structure
9
- */
10
- export declare class DataRedactor {
11
- private static config;
12
- private static readonly MAX_RECURSION_DEPTH;
13
- private static readonly MAX_REDACT_OBJECT_DEPTH;
14
- /**
15
- * Update the redaction configuration with new settings
16
- * Merges provided config with existing settings and reloads environment variables
17
- * @param newConfig - Partial configuration to merge with current settings
18
- */
19
- static updateConfig(newConfig: Partial<RedactionConfig>): void;
20
- /**
21
- * Get the current redaction configuration
22
- * @returns Deep copy of current redaction configuration
23
- */
24
- static getConfig(): RedactionConfig;
25
- /**
26
- * Refresh configuration from environment variables
27
- * Useful for picking up runtime environment changes
28
- */
29
- static refreshConfig(): void;
30
- /**
31
- * Add custom regex patterns for advanced field detection
32
- * @param patterns - Array of regex patterns to add
33
- */
34
- static addCustomPatterns(patterns: RegExp[]): void;
35
- /**
36
- * Clear all custom regex patterns
37
- */
38
- static clearCustomPatterns(): void;
39
- /**
40
- * Add custom sensitive field names to the existing list
41
- * @param fields - Array of field names to add
42
- */
43
- static addSensitiveFields(fields: string[]): void;
44
- /**
45
- * Test if a field name would be redacted with current configuration
46
- * @param fieldName - Field name to test
47
- * @returns true if field would be redacted, false otherwise
48
- */
49
- static testFieldRedaction(fieldName: string): boolean;
50
- /**
51
- * Main entry point for data redaction
52
- * Processes any type of data and returns a redacted version
53
- * @param data - Data to be processed for redaction
54
- * @returns Redacted version of the data
55
- */
56
- static redactData(data: any): any;
57
- /**
58
- * Process a value of any type (primitive, object, array)
59
- * Recursively handles nested structures when deepRedaction is enabled
60
- * Includes circular reference protection and recursion depth limiting
61
- * @param value - Value to process
62
- * @param visited - Set to track visited objects (prevents circular references)
63
- * @param depth - Current recursion depth (prevents stack overflow)
64
- * @returns Processed value with redaction applied
65
- */
66
- private static processValue;
67
- /**
68
- * Process an object and redact sensitive fields
69
- * Handles field-level redaction and content truncation
70
- * @param obj - Object to process
71
- * @param visited - Set to track visited objects (prevents circular references)
72
- * @param depth - Current recursion depth (prevents stack overflow)
73
- * @returns Object with sensitive fields redacted
74
- */
75
- private static redactObject;
76
- /**
77
- * Check if a field name indicates sensitive information
78
- * Uses case-insensitive matching with exact and partial matches
79
- * Includes smart filtering to avoid false positives and custom patterns
80
- * @param fieldName - Field name to check
81
- * @returns true if field should be redacted, false otherwise
82
- */
83
- private static isSensitiveField;
84
- /**
85
- * Check if a field name indicates content that should be truncated
86
- * Uses exact case-insensitive matching for content fields
87
- * @param fieldName - Field name to check
88
- * @returns true if field is a content field, false otherwise
89
- */
90
- private static isContentField;
91
- /**
92
- * Truncate content that exceeds the maximum length
93
- * Preserves readability while preventing log bloat
94
- * @param content - Content string to potentially truncate
95
- * @returns Original content or truncated version with indicator
96
- */
97
- private static truncateContent;
98
- }
99
- //# sourceMappingURL=redactor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redactor.d.ts","sourceRoot":"","sources":["../../src/redaction/redactor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C;;;GAGG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,MAAM,CAAC,MAAM,CAGnB;IAGF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAO;IAElD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAM;IAErD;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAU9D;;;OAGG;IACH,MAAM,CAAC,SAAS,IAAI,eAAe;IASnC;;;OAGG;IACH,MAAM,CAAC,aAAa,IAAI,IAAI;IAQ5B;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAQlD;;OAEG;IACH,MAAM,CAAC,mBAAmB,IAAI,IAAI;IAOlC;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAOjD;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAMrD;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG;IASjC;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAyC3B;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IA8B3B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAgD/B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAK7B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;CAMjC"}