@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
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shared test utilities for log-engine tests
3
+ * Provides consistent console mocking and cleanup functionality across all test suites
4
+ */
5
+ /**
6
+ * Sets up console mocks for testing log output
7
+ * Replaces console methods with Jest spies to capture and verify log calls
8
+ * @returns ConsoleMocks object containing all spy instances
9
+ */
10
+ export const setupConsoleMocks = () => {
11
+ const mockConsoleLog = jest.spyOn(console, 'log').mockImplementation();
12
+ const mockConsoleWarn = jest.spyOn(console, 'warn').mockImplementation();
13
+ const mockConsoleError = jest.spyOn(console, 'error').mockImplementation();
14
+ return { mockConsoleLog, mockConsoleWarn, mockConsoleError };
15
+ };
16
+ /**
17
+ * Restores console mocks after testing
18
+ * Cleans up Jest spies and restores original console functionality
19
+ * @param mocks - The ConsoleMocks object from setupConsoleMocks
20
+ */
21
+ export const restoreConsoleMocks = (mocks) => {
22
+ mocks.mockConsoleLog.mockRestore();
23
+ mocks.mockConsoleWarn.mockRestore();
24
+ mocks.mockConsoleError.mockRestore();
25
+ };
26
+ /**
27
+ * Convenience function for setting up console mocks in beforeEach hooks
28
+ * Identical to setupConsoleMocks but with a more descriptive name for test setup
29
+ * @returns ConsoleMocks object containing all spy instances
30
+ */
31
+ export const setupConsoleBeforeEach = () => {
32
+ return setupConsoleMocks();
33
+ };
34
+ /**
35
+ * Convenience function for restoring console mocks in afterEach hooks
36
+ * Identical to restoreConsoleMocks but with a more descriptive name for test cleanup
37
+ * @param mocks - The ConsoleMocks object to restore
38
+ */
39
+ export const restoreConsoleAfterEach = (mocks) => {
40
+ restoreConsoleMocks(mocks);
41
+ };
42
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../../src/__tests__/test-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAiB,EAAE;IAClD,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACvE,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACzE,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAE3E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAC/D,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAmB,EAAQ,EAAE;IAC/D,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;IACnC,KAAK,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;IACpC,KAAK,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAiB,EAAE;IACvD,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAmB,EAAQ,EAAE;IACnE,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ANSI color codes and color management for terminal output
3
+ * Provides consistent color definitions used throughout the formatting system
4
+ */
5
+ /**
6
+ * ANSI color codes for terminal output styling
7
+ * Used to create colorized console output with consistent theming
8
+ */
9
+ export declare const colors: {
10
+ readonly reset: "\u001B[0m";
11
+ readonly dim: "\u001B[2m";
12
+ readonly red: "\u001B[31m";
13
+ readonly yellow: "\u001B[33m";
14
+ readonly blue: "\u001B[34m";
15
+ readonly magenta: "\u001B[35m";
16
+ readonly cyan: "\u001B[36m";
17
+ readonly white: "\u001B[37m";
18
+ readonly gray: "\u001B[90m";
19
+ readonly green: "\u001B[32m";
20
+ };
21
+ /**
22
+ * Color scheme configuration
23
+ * Maps semantic meanings to specific colors for consistent theming
24
+ */
25
+ export declare const colorScheme: {
26
+ readonly timestamp: "\u001B[90m";
27
+ readonly timeString: "\u001B[36m";
28
+ readonly system: "\u001B[33m";
29
+ readonly data: "\u001B[2m";
30
+ readonly reset: "\u001B[0m";
31
+ };
32
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/formatter/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;CAWT,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ANSI color codes and color management for terminal output
3
+ * Provides consistent color definitions used throughout the formatting system
4
+ */
5
+ /**
6
+ * ANSI color codes for terminal output styling
7
+ * Used to create colorized console output with consistent theming
8
+ */
9
+ export const colors = {
10
+ reset: '\x1b[0m', // Reset all formatting
11
+ dim: '\x1b[2m', // Dim/faded text
12
+ red: '\x1b[31m', // Red text (errors)
13
+ yellow: '\x1b[33m', // Yellow text (warnings)
14
+ blue: '\x1b[34m', // Blue text (info)
15
+ magenta: '\x1b[35m', // Magenta text (debug)
16
+ cyan: '\x1b[36m', // Cyan text (timestamps)
17
+ white: '\x1b[37m', // White text (default)
18
+ gray: '\x1b[90m', // Gray text (timestamps)
19
+ green: '\x1b[32m' // Green text (log level)
20
+ };
21
+ /**
22
+ * Color scheme configuration
23
+ * Maps semantic meanings to specific colors for consistent theming
24
+ */
25
+ export const colorScheme = {
26
+ timestamp: colors.gray,
27
+ timeString: colors.cyan,
28
+ system: colors.yellow,
29
+ data: colors.dim,
30
+ reset: colors.reset
31
+ };
32
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/formatter/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,SAAS,EAAO,uBAAuB;IAC9C,GAAG,EAAE,SAAS,EAAS,iBAAiB;IACxC,GAAG,EAAE,UAAU,EAAQ,oBAAoB;IAC3C,MAAM,EAAE,UAAU,EAAK,yBAAyB;IAChD,IAAI,EAAE,UAAU,EAAO,mBAAmB;IAC1C,OAAO,EAAE,UAAU,EAAI,uBAAuB;IAC9C,IAAI,EAAE,UAAU,EAAO,yBAAyB;IAChD,KAAK,EAAE,UAAU,EAAM,uBAAuB;IAC9C,IAAI,EAAE,UAAU,EAAO,yBAAyB;IAChD,KAAK,EAAE,UAAU,CAAM,yBAAyB;CACxC,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC,IAAI;IACtB,UAAU,EAAE,MAAM,CAAC,IAAI;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC,KAAK;CACX,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Data formatting utilities for log output
3
+ * Handles serialization and formatting of data objects in log messages
4
+ */
5
+ import { LogData } from '../types';
6
+ /**
7
+ * Converts input data to a readable string suitable for log output.
8
+ *
9
+ * Returns 'null' for `null`, an empty string for `undefined`, the value itself for strings, and string representations for numbers and booleans. For other types, attempts JSON serialization; if serialization fails, returns '[Object]'.
10
+ *
11
+ * @param data - The value to format for logging
12
+ * @returns The formatted string representation of the input data
13
+ */
14
+ export declare function formatData(data: LogData): string;
15
+ /**
16
+ * Applies color styling to a formatted data string using the provided color codes.
17
+ *
18
+ * @param dataString - The string to be styled; if falsy, an empty string is returned.
19
+ * @param colors - An object containing `data` (the color code prefix) and `reset` (the color code suffix).
20
+ * @returns The styled data string with color codes applied, or an empty string if `dataString` is falsy.
21
+ */
22
+ export declare function styleData(dataString: string, colors: {
23
+ data: string;
24
+ reset: string;
25
+ }): string;
26
+ //# sourceMappingURL=data-formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-formatter.d.ts","sourceRoot":"","sources":["../../../src/formatter/data-formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CA2BhD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAM7F"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Data formatting utilities for log output
3
+ * Handles serialization and formatting of data objects in log messages
4
+ */
5
+ /**
6
+ * Converts input data to a readable string suitable for log output.
7
+ *
8
+ * Returns 'null' for `null`, an empty string for `undefined`, the value itself for strings, and string representations for numbers and booleans. For other types, attempts JSON serialization; if serialization fails, returns '[Object]'.
9
+ *
10
+ * @param data - The value to format for logging
11
+ * @returns The formatted string representation of the input data
12
+ */
13
+ export function formatData(data) {
14
+ if (data === null) {
15
+ return 'null';
16
+ }
17
+ if (data === undefined) {
18
+ return '';
19
+ }
20
+ if (typeof data === 'string') {
21
+ return data;
22
+ }
23
+ if (typeof data === 'number' || typeof data === 'boolean') {
24
+ return String(data);
25
+ }
26
+ if (typeof data === 'symbol') {
27
+ return data.toString();
28
+ }
29
+ try {
30
+ return JSON.stringify(data, null, 0);
31
+ }
32
+ catch {
33
+ // Fallback for objects that can't be stringified (e.g., circular references)
34
+ return '[Object]';
35
+ }
36
+ }
37
+ /**
38
+ * Applies color styling to a formatted data string using the provided color codes.
39
+ *
40
+ * @param dataString - The string to be styled; if falsy, an empty string is returned.
41
+ * @param colors - An object containing `data` (the color code prefix) and `reset` (the color code suffix).
42
+ * @returns The styled data string with color codes applied, or an empty string if `dataString` is falsy.
43
+ */
44
+ export function styleData(dataString, colors) {
45
+ if (!dataString) {
46
+ return '';
47
+ }
48
+ return ` ${colors.data}${dataString}${colors.reset}`;
49
+ }
50
+ //# sourceMappingURL=data-formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-formatter.js","sourceRoot":"","sources":["../../../src/formatter/data-formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAa;IACtC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,6EAA6E;QAC7E,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,UAAkB,EAAE,MAAuC;IACnF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,IAAI,MAAM,CAAC,IAAI,GAAG,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Formatter module exports
3
+ * Provides centralized access to all formatting functionality
4
+ */
5
+ export { MessageFormatter } from './message-formatter';
6
+ export { colors, colorScheme } from './colors';
7
+ export { getTimestampComponents, formatTimestamp } from './timestamp';
8
+ export { formatData, styleData } from './data-formatter';
9
+ export { MessageFormatter as LogFormatter } from './message-formatter';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Formatter module exports
3
+ * Provides centralized access to all formatting functionality
4
+ */
5
+ export { MessageFormatter } from './message-formatter.js';
6
+ export { colors, colorScheme } from './colors.js';
7
+ export { getTimestampComponents, formatTimestamp } from './timestamp.js';
8
+ export { formatData, styleData } from './data-formatter.js';
9
+ // Backward compatibility - maintain the original LogFormatter class interface
10
+ export { MessageFormatter as LogFormatter } from './message-formatter.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEzD,8EAA8E;AAC9E,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Core message formatting functionality
3
+ * Handles the main log message formatting with colors, timestamps, and levels
4
+ */
5
+ import { LogLevel, LogData } from '../types';
6
+ /**
7
+ * Core message formatter class
8
+ * Provides the main formatting functionality for log messages
9
+ */
10
+ export declare class MessageFormatter {
11
+ /**
12
+ * Formats a log message with timestamp, level indicator, and appropriate coloring
13
+ * Creates a structured log entry: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message [data]
14
+ * @param level - The log level to format for
15
+ * @param message - The message content to format
16
+ * @param data - Optional data object to include in the log output
17
+ * @returns Formatted string with ANSI colors and timestamps
18
+ */
19
+ static format(level: LogLevel, message: string, data?: LogData): string;
20
+ /**
21
+ * Formats a Log Engine system message with [LOG ENGINE] prefix instead of log levels
22
+ * Used for internal messages like deprecation warnings that should be distinguished from user logs
23
+ * @param message - The system message content to format
24
+ * @returns Formatted string with ANSI colors, timestamps, and LOG ENGINE prefix
25
+ */
26
+ static formatSystemMessage(message: string): string;
27
+ /**
28
+ * Converts LogLevel enum to human-readable string
29
+ * @param level - The LogLevel to convert
30
+ * @returns String representation of the log level
31
+ */
32
+ private static getLevelName;
33
+ /**
34
+ * Maps LogLevel to appropriate ANSI color code
35
+ * Colors help quickly identify message severity in console output
36
+ * @param level - The LogLevel to get color for
37
+ * @returns ANSI color escape sequence
38
+ */
39
+ private static getLevelColor;
40
+ }
41
+ //# sourceMappingURL=message-formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-formatter.d.ts","sourceRoot":"","sources":["../../../src/formatter/message-formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAK7C;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B;;;;;;;SAOK;IACL,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM;IAsBvE;;;;;SAKK;IACL,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAUnD;;;;SAIK;IACL,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B;;;;;SAKK;IACL,OAAO,CAAC,MAAM,CAAC,aAAa;CAU7B"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Core message formatting functionality
3
+ * Handles the main log message formatting with colors, timestamps, and levels
4
+ */
5
+ import { LogLevel } from '../types/index.js';
6
+ import { colors, colorScheme } from './colors.js';
7
+ import { getTimestampComponents, formatTimestamp } from './timestamp.js';
8
+ import { formatData, styleData } from './data-formatter.js';
9
+ /**
10
+ * Core message formatter class
11
+ * Provides the main formatting functionality for log messages
12
+ */
13
+ export class MessageFormatter {
14
+ /**
15
+ * Formats a log message with timestamp, level indicator, and appropriate coloring
16
+ * Creates a structured log entry: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message [data]
17
+ * @param level - The log level to format for
18
+ * @param message - The message content to format
19
+ * @param data - Optional data object to include in the log output
20
+ * @returns Formatted string with ANSI colors and timestamps
21
+ */
22
+ static format(level, message, data) {
23
+ const { isoTimestamp, timeString } = getTimestampComponents();
24
+ const timestamp = formatTimestamp(isoTimestamp, timeString, colorScheme);
25
+ const levelName = MessageFormatter.getLevelName(level);
26
+ const levelColor = MessageFormatter.getLevelColor(level);
27
+ const coloredLevel = `${levelColor}[${levelName}]${colors.reset}`;
28
+ // Format the base message
29
+ let formattedMessage = `${timestamp}${coloredLevel}: ${message}`;
30
+ // Append data if provided
31
+ if (data !== undefined) {
32
+ const dataString = formatData(data);
33
+ const styledData = styleData(dataString, colorScheme);
34
+ formattedMessage += styledData;
35
+ }
36
+ // Always reset colors at the end of the entire log line
37
+ return formattedMessage + colors.reset;
38
+ }
39
+ /**
40
+ * Formats a Log Engine system message with [LOG ENGINE] prefix instead of log levels
41
+ * Used for internal messages like deprecation warnings that should be distinguished from user logs
42
+ * @param message - The system message content to format
43
+ * @returns Formatted string with ANSI colors, timestamps, and LOG ENGINE prefix
44
+ */
45
+ static formatSystemMessage(message) {
46
+ const { isoTimestamp, timeString } = getTimestampComponents();
47
+ const timestamp = formatTimestamp(isoTimestamp, timeString, colorScheme);
48
+ const coloredLogEngine = `${colorScheme.system}[LOG ENGINE]${colors.reset}`;
49
+ const coloredMessage = `${colorScheme.system}${message}${colors.reset}`;
50
+ return `${timestamp}${coloredLogEngine}: ${coloredMessage}`;
51
+ }
52
+ /**
53
+ * Converts LogLevel enum to human-readable string
54
+ * @param level - The LogLevel to convert
55
+ * @returns String representation of the log level
56
+ */
57
+ static getLevelName(level) {
58
+ switch (level) {
59
+ case LogLevel.DEBUG: return 'DEBUG';
60
+ case LogLevel.INFO: return 'INFO';
61
+ case LogLevel.WARN: return 'WARN';
62
+ case LogLevel.ERROR: return 'ERROR';
63
+ case LogLevel.LOG: return 'LOG';
64
+ default: return 'UNKNOWN';
65
+ }
66
+ }
67
+ /**
68
+ * Maps LogLevel to appropriate ANSI color code
69
+ * Colors help quickly identify message severity in console output
70
+ * @param level - The LogLevel to get color for
71
+ * @returns ANSI color escape sequence
72
+ */
73
+ static getLevelColor(level) {
74
+ switch (level) {
75
+ case LogLevel.DEBUG: return colors.magenta; // Purple for debug info
76
+ case LogLevel.INFO: return colors.blue; // Blue for general info
77
+ case LogLevel.WARN: return colors.yellow; // Yellow for warnings
78
+ case LogLevel.ERROR: return colors.red; // Red for errors
79
+ case LogLevel.LOG: return colors.green; // Green for always-on log messages
80
+ default: return colors.white; // White for unknown levels
81
+ }
82
+ }
83
+ }
84
+ //# sourceMappingURL=message-formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-formatter.js","sourceRoot":"","sources":["../../../src/formatter/message-formatter.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Timestamp formatting utilities
3
+ * Handles ISO timestamp and local time formatting for log messages
4
+ */
5
+ /**
6
+ * Generates the current timestamp as both an ISO 8601 string and a compact US English local time string.
7
+ *
8
+ * @returns An object containing `isoTimestamp` (ISO 8601 format) and `timeString` (localized time string without spaces)
9
+ */
10
+ export declare function getTimestampComponents(): {
11
+ isoTimestamp: string;
12
+ timeString: string;
13
+ };
14
+ /**
15
+ * Returns a formatted string combining an ISO timestamp and a local time string, each wrapped with specified color codes for console output.
16
+ *
17
+ * @param isoTimestamp - The ISO 8601 formatted timestamp to display
18
+ * @param timeString - The local time string to display
19
+ * @param colors - An object containing color codes for the timestamp, time string, and reset sequence
20
+ * @returns The combined, colorized timestamp string suitable for log messages
21
+ */
22
+ export declare function formatTimestamp(isoTimestamp: string, timeString: string, colors: {
23
+ timestamp: string;
24
+ timeString: string;
25
+ reset: string;
26
+ }): string;
27
+ //# sourceMappingURL=timestamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timestamp.d.ts","sourceRoot":"","sources":["../../../src/formatter/timestamp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CAClB,CAaJ;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/D,MAAM,CAKR"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Timestamp formatting utilities
3
+ * Handles ISO timestamp and local time formatting for log messages
4
+ */
5
+ /**
6
+ * Generates the current timestamp as both an ISO 8601 string and a compact US English local time string.
7
+ *
8
+ * @returns An object containing `isoTimestamp` (ISO 8601 format) and `timeString` (localized time string without spaces)
9
+ */
10
+ export function getTimestampComponents() {
11
+ const now = new Date();
12
+ const isoTimestamp = now.toISOString();
13
+ const timeString = now.toLocaleTimeString('en-US', {
14
+ hour: 'numeric',
15
+ minute: '2-digit',
16
+ hour12: true
17
+ }).replace(/\s+/g, '');
18
+ return {
19
+ isoTimestamp,
20
+ timeString
21
+ };
22
+ }
23
+ /**
24
+ * Returns a formatted string combining an ISO timestamp and a local time string, each wrapped with specified color codes for console output.
25
+ *
26
+ * @param isoTimestamp - The ISO 8601 formatted timestamp to display
27
+ * @param timeString - The local time string to display
28
+ * @param colors - An object containing color codes for the timestamp, time string, and reset sequence
29
+ * @returns The combined, colorized timestamp string suitable for log messages
30
+ */
31
+ export function formatTimestamp(isoTimestamp, timeString, colors) {
32
+ const coloredTimestamp = `${colors.timestamp}[${isoTimestamp}]${colors.reset}`;
33
+ const coloredTimeString = `${colors.timeString}[${timeString}]${colors.reset}`;
34
+ return `${coloredTimestamp}${coloredTimeString}`;
35
+ }
36
+ //# sourceMappingURL=timestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../../../src/formatter/timestamp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IAIpC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,YAAY,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IACvC,MAAM,UAAU,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;QACjD,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,IAAI;KACb,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEvB,OAAO;QACL,YAAY;QACZ,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,YAAoB,EACpB,UAAkB,EAClB,MAAgE;IAEhE,MAAM,gBAAgB,GAAG,GAAG,MAAM,CAAC,SAAS,IAAI,YAAY,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/E,MAAM,iBAAiB,GAAG,GAAG,MAAM,CAAC,UAAU,IAAI,UAAU,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;IAE/E,OAAO,GAAG,gBAAgB,GAAG,iBAAiB,EAAE,CAAC;AACnD,CAAC"}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Main LogEngine module - provides a comprehensive logging solution
3
+ * with mode-based filtering, colorized output, and automatic data redaction
4
+ *
5
+ * Features a modular architecture with separate modules for:
6
+ * - Logger: Core logging functionality with environment-based configuration
7
+ * - Formatter: Message formatting with ANSI colors and timestamps
8
+ * - Redaction: Automatic sensitive data protection with customizable patterns
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
13
+ *
14
+ * // Configure logging mode
15
+ * LogEngine.configure({ mode: LogMode.DEBUG });
16
+ *
17
+ * // Log with automatic redaction
18
+ * LogEngine.info('User login', { username: 'john', password: 'secret123' });
19
+ * // Output: [2025-06-18T...][3:45PM][INFO]: User login { username: 'john', password: '[REDACTED]' }
20
+ * ```
21
+ */
22
+ import type { LoggerConfig, RedactionConfig, ILogEngineWithoutRedaction, LogData } from './types';
23
+ /**
24
+ * LogEngine - The main interface for logging operations
25
+ * Provides a simple, intuitive API for all logging needs with security-first design
26
+ */
27
+ export declare const LogEngine: {
28
+ /**
29
+ * Configure the logger with new settings
30
+ * @param config - Configuration object containing logger settings
31
+ * @example
32
+ * ```typescript
33
+ * LogEngine.configure({ mode: LogMode.PRODUCTION });
34
+ * ```
35
+ */
36
+ configure: (config: Partial<LoggerConfig>) => void;
37
+ /**
38
+ * Log a debug message with automatic data redaction
39
+ * Only shown in DEVELOPMENT mode
40
+ * @param message - The debug message to log
41
+ * @param data - Optional data object to log (sensitive data will be redacted)
42
+ * @example
43
+ * ```typescript
44
+ * LogEngine.debug('Processing user data', { userId: 123, email: 'user@example.com' });
45
+ * ```
46
+ */
47
+ debug: (message: string, data?: LogData) => void;
48
+ /**
49
+ * Log an info message with automatic data redaction
50
+ * Shown in DEVELOPMENT and PRODUCTION modes
51
+ * @param message - The info message to log
52
+ * @param data - Optional data object to log (sensitive data will be redacted)
53
+ * @example
54
+ * ```typescript
55
+ * LogEngine.info('User login successful', { username: 'john' });
56
+ * ```
57
+ */
58
+ info: (message: string, data?: LogData) => void;
59
+ /**
60
+ * Log a warning message with automatic data redaction
61
+ * Shown in DEVELOPMENT and PRODUCTION modes
62
+ * @param message - The warning message to log
63
+ * @param data - Optional data object to log (sensitive data will be redacted)
64
+ * @example
65
+ * ```typescript
66
+ * LogEngine.warn('API rate limit approaching', { requestsRemaining: 10 });
67
+ * ```
68
+ */
69
+ warn: (message: string, data?: LogData) => void;
70
+ /**
71
+ * Log an error message with automatic data redaction
72
+ * Shown in DEVELOPMENT and PRODUCTION modes
73
+ * @param message - The error message to log
74
+ * @param data - Optional data object to log (sensitive data will be redacted)
75
+ * @example
76
+ * ```typescript
77
+ * LogEngine.error('Database connection failed', { host: 'localhost', port: 5432 });
78
+ * ```
79
+ */
80
+ error: (message: string, data?: LogData) => void;
81
+ /**
82
+ * Log a critical message with automatic data redaction
83
+ * Always shown regardless of mode (except OFF)
84
+ * @param message - The critical log message to log
85
+ * @param data - Optional data object to log (sensitive data will be redacted)
86
+ * @example
87
+ * ```typescript
88
+ * LogEngine.log('Application starting', { version: '1.0.0' });
89
+ * ```
90
+ */
91
+ log: (message: string, data?: LogData) => void;
92
+ /**
93
+ * Log a debug message without redaction (use with caution)
94
+ * Bypasses automatic data redaction for debugging purposes
95
+ * @param message - The debug message to log
96
+ * @param data - Optional data object to log (no redaction applied)
97
+ */
98
+ debugRaw: (message: string, data?: LogData) => void;
99
+ /**
100
+ * Log an info message without redaction (use with caution)
101
+ * Bypasses automatic data redaction for debugging purposes
102
+ * @param message - The info message to log
103
+ * @param data - Optional data object to log (no redaction applied)
104
+ */
105
+ infoRaw: (message: string, data?: LogData) => void;
106
+ /**
107
+ * Log a warning message without redaction (use with caution)
108
+ * Bypasses automatic data redaction for debugging purposes
109
+ * @param message - The warning message to log
110
+ * @param data - Optional data object to log (no redaction applied)
111
+ */
112
+ warnRaw: (message: string, data?: LogData) => void;
113
+ /**
114
+ * Log an error message without redaction (use with caution)
115
+ * Bypasses automatic data redaction for debugging purposes
116
+ * @param message - The error message to log
117
+ * @param data - Optional data object to log (no redaction applied)
118
+ */
119
+ errorRaw: (message: string, data?: LogData) => void;
120
+ /**
121
+ * Log a critical message without redaction (use with caution)
122
+ * Bypasses automatic data redaction for debugging purposes
123
+ * @param message - The critical log message to log
124
+ * @param data - Optional data object to log (no redaction applied)
125
+ */
126
+ logRaw: (message: string, data?: LogData) => void;
127
+ /**
128
+ * Configure data redaction settings
129
+ * @param config - Partial redaction configuration to apply
130
+ */
131
+ configureRedaction: (config: Partial<RedactionConfig>) => void;
132
+ /**
133
+ * Refresh redaction configuration from environment variables
134
+ * Useful for picking up runtime environment changes
135
+ */
136
+ refreshRedactionConfig: () => void;
137
+ /**
138
+ * Reset redaction configuration to defaults
139
+ */
140
+ resetRedactionConfig: () => void;
141
+ /**
142
+ * Get current redaction configuration
143
+ * @returns Current redaction configuration
144
+ */
145
+ getRedactionConfig: () => RedactionConfig;
146
+ /**
147
+ * Add custom regex patterns for advanced field detection
148
+ * @param patterns - Array of regex patterns to add
149
+ */
150
+ addCustomRedactionPatterns: (patterns: RegExp[]) => void;
151
+ /**
152
+ * Clear all custom redaction patterns
153
+ */
154
+ clearCustomRedactionPatterns: () => void;
155
+ /**
156
+ * Add custom sensitive field names to the existing list
157
+ * @param fields - Array of field names to add
158
+ */
159
+ addSensitiveFields: (fields: string[]) => void;
160
+ /**
161
+ * Test if a field name would be redacted with current configuration
162
+ * @param fieldName - Field name to test
163
+ * @returns true if field would be redacted, false otherwise
164
+ */
165
+ testFieldRedaction: (fieldName: string) => boolean;
166
+ /**
167
+ * Temporarily disable redaction for a specific logging call
168
+ * @returns LogEngine instance with redaction bypassed
169
+ * @example
170
+ * ```typescript
171
+ * LogEngine.withoutRedaction().info('Debug data', sensitiveObject);
172
+ * ```
173
+ */
174
+ withoutRedaction: () => ILogEngineWithoutRedaction;
175
+ };
176
+ export { LogMode, LogLevel } from './types';
177
+ export type { LoggerConfig, RedactionConfig, LogOutputHandler, BuiltInOutputHandler, OutputTarget, FileOutputConfig, HttpOutputConfig, AdvancedOutputConfig, EnhancedOutputTarget } from './types';
178
+ export { DataRedactor, defaultRedactionConfig, RedactionController } from './redaction';
179
+ export default LogEngine;
180
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMlG;;;GAGG;AACH,eAAO,MAAM,SAAS;IACpB;;;;;;;SAOK;wBACe,OAAO,CAAC,YAAY,CAAC,KAAG,IAAI;IAGhD;;;;;;;;;SASK;qBACY,MAAM,SAAS,OAAO,KAAG,IAAI;IAE9C;;;;;;;;;SASK;oBACW,MAAM,SAAS,OAAO,KAAG,IAAI;IAE7C;;;;;;;;;SASK;oBACW,MAAM,SAAS,OAAO,KAAG,IAAI;IAE7C;;;;;;;;;SASK;qBACY,MAAM,SAAS,OAAO,KAAG,IAAI;IAE9C;;;;;;;;;SASK;mBACU,MAAM,SAAS,OAAO,KAAG,IAAI;IAG5C;;;;;SAKK;wBACe,MAAM,SAAS,OAAO,KAAG,IAAI;IAEjD;;;;;SAKK;uBACc,MAAM,SAAS,OAAO,KAAG,IAAI;IAEhD;;;;;SAKK;uBACc,MAAM,SAAS,OAAO,KAAG,IAAI;IAEhD;;;;;SAKK;wBACe,MAAM,SAAS,OAAO,KAAG,IAAI;IAEjD;;;;;SAKK;sBACa,MAAM,SAAS,OAAO,KAAG,IAAI;IAG/C;;;SAGK;iCACwB,OAAO,CAAC,eAAe,CAAC,KAAG,IAAI;IAE5D;;;SAGK;kCACuB,IAAI;IAEhC;;SAEK;gCACqB,IAAI;IAE9B;;;SAGK;8BACmB,eAAe;IAGvC;;;SAGK;2CACkC,MAAM,EAAE,KAAG,IAAI;IAEtD;;SAEK;wCAC6B,IAAI;IAEtC;;;SAGK;iCACwB,MAAM,EAAE,KAAG,IAAI;IAE5C;;;;SAIK;oCAC2B,MAAM,KAAG,OAAO;IAEhD;;;;;;;SAOK;4BACiB,0BAA0B;CAOjD,CAAC;AAGF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EAEZ,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGxF,eAAe,SAAS,CAAC"}