@wgtechlabs/log-engine 1.2.0 → 1.3.0

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 (52) hide show
  1. package/README.md +283 -18
  2. package/dist/formatter/colors.d.ts +32 -0
  3. package/dist/formatter/colors.d.ts.map +1 -0
  4. package/dist/formatter/colors.js +34 -0
  5. package/dist/formatter/data-formatter.d.ts +25 -0
  6. package/dist/formatter/data-formatter.d.ts.map +1 -0
  7. package/dist/formatter/data-formatter.js +53 -0
  8. package/dist/formatter/index.d.ts +10 -0
  9. package/dist/formatter/index.d.ts.map +1 -0
  10. package/dist/formatter/index.js +21 -0
  11. package/dist/formatter/message-formatter.d.ts +41 -0
  12. package/dist/formatter/message-formatter.d.ts.map +1 -0
  13. package/dist/formatter/message-formatter.js +87 -0
  14. package/dist/formatter/timestamp.d.ts +27 -0
  15. package/dist/formatter/timestamp.d.ts.map +1 -0
  16. package/dist/formatter/timestamp.js +39 -0
  17. package/dist/formatter.d.ts +10 -2
  18. package/dist/formatter.d.ts.map +1 -1
  19. package/dist/formatter.js +42 -5
  20. package/dist/index.d.ts +143 -41
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +155 -71
  23. package/dist/logger/config.d.ts +42 -0
  24. package/dist/logger/config.d.ts.map +1 -0
  25. package/dist/logger/config.js +101 -0
  26. package/dist/logger/core.d.ts +108 -0
  27. package/dist/logger/core.d.ts.map +1 -0
  28. package/dist/logger/core.js +185 -0
  29. package/dist/logger/environment.d.ts +36 -0
  30. package/dist/logger/environment.d.ts.map +1 -0
  31. package/dist/logger/environment.js +61 -0
  32. package/dist/logger/filtering.d.ts +36 -0
  33. package/dist/logger/filtering.d.ts.map +1 -0
  34. package/dist/logger/filtering.js +65 -0
  35. package/dist/logger/index.d.ts +10 -0
  36. package/dist/logger/index.d.ts.map +1 -0
  37. package/dist/logger/index.js +18 -0
  38. package/dist/logger.d.ts +61 -5
  39. package/dist/logger.d.ts.map +1 -1
  40. package/dist/logger.js +117 -10
  41. package/dist/redaction/config.d.ts +29 -0
  42. package/dist/redaction/config.d.ts.map +1 -0
  43. package/dist/redaction/config.js +95 -0
  44. package/dist/redaction/index.d.ts +8 -0
  45. package/dist/redaction/index.d.ts.map +1 -0
  46. package/dist/redaction/index.js +12 -0
  47. package/dist/redaction/redactor.d.ts +99 -0
  48. package/dist/redaction/redactor.d.ts.map +1 -0
  49. package/dist/redaction/redactor.js +257 -0
  50. package/dist/types/index.d.ts +164 -0
  51. package/dist/types/index.d.ts.map +1 -1
  52. package/package.json +11 -4
@@ -0,0 +1,185 @@
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;
@@ -0,0 +1,36 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Environment detection utilities for logging configuration
4
+ * Handles automatic environment-based configuration
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.EnvironmentDetector = void 0;
8
+ const types_1 = require("../types");
9
+ /**
10
+ * Environment detection and configuration utilities
11
+ */
12
+ class EnvironmentDetector {
13
+ /**
14
+ * Get the normalized NODE_ENV value
15
+ * @returns Normalized NODE_ENV (trimmed and lowercase)
16
+ */
17
+ static getNormalizedNodeEnv() {
18
+ return (process.env.NODE_ENV || '').trim().toLowerCase();
19
+ }
20
+ /**
21
+ * Determines the appropriate log mode based on NODE_ENV
22
+ * @returns LogMode appropriate for current environment
23
+ */
24
+ static getEnvironmentMode() {
25
+ const nodeEnv = EnvironmentDetector.getNormalizedNodeEnv();
26
+ switch (nodeEnv) {
27
+ case 'development':
28
+ return types_1.LogMode.DEBUG; // Verbose logging for development
29
+ case 'production':
30
+ return types_1.LogMode.INFO; // Important info and above for production
31
+ case 'staging':
32
+ return types_1.LogMode.WARN; // Focused logging for staging
33
+ case 'test':
34
+ return types_1.LogMode.ERROR; // Minimal logging during tests
35
+ default:
36
+ return types_1.LogMode.INFO; // Default fallback for unknown environments
37
+ }
38
+ }
39
+ /**
40
+ * Check if we're in a test environment
41
+ * @returns true if NODE_ENV is 'test'
42
+ */
43
+ static isTestEnvironment() {
44
+ return EnvironmentDetector.getNormalizedNodeEnv() === 'test';
45
+ }
46
+ /**
47
+ * Check if we're in a development environment
48
+ * @returns true if NODE_ENV is 'development'
49
+ */
50
+ static isDevelopmentEnvironment() {
51
+ return EnvironmentDetector.getNormalizedNodeEnv() === 'development';
52
+ }
53
+ /**
54
+ * Check if we're in a production environment
55
+ * @returns true if NODE_ENV is 'production'
56
+ */
57
+ static isProductionEnvironment() {
58
+ return EnvironmentDetector.getNormalizedNodeEnv() === 'production';
59
+ }
60
+ }
61
+ exports.EnvironmentDetector = EnvironmentDetector;
@@ -0,0 +1,36 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,65 @@
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
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Logger module exports
3
+ * Provides centralized access to all logging functionality
4
+ */
5
+ export { Logger } from './core';
6
+ export { LoggerConfigManager } from './config';
7
+ export { LogFilter } from './filtering';
8
+ export { EnvironmentDetector } from './environment';
9
+ export { Logger as CoreLogger } from './core';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * Logger module exports
4
+ * Provides centralized access to all logging functionality
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.CoreLogger = exports.EnvironmentDetector = exports.LogFilter = exports.LoggerConfigManager = exports.Logger = void 0;
8
+ var core_1 = require("./core");
9
+ Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return core_1.Logger; } });
10
+ var config_1 = require("./config");
11
+ Object.defineProperty(exports, "LoggerConfigManager", { enumerable: true, get: function () { return config_1.LoggerConfigManager; } });
12
+ var filtering_1 = require("./filtering");
13
+ Object.defineProperty(exports, "LogFilter", { enumerable: true, get: function () { return filtering_1.LogFilter; } });
14
+ var environment_1 = require("./environment");
15
+ Object.defineProperty(exports, "EnvironmentDetector", { enumerable: true, get: function () { return environment_1.EnvironmentDetector; } });
16
+ // Backward compatibility - maintain the original Logger class interface
17
+ var core_2 = require("./core");
18
+ Object.defineProperty(exports, "CoreLogger", { enumerable: true, get: function () { return core_2.Logger; } });
package/dist/logger.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Supports DEBUG, INFO, WARN, ERROR, and LOG levels with intelligent filtering
4
4
  * LOG level always outputs regardless of configuration
5
5
  * Uses colorized console output with timestamps for better readability
6
+ * Includes automatic data redaction for sensitive information
6
7
  */
7
8
  import { LoggerConfig } from './types';
8
9
  /**
@@ -11,10 +12,20 @@ import { LoggerConfig } from './types';
11
12
  */
12
13
  export declare class Logger {
13
14
  private config;
15
+ /**
16
+ * Logger constructor - sets up environment-based auto-configuration
17
+ */
18
+ constructor();
19
+ /**
20
+ * Determines the appropriate log mode based on NODE_ENV
21
+ * @returns LogMode appropriate for current environment
22
+ */
23
+ private getEnvironmentMode;
14
24
  /**
15
25
  * Updates logger configuration with new settings
16
26
  * Merges provided config with existing settings (partial update)
17
27
  * Supports backwards compatibility by mapping level to mode with deprecation warnings
28
+ * Also updates redaction configuration based on environment
18
29
  * @param config - Partial configuration object to apply
19
30
  */
20
31
  configure(config: Partial<LoggerConfig>): void;
@@ -40,33 +51,78 @@ export declare class Logger {
40
51
  /**
41
52
  * Log a debug message with DEBUG level formatting
42
53
  * Uses console.log for output with purple/magenta coloring
54
+ * Automatically redacts sensitive data when provided
43
55
  * @param message - The debug message to log
56
+ * @param data - Optional data object to log (will be redacted)
44
57
  */
45
- debug(message: string): void;
58
+ debug(message: string, data?: any): void;
46
59
  /**
47
60
  * Log an informational message with INFO level formatting
48
61
  * Uses console.log for output with blue coloring
62
+ * Automatically redacts sensitive data when provided
49
63
  * @param message - The info message to log
64
+ * @param data - Optional data object to log (will be redacted)
50
65
  */
51
- info(message: string): void;
66
+ info(message: string, data?: any): void;
52
67
  /**
53
68
  * Log a warning message with WARN level formatting
54
69
  * Uses console.warn for output with yellow coloring
70
+ * Automatically redacts sensitive data when provided
55
71
  * @param message - The warning message to log
72
+ * @param data - Optional data object to log (will be redacted)
56
73
  */
57
- warn(message: string): void;
74
+ warn(message: string, data?: any): void;
58
75
  /**
59
76
  * Log an error message with ERROR level formatting
60
77
  * Uses console.error for output with red coloring
78
+ * Automatically redacts sensitive data when provided
61
79
  * @param message - The error message to log
80
+ * @param data - Optional data object to log (will be redacted)
62
81
  */
63
- error(message: string): void;
82
+ error(message: string, data?: any): void;
64
83
  /**
65
84
  * Log a critical message that always outputs (LOG level)
66
85
  * Uses console.log for output with green coloring
67
86
  * Always shown regardless of configured log level
87
+ * Automatically redacts sensitive data when provided
88
+ * @param message - The critical log message to log
89
+ * @param data - Optional data object to log (will be redacted)
90
+ */
91
+ log(message: string, data?: any): 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?: any): 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?: any): 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?: any): 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?: any): void;
120
+ /**
121
+ * Log a critical message without redaction (use with caution)
122
+ * Bypasses automatic data redaction for debugging purposes
68
123
  * @param message - The critical log message to log
124
+ * @param data - Optional data object to log (no redaction applied)
69
125
  */
70
- log(message: string): void;
126
+ logRaw(message: string, data?: any): void;
71
127
  }
72
128
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D;;;GAGG;AACH,qBAAa,MAAM;IAEf,OAAO,CAAC,MAAM,CAEZ;IAEF;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAmC9C;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAMpC;IAEF;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAOrC;IAEF;;;;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