@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.
- package/LICENSE +21 -21
- package/README.md +869 -608
- package/dist/cjs/__tests__/async-test-utils.cjs +276 -0
- package/dist/cjs/__tests__/async-test-utils.d.ts +51 -0
- package/dist/cjs/__tests__/async-test-utils.d.ts.map +1 -0
- package/dist/cjs/__tests__/async-test-utils.js.map +1 -0
- package/dist/cjs/__tests__/redaction/test-utils.cjs +72 -0
- package/dist/cjs/__tests__/redaction/test-utils.d.ts +33 -0
- package/dist/cjs/__tests__/redaction/test-utils.d.ts.map +1 -0
- package/dist/cjs/__tests__/redaction/test-utils.js.map +1 -0
- package/dist/cjs/__tests__/test-utils.cjs +49 -0
- package/dist/cjs/__tests__/test-utils.d.ts +41 -0
- package/dist/cjs/__tests__/test-utils.d.ts.map +1 -0
- package/dist/cjs/__tests__/test-utils.js.map +1 -0
- package/dist/{formatter/colors.js → cjs/formatter/colors.cjs} +1 -0
- package/dist/cjs/formatter/colors.d.ts.map +1 -0
- package/dist/cjs/formatter/colors.js.map +1 -0
- package/dist/{formatter/data-formatter.js → cjs/formatter/data-formatter.cjs} +2 -1
- package/dist/{formatter → cjs/formatter}/data-formatter.d.ts +2 -1
- package/dist/cjs/formatter/data-formatter.d.ts.map +1 -0
- package/dist/cjs/formatter/data-formatter.js.map +1 -0
- package/dist/{formatter/index.js → cjs/formatter/index.cjs} +6 -5
- package/dist/cjs/formatter/index.d.ts.map +1 -0
- package/dist/cjs/formatter/index.js.map +1 -0
- package/dist/{formatter/message-formatter.js → cjs/formatter/message-formatter.cjs} +28 -27
- package/dist/cjs/formatter/message-formatter.d.ts +41 -0
- package/dist/cjs/formatter/message-formatter.d.ts.map +1 -0
- package/dist/cjs/formatter/message-formatter.js.map +1 -0
- package/dist/{formatter/timestamp.js → cjs/formatter/timestamp.cjs} +1 -0
- package/dist/cjs/formatter/timestamp.d.ts.map +1 -0
- package/dist/cjs/formatter/timestamp.js.map +1 -0
- package/dist/cjs/index.cjs +202 -0
- package/dist/cjs/index.d.ts +180 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/logger/advanced-outputs.cjs +587 -0
- package/dist/cjs/logger/advanced-outputs.d.ts +159 -0
- package/dist/cjs/logger/advanced-outputs.d.ts.map +1 -0
- package/dist/cjs/logger/advanced-outputs.js.map +1 -0
- package/dist/{logger/config.js → cjs/logger/config.cjs} +36 -32
- package/dist/cjs/logger/config.d.ts +42 -0
- package/dist/cjs/logger/config.d.ts.map +1 -0
- package/dist/cjs/logger/config.js.map +1 -0
- package/dist/cjs/logger/core.cjs +371 -0
- package/dist/cjs/logger/core.d.ts +152 -0
- package/dist/cjs/logger/core.d.ts.map +1 -0
- package/dist/cjs/logger/core.js.map +1 -0
- package/dist/{logger/environment.js → cjs/logger/environment.cjs} +17 -16
- package/dist/cjs/logger/environment.d.ts +36 -0
- package/dist/cjs/logger/environment.d.ts.map +1 -0
- package/dist/cjs/logger/environment.js.map +1 -0
- package/dist/cjs/logger/filtering.cjs +81 -0
- package/dist/cjs/logger/filtering.d.ts +36 -0
- package/dist/cjs/logger/filtering.d.ts.map +1 -0
- package/dist/cjs/logger/filtering.js.map +1 -0
- package/dist/{logger/index.js → cjs/logger/index.cjs} +6 -5
- package/dist/cjs/logger/index.d.ts.map +1 -0
- package/dist/cjs/logger/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/{redaction/config.js → cjs/redaction/config.cjs} +9 -8
- package/dist/{redaction → cjs/redaction}/config.d.ts +8 -8
- package/dist/cjs/redaction/config.d.ts.map +1 -0
- package/dist/cjs/redaction/config.js.map +1 -0
- package/dist/{redaction/index.js → cjs/redaction/index.cjs} +3 -2
- package/dist/cjs/redaction/index.d.ts.map +1 -0
- package/dist/cjs/redaction/index.js.map +1 -0
- package/dist/cjs/redaction/redactor.cjs +263 -0
- package/dist/cjs/redaction/redactor.d.ts +99 -0
- package/dist/cjs/redaction/redactor.d.ts.map +1 -0
- package/dist/cjs/redaction/redactor.js.map +1 -0
- package/dist/{types/index.js → cjs/types/index.cjs} +1 -0
- package/dist/{types → cjs/types}/index.d.ts +98 -16
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/esm/__tests__/async-test-utils.d.ts +51 -0
- package/dist/esm/__tests__/async-test-utils.d.ts.map +1 -0
- package/dist/esm/__tests__/async-test-utils.js +231 -0
- package/dist/esm/__tests__/async-test-utils.js.map +1 -0
- package/dist/esm/__tests__/redaction/test-utils.d.ts +33 -0
- package/dist/esm/__tests__/redaction/test-utils.d.ts.map +1 -0
- package/dist/esm/__tests__/redaction/test-utils.js +65 -0
- package/dist/esm/__tests__/redaction/test-utils.js.map +1 -0
- package/dist/esm/__tests__/test-utils.d.ts +41 -0
- package/dist/esm/__tests__/test-utils.d.ts.map +1 -0
- package/dist/esm/__tests__/test-utils.js +42 -0
- package/dist/esm/__tests__/test-utils.js.map +1 -0
- package/dist/esm/formatter/colors.d.ts +32 -0
- package/dist/esm/formatter/colors.d.ts.map +1 -0
- package/dist/esm/formatter/colors.js +32 -0
- package/dist/esm/formatter/colors.js.map +1 -0
- package/dist/esm/formatter/data-formatter.d.ts +26 -0
- package/dist/esm/formatter/data-formatter.d.ts.map +1 -0
- package/dist/esm/formatter/data-formatter.js +50 -0
- package/dist/esm/formatter/data-formatter.js.map +1 -0
- package/dist/esm/formatter/index.d.ts +10 -0
- package/dist/esm/formatter/index.d.ts.map +1 -0
- package/dist/esm/formatter/index.js +11 -0
- package/dist/esm/formatter/index.js.map +1 -0
- package/dist/esm/formatter/message-formatter.d.ts +41 -0
- package/dist/esm/formatter/message-formatter.d.ts.map +1 -0
- package/dist/esm/formatter/message-formatter.js +84 -0
- package/dist/esm/formatter/message-formatter.js.map +1 -0
- package/dist/esm/formatter/timestamp.d.ts +27 -0
- package/dist/esm/formatter/timestamp.d.ts.map +1 -0
- package/dist/esm/formatter/timestamp.js +36 -0
- package/dist/esm/formatter/timestamp.js.map +1 -0
- package/dist/esm/index.d.ts +180 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +194 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger/advanced-outputs.d.ts +159 -0
- package/dist/esm/logger/advanced-outputs.d.ts.map +1 -0
- package/dist/esm/logger/advanced-outputs.js +542 -0
- package/dist/esm/logger/advanced-outputs.js.map +1 -0
- package/dist/esm/logger/config.d.ts +42 -0
- package/dist/esm/logger/config.d.ts.map +1 -0
- package/dist/esm/logger/config.js +101 -0
- package/dist/esm/logger/config.js.map +1 -0
- package/dist/esm/logger/core.d.ts +152 -0
- package/dist/esm/logger/core.d.ts.map +1 -0
- package/dist/esm/logger/core.js +367 -0
- package/dist/esm/logger/core.js.map +1 -0
- package/dist/esm/logger/environment.d.ts +36 -0
- package/dist/esm/logger/environment.d.ts.map +1 -0
- package/dist/esm/logger/environment.js +58 -0
- package/dist/esm/logger/environment.js.map +1 -0
- package/dist/esm/logger/filtering.d.ts +36 -0
- package/dist/esm/logger/filtering.d.ts.map +1 -0
- package/dist/esm/logger/filtering.js +77 -0
- package/dist/esm/logger/filtering.js.map +1 -0
- package/dist/esm/logger/index.d.ts +10 -0
- package/dist/esm/logger/index.d.ts.map +1 -0
- package/dist/esm/logger/index.js +11 -0
- package/dist/esm/logger/index.js.map +1 -0
- package/dist/esm/redaction/config.d.ts +29 -0
- package/dist/esm/redaction/config.d.ts.map +1 -0
- package/dist/esm/redaction/config.js +92 -0
- package/dist/esm/redaction/config.js.map +1 -0
- package/dist/esm/redaction/index.d.ts +8 -0
- package/dist/esm/redaction/index.d.ts.map +1 -0
- package/dist/esm/redaction/index.js +7 -0
- package/dist/esm/redaction/index.js.map +1 -0
- package/dist/esm/redaction/redactor.d.ts +99 -0
- package/dist/esm/redaction/redactor.d.ts.map +1 -0
- package/dist/esm/redaction/redactor.js +259 -0
- package/dist/esm/redaction/redactor.js.map +1 -0
- package/dist/esm/types/index.d.ts +310 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +41 -0
- package/dist/esm/types/index.js.map +1 -0
- package/package.json +94 -68
- package/dist/formatter/colors.d.ts.map +0 -1
- package/dist/formatter/data-formatter.d.ts.map +0 -1
- package/dist/formatter/index.d.ts.map +0 -1
- package/dist/formatter/message-formatter.d.ts +0 -41
- package/dist/formatter/message-formatter.d.ts.map +0 -1
- package/dist/formatter/timestamp.d.ts.map +0 -1
- package/dist/index.d.ts +0 -186
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -201
- package/dist/logger/config.d.ts +0 -42
- package/dist/logger/config.d.ts.map +0 -1
- package/dist/logger/core.d.ts +0 -108
- package/dist/logger/core.d.ts.map +0 -1
- package/dist/logger/core.js +0 -185
- package/dist/logger/environment.d.ts +0 -36
- package/dist/logger/environment.d.ts.map +0 -1
- package/dist/logger/filtering.d.ts +0 -36
- package/dist/logger/filtering.d.ts.map +0 -1
- package/dist/logger/filtering.js +0 -65
- package/dist/logger/index.d.ts.map +0 -1
- package/dist/redaction/config.d.ts.map +0 -1
- package/dist/redaction/index.d.ts.map +0 -1
- package/dist/redaction/redactor.d.ts +0 -99
- package/dist/redaction/redactor.d.ts.map +0 -1
- package/dist/redaction/redactor.js +0 -257
- package/dist/types/index.d.ts.map +0 -1
- /package/dist/{formatter → cjs/formatter}/colors.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/index.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/timestamp.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/index.d.ts +0 -0
- /package/dist/{redaction → cjs/redaction}/index.d.ts +0 -0
|
@@ -0,0 +1,371 @@
|
|
|
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/index.cjs");
|
|
12
|
+
const formatter_1 = require("../formatter/index.cjs");
|
|
13
|
+
const redaction_1 = require("../redaction/index.cjs");
|
|
14
|
+
const config_1 = require("./config.cjs");
|
|
15
|
+
const filtering_1 = require("./filtering.cjs");
|
|
16
|
+
const advanced_outputs_1 = require("./advanced-outputs.cjs");
|
|
17
|
+
/**
|
|
18
|
+
* Logger class responsible for managing log output and configuration
|
|
19
|
+
* Provides mode-based filtering and formatted console output
|
|
20
|
+
*/
|
|
21
|
+
class Logger {
|
|
22
|
+
/**
|
|
23
|
+
* Logger constructor - sets up environment-based auto-configuration
|
|
24
|
+
*/
|
|
25
|
+
constructor() {
|
|
26
|
+
this.configManager = new config_1.LoggerConfigManager();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Built-in output handlers for common use cases
|
|
30
|
+
*/
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
getBuiltInHandler(type, config) {
|
|
33
|
+
switch (type) {
|
|
34
|
+
case 'console':
|
|
35
|
+
return (level, message, data) => {
|
|
36
|
+
// Use appropriate console method based on level
|
|
37
|
+
if (level === 'error') {
|
|
38
|
+
if (data !== undefined) {
|
|
39
|
+
console.error(message, data);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.error(message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (level === 'warn') {
|
|
46
|
+
if (data !== undefined) {
|
|
47
|
+
console.warn(message, data);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.warn(message);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (data !== undefined) {
|
|
55
|
+
console.log(message, data);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(message);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
case 'silent':
|
|
63
|
+
return () => {
|
|
64
|
+
// Do nothing - silent output
|
|
65
|
+
};
|
|
66
|
+
case 'file':
|
|
67
|
+
case 'http':
|
|
68
|
+
// Use advanced output handlers for file and http
|
|
69
|
+
return (0, advanced_outputs_1.createBuiltInHandler)(type, config);
|
|
70
|
+
default:
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Process a single output target with error handling
|
|
76
|
+
* @param output - Single output target to process
|
|
77
|
+
* @param level - Log level
|
|
78
|
+
* @param rawMessage - Original unformatted message
|
|
79
|
+
* @param formattedMessage - Formatted message for console-based outputs
|
|
80
|
+
* @param data - Optional data
|
|
81
|
+
* @param isEnhanced - Whether this is an enhanced output (supports configured handler objects)
|
|
82
|
+
*/
|
|
83
|
+
processSingleOutput(output, level, rawMessage, formattedMessage, data, isEnhanced = false) {
|
|
84
|
+
const config = this.configManager.getConfig();
|
|
85
|
+
try {
|
|
86
|
+
if (typeof output === 'string') {
|
|
87
|
+
// Built-in handler - get config if available
|
|
88
|
+
const outputConfig = config.advancedOutputConfig?.[output];
|
|
89
|
+
const handler = this.getBuiltInHandler(output, outputConfig);
|
|
90
|
+
if (handler) {
|
|
91
|
+
// Advanced handlers (file, http) get raw message, console gets formatted
|
|
92
|
+
const messageToUse = (output === 'file' || output === 'http') ? rawMessage : formattedMessage;
|
|
93
|
+
handler(level, messageToUse, data);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.error('[LogEngine] Unknown built-in output handler:', JSON.stringify(output));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (typeof output === 'function') {
|
|
100
|
+
// Custom function handler gets formatted message for backward compatibility
|
|
101
|
+
output(level, formattedMessage, data);
|
|
102
|
+
}
|
|
103
|
+
else if (isEnhanced && typeof output === 'object' && output.type && output.config) {
|
|
104
|
+
// Configured handler object (only available for enhanced outputs)
|
|
105
|
+
const handler = this.getBuiltInHandler(output.type, output.config);
|
|
106
|
+
if (handler) {
|
|
107
|
+
// Advanced configured handlers get raw message
|
|
108
|
+
handler(level, rawMessage, data);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
console.error('[LogEngine] Unknown enhanced output handler type:', JSON.stringify(output));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const outputType = isEnhanced ? 'enhanced output target' : 'output target';
|
|
116
|
+
console.error(`[LogEngine] Invalid ${outputType}:`, output);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
// Continue processing other outputs even if one fails
|
|
121
|
+
const handlerType = isEnhanced ? 'Enhanced output' : 'Output';
|
|
122
|
+
console.error(`[LogEngine] ${handlerType} handler failed: ${error}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Process multiple output targets
|
|
127
|
+
* @param outputs - Array of output targets to process
|
|
128
|
+
* @param level - Log level
|
|
129
|
+
* @param rawMessage - Original unformatted message
|
|
130
|
+
* @param formattedMessage - Formatted message for console-based outputs
|
|
131
|
+
* @param data - Optional data
|
|
132
|
+
*/
|
|
133
|
+
processOutputs(outputs, level, rawMessage, formattedMessage, data) {
|
|
134
|
+
for (const output of outputs) {
|
|
135
|
+
this.processSingleOutput(output, level, rawMessage, formattedMessage, data, false);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Process enhanced output targets
|
|
140
|
+
* @param enhancedOutputs - Array of enhanced output targets to process
|
|
141
|
+
* @param level - Log level
|
|
142
|
+
* @param rawMessage - Original unformatted message
|
|
143
|
+
* @param formattedMessage - Formatted message for console-based outputs
|
|
144
|
+
* @param data - Optional data
|
|
145
|
+
*/
|
|
146
|
+
processEnhancedOutputs(enhancedOutputs, level, rawMessage, formattedMessage, data) {
|
|
147
|
+
for (const output of enhancedOutputs) {
|
|
148
|
+
this.processSingleOutput(output, level, rawMessage, formattedMessage, data, true);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Updates logger configuration with new settings
|
|
153
|
+
* Also updates redaction configuration based on environment
|
|
154
|
+
* @param config - Partial configuration object to apply
|
|
155
|
+
*/
|
|
156
|
+
configure(config) {
|
|
157
|
+
this.configManager.updateConfig(config);
|
|
158
|
+
// Update redaction configuration based on current environment
|
|
159
|
+
redaction_1.DataRedactor.updateConfig({
|
|
160
|
+
...redaction_1.defaultRedactionConfig,
|
|
161
|
+
...redaction_1.RedactionController.getEnvironmentConfig()
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get current logger configuration
|
|
166
|
+
* @returns Current logger configuration
|
|
167
|
+
*/
|
|
168
|
+
getConfig() {
|
|
169
|
+
return this.configManager.getConfig();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Determines if a message should be logged based on current log mode
|
|
173
|
+
* @param level - The log level of the message to check
|
|
174
|
+
* @returns true if message should be logged, false otherwise
|
|
175
|
+
*/
|
|
176
|
+
shouldLog(level) {
|
|
177
|
+
const currentConfig = this.configManager.getConfig();
|
|
178
|
+
const currentMode = currentConfig.mode !== undefined ? currentConfig.mode : types_1.LogMode.INFO;
|
|
179
|
+
return filtering_1.LogFilter.shouldLog(level, currentMode);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Writes log output using configured output handler or default console methods
|
|
183
|
+
* Supports single output handler, multiple outputs, and enhanced outputs
|
|
184
|
+
* Priority: outputs > enhancedOutputs > outputHandler > default console
|
|
185
|
+
* @param level - The log level as a string
|
|
186
|
+
* @param rawMessage - The original unformatted message
|
|
187
|
+
* @param formattedMessage - The pre-formatted message to output
|
|
188
|
+
* @param data - Optional data object that was logged
|
|
189
|
+
* @param isError - Whether this is an error level message (for console.error)
|
|
190
|
+
* @param isWarn - Whether this is a warning level message (for console.warn)
|
|
191
|
+
*/
|
|
192
|
+
writeToOutput(level, rawMessage, formattedMessage, data, isError = false, isWarn = false) {
|
|
193
|
+
const config = this.configManager.getConfig();
|
|
194
|
+
// Multiple outputs support (highest priority - newer API)
|
|
195
|
+
if (config.outputs !== undefined) {
|
|
196
|
+
if (config.outputs.length > 0) {
|
|
197
|
+
// Process outputs array when it has actual outputs
|
|
198
|
+
this.processOutputs(config.outputs, level, rawMessage, formattedMessage, data);
|
|
199
|
+
}
|
|
200
|
+
// If outputs is explicitly set to empty array, disable all logging
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
// Enhanced outputs with advanced configuration (second priority)
|
|
204
|
+
if (config.enhancedOutputs !== undefined && config.enhancedOutputs.length > 0) {
|
|
205
|
+
this.processEnhancedOutputs(config.enhancedOutputs, level, rawMessage, formattedMessage, data);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// Single output handler (third priority - legacy compatibility)
|
|
209
|
+
if (config.outputHandler) {
|
|
210
|
+
try {
|
|
211
|
+
config.outputHandler(level, formattedMessage, data);
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
// Fallback to console if custom handler fails
|
|
215
|
+
console.error(`[LogEngine] Output handler failed: ${error}. Falling back to console.`);
|
|
216
|
+
if (isError) {
|
|
217
|
+
console.error(formattedMessage);
|
|
218
|
+
}
|
|
219
|
+
else if (isWarn) {
|
|
220
|
+
console.warn(formattedMessage);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
console.log(formattedMessage);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
// Default: Console output (unless suppressed)
|
|
229
|
+
if (!config.suppressConsoleOutput) {
|
|
230
|
+
if (isError) {
|
|
231
|
+
console.error(formattedMessage);
|
|
232
|
+
}
|
|
233
|
+
else if (isWarn) {
|
|
234
|
+
console.warn(formattedMessage);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
console.log(formattedMessage);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// If suppressConsoleOutput is true and no outputHandler/outputs, do nothing (silent)
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Log a debug message with DEBUG level formatting
|
|
244
|
+
* Uses console.log for output with purple/magenta coloring
|
|
245
|
+
* Automatically redacts sensitive data when provided
|
|
246
|
+
* @param message - The debug message to log
|
|
247
|
+
* @param data - Optional data object to log (will be redacted)
|
|
248
|
+
*/
|
|
249
|
+
debug(message, data) {
|
|
250
|
+
if (this.shouldLog(types_1.LogLevel.DEBUG)) {
|
|
251
|
+
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
252
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.DEBUG, message, processedData);
|
|
253
|
+
this.writeToOutput('debug', message, formatted, processedData);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Log an informational message with INFO level formatting
|
|
258
|
+
* Uses console.log for output with blue coloring
|
|
259
|
+
* Automatically redacts sensitive data when provided
|
|
260
|
+
* @param message - The info message to log
|
|
261
|
+
* @param data - Optional data object to log (will be redacted)
|
|
262
|
+
*/
|
|
263
|
+
info(message, data) {
|
|
264
|
+
if (this.shouldLog(types_1.LogLevel.INFO)) {
|
|
265
|
+
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
266
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.INFO, message, processedData);
|
|
267
|
+
this.writeToOutput('info', message, formatted, processedData);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Log a warning message with WARN level formatting
|
|
272
|
+
* Uses console.warn for output with yellow coloring
|
|
273
|
+
* Automatically redacts sensitive data when provided
|
|
274
|
+
* @param message - The warning message to log
|
|
275
|
+
* @param data - Optional data object to log (will be redacted)
|
|
276
|
+
*/
|
|
277
|
+
warn(message, data) {
|
|
278
|
+
if (this.shouldLog(types_1.LogLevel.WARN)) {
|
|
279
|
+
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
280
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.WARN, message, processedData);
|
|
281
|
+
this.writeToOutput('warn', message, formatted, processedData, false, true);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Log an error message with ERROR level formatting
|
|
286
|
+
* Uses console.error for output with red coloring
|
|
287
|
+
* Automatically redacts sensitive data when provided
|
|
288
|
+
* @param message - The error message to log
|
|
289
|
+
* @param data - Optional data object to log (will be redacted)
|
|
290
|
+
*/
|
|
291
|
+
error(message, data) {
|
|
292
|
+
if (this.shouldLog(types_1.LogLevel.ERROR)) {
|
|
293
|
+
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
294
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.ERROR, message, processedData);
|
|
295
|
+
this.writeToOutput('error', message, formatted, processedData, true, false);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Log a message with LOG level formatting (always outputs unless mode is OFF)
|
|
300
|
+
* Uses console.log for output with green coloring
|
|
301
|
+
* LOG level bypasses normal filtering and always outputs (except when OFF is set)
|
|
302
|
+
* Automatically redacts sensitive data when provided
|
|
303
|
+
* @param message - The log message to output
|
|
304
|
+
* @param data - Optional data object to log (will be redacted)
|
|
305
|
+
*/
|
|
306
|
+
log(message, data) {
|
|
307
|
+
if (this.shouldLog(types_1.LogLevel.LOG)) {
|
|
308
|
+
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
309
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.LOG, message, processedData);
|
|
310
|
+
this.writeToOutput('log', message, formatted, processedData);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
// Raw logging methods (bypass redaction for debugging)
|
|
314
|
+
/**
|
|
315
|
+
* Log a debug message without data redaction
|
|
316
|
+
* @param message - The debug message to log
|
|
317
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
318
|
+
*/
|
|
319
|
+
debugRaw(message, data) {
|
|
320
|
+
if (this.shouldLog(types_1.LogLevel.DEBUG)) {
|
|
321
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.DEBUG, message, data);
|
|
322
|
+
this.writeToOutput('debug', message, formatted, data);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Log an info message without data redaction
|
|
327
|
+
* @param message - The info message to log
|
|
328
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
329
|
+
*/
|
|
330
|
+
infoRaw(message, data) {
|
|
331
|
+
if (this.shouldLog(types_1.LogLevel.INFO)) {
|
|
332
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.INFO, message, data);
|
|
333
|
+
this.writeToOutput('info', message, formatted, data);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Log a warning message without data redaction
|
|
338
|
+
* @param message - The warning message to log
|
|
339
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
340
|
+
*/
|
|
341
|
+
warnRaw(message, data) {
|
|
342
|
+
if (this.shouldLog(types_1.LogLevel.WARN)) {
|
|
343
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.WARN, message, data);
|
|
344
|
+
this.writeToOutput('warn', message, formatted, data, false, true);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Log an error message without data redaction
|
|
349
|
+
* @param message - The error message to log
|
|
350
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
351
|
+
*/
|
|
352
|
+
errorRaw(message, data) {
|
|
353
|
+
if (this.shouldLog(types_1.LogLevel.ERROR)) {
|
|
354
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.ERROR, message, data);
|
|
355
|
+
this.writeToOutput('error', message, formatted, data, true, false);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Log a message without data redaction (always outputs unless mode is OFF)
|
|
360
|
+
* @param message - The log message to output
|
|
361
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
362
|
+
*/
|
|
363
|
+
logRaw(message, data) {
|
|
364
|
+
if (this.shouldLog(types_1.LogLevel.LOG)) {
|
|
365
|
+
const formatted = formatter_1.LogFormatter.format(types_1.LogLevel.LOG, message, data);
|
|
366
|
+
this.writeToOutput('log', message, formatted, data);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
exports.Logger = Logger;
|
|
371
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1,152 @@
|
|
|
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, LogData } 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
|
+
* Built-in output handlers for common use cases
|
|
21
|
+
*/
|
|
22
|
+
private getBuiltInHandler;
|
|
23
|
+
/**
|
|
24
|
+
* Process a single output target with error handling
|
|
25
|
+
* @param output - Single output target to process
|
|
26
|
+
* @param level - Log level
|
|
27
|
+
* @param rawMessage - Original unformatted message
|
|
28
|
+
* @param formattedMessage - Formatted message for console-based outputs
|
|
29
|
+
* @param data - Optional data
|
|
30
|
+
* @param isEnhanced - Whether this is an enhanced output (supports configured handler objects)
|
|
31
|
+
*/
|
|
32
|
+
private processSingleOutput;
|
|
33
|
+
/**
|
|
34
|
+
* Process multiple output targets
|
|
35
|
+
* @param outputs - Array of output targets to process
|
|
36
|
+
* @param level - Log level
|
|
37
|
+
* @param rawMessage - Original unformatted message
|
|
38
|
+
* @param formattedMessage - Formatted message for console-based outputs
|
|
39
|
+
* @param data - Optional data
|
|
40
|
+
*/
|
|
41
|
+
private processOutputs;
|
|
42
|
+
/**
|
|
43
|
+
* Process enhanced output targets
|
|
44
|
+
* @param enhancedOutputs - Array of enhanced output targets to process
|
|
45
|
+
* @param level - Log level
|
|
46
|
+
* @param rawMessage - Original unformatted message
|
|
47
|
+
* @param formattedMessage - Formatted message for console-based outputs
|
|
48
|
+
* @param data - Optional data
|
|
49
|
+
*/
|
|
50
|
+
private processEnhancedOutputs;
|
|
51
|
+
/**
|
|
52
|
+
* Updates logger configuration with new settings
|
|
53
|
+
* Also updates redaction configuration based on environment
|
|
54
|
+
* @param config - Partial configuration object to apply
|
|
55
|
+
*/
|
|
56
|
+
configure(config: Partial<LoggerConfig>): void;
|
|
57
|
+
/**
|
|
58
|
+
* Get current logger configuration
|
|
59
|
+
* @returns Current logger configuration
|
|
60
|
+
*/
|
|
61
|
+
getConfig(): LoggerConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Determines if a message should be logged based on current log mode
|
|
64
|
+
* @param level - The log level of the message to check
|
|
65
|
+
* @returns true if message should be logged, false otherwise
|
|
66
|
+
*/
|
|
67
|
+
private shouldLog;
|
|
68
|
+
/**
|
|
69
|
+
* Writes log output using configured output handler or default console methods
|
|
70
|
+
* Supports single output handler, multiple outputs, and enhanced outputs
|
|
71
|
+
* Priority: outputs > enhancedOutputs > outputHandler > default console
|
|
72
|
+
* @param level - The log level as a string
|
|
73
|
+
* @param rawMessage - The original unformatted message
|
|
74
|
+
* @param formattedMessage - The pre-formatted message to output
|
|
75
|
+
* @param data - Optional data object that was logged
|
|
76
|
+
* @param isError - Whether this is an error level message (for console.error)
|
|
77
|
+
* @param isWarn - Whether this is a warning level message (for console.warn)
|
|
78
|
+
*/
|
|
79
|
+
private writeToOutput;
|
|
80
|
+
/**
|
|
81
|
+
* Log a debug message with DEBUG level formatting
|
|
82
|
+
* Uses console.log for output with purple/magenta coloring
|
|
83
|
+
* Automatically redacts sensitive data when provided
|
|
84
|
+
* @param message - The debug message to log
|
|
85
|
+
* @param data - Optional data object to log (will be redacted)
|
|
86
|
+
*/
|
|
87
|
+
debug(message: string, data?: LogData): void;
|
|
88
|
+
/**
|
|
89
|
+
* Log an informational message with INFO level formatting
|
|
90
|
+
* Uses console.log for output with blue coloring
|
|
91
|
+
* Automatically redacts sensitive data when provided
|
|
92
|
+
* @param message - The info message to log
|
|
93
|
+
* @param data - Optional data object to log (will be redacted)
|
|
94
|
+
*/
|
|
95
|
+
info(message: string, data?: LogData): void;
|
|
96
|
+
/**
|
|
97
|
+
* Log a warning message with WARN level formatting
|
|
98
|
+
* Uses console.warn for output with yellow coloring
|
|
99
|
+
* Automatically redacts sensitive data when provided
|
|
100
|
+
* @param message - The warning message to log
|
|
101
|
+
* @param data - Optional data object to log (will be redacted)
|
|
102
|
+
*/
|
|
103
|
+
warn(message: string, data?: LogData): void;
|
|
104
|
+
/**
|
|
105
|
+
* Log an error message with ERROR level formatting
|
|
106
|
+
* Uses console.error for output with red coloring
|
|
107
|
+
* Automatically redacts sensitive data when provided
|
|
108
|
+
* @param message - The error message to log
|
|
109
|
+
* @param data - Optional data object to log (will be redacted)
|
|
110
|
+
*/
|
|
111
|
+
error(message: string, data?: LogData): void;
|
|
112
|
+
/**
|
|
113
|
+
* Log a message with LOG level formatting (always outputs unless mode is OFF)
|
|
114
|
+
* Uses console.log for output with green coloring
|
|
115
|
+
* LOG level bypasses normal filtering and always outputs (except when OFF is set)
|
|
116
|
+
* Automatically redacts sensitive data when provided
|
|
117
|
+
* @param message - The log message to output
|
|
118
|
+
* @param data - Optional data object to log (will be redacted)
|
|
119
|
+
*/
|
|
120
|
+
log(message: string, data?: LogData): void;
|
|
121
|
+
/**
|
|
122
|
+
* Log a debug message without data redaction
|
|
123
|
+
* @param message - The debug message to log
|
|
124
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
125
|
+
*/
|
|
126
|
+
debugRaw(message: string, data?: LogData): void;
|
|
127
|
+
/**
|
|
128
|
+
* Log an info message without data redaction
|
|
129
|
+
* @param message - The info message to log
|
|
130
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
131
|
+
*/
|
|
132
|
+
infoRaw(message: string, data?: LogData): void;
|
|
133
|
+
/**
|
|
134
|
+
* Log a warning message without data redaction
|
|
135
|
+
* @param message - The warning message to log
|
|
136
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
137
|
+
*/
|
|
138
|
+
warnRaw(message: string, data?: LogData): void;
|
|
139
|
+
/**
|
|
140
|
+
* Log an error message without data redaction
|
|
141
|
+
* @param message - The error message to log
|
|
142
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
143
|
+
*/
|
|
144
|
+
errorRaw(message: string, data?: LogData): void;
|
|
145
|
+
/**
|
|
146
|
+
* Log a message without data redaction (always outputs unless mode is OFF)
|
|
147
|
+
* @param message - The log message to output
|
|
148
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
149
|
+
*/
|
|
150
|
+
logRaw(message: string, data?: LogData): void;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/logger/core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAqB,YAAY,EAAwD,OAAO,EAAE,MAAM,UAAU,CAAC;AAO1H;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,aAAa,CAAsB;IAE3C;;SAEK;;IAKL;;SAEK;IAEL,OAAO,CAAC,iBAAiB;IAsCzB;;;;;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IACH,CAAC;IAED;;;;SAIK;IACL,MAAM,CAAC,OAAe,EAAE,IAAc;QACpC,IAAI,IAAI,CAAC,SAAS,CAAC,gBAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,SAAS,GAAG,wBAAY,CAAC,MAAM,CAAC,gBAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF;AA7WD,wBA6WC"}
|
|
@@ -5,22 +5,22 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.EnvironmentDetector = void 0;
|
|
8
|
-
const types_1 = require("../types");
|
|
8
|
+
const types_1 = require("../types/index.cjs");
|
|
9
9
|
/**
|
|
10
10
|
* Environment detection and configuration utilities
|
|
11
11
|
*/
|
|
12
12
|
class EnvironmentDetector {
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
* Get the normalized NODE_ENV value
|
|
15
|
+
* @returns Normalized NODE_ENV (trimmed and lowercase)
|
|
16
|
+
*/
|
|
17
17
|
static getNormalizedNodeEnv() {
|
|
18
18
|
return (process.env.NODE_ENV || '').trim().toLowerCase();
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
* Determines the appropriate log mode based on NODE_ENV
|
|
22
|
+
* @returns LogMode appropriate for current environment
|
|
23
|
+
*/
|
|
24
24
|
static getEnvironmentMode() {
|
|
25
25
|
const nodeEnv = EnvironmentDetector.getNormalizedNodeEnv();
|
|
26
26
|
switch (nodeEnv) {
|
|
@@ -37,25 +37,26 @@ class EnvironmentDetector {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
* Check if we're in a test environment
|
|
41
|
+
* @returns true if NODE_ENV is 'test'
|
|
42
|
+
*/
|
|
43
43
|
static isTestEnvironment() {
|
|
44
44
|
return EnvironmentDetector.getNormalizedNodeEnv() === 'test';
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
* Check if we're in a development environment
|
|
48
|
+
* @returns true if NODE_ENV is 'development'
|
|
49
|
+
*/
|
|
50
50
|
static isDevelopmentEnvironment() {
|
|
51
51
|
return EnvironmentDetector.getNormalizedNodeEnv() === 'development';
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
* Check if we're in a production environment
|
|
55
|
+
* @returns true if NODE_ENV is 'production'
|
|
56
|
+
*/
|
|
57
57
|
static isProductionEnvironment() {
|
|
58
58
|
return EnvironmentDetector.getNormalizedNodeEnv() === 'production';
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
exports.EnvironmentDetector = EnvironmentDetector;
|
|
62
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -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;IAC9B;;;SAGK;IACL,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC;;;SAGK;IACL,MAAM,CAAC,kBAAkB,IAAI,OAAO;IAiBpC;;;SAGK;IACL,MAAM,CAAC,iBAAiB,IAAI,OAAO;IAInC;;;SAGK;IACL,MAAM,CAAC,wBAAwB,IAAI,OAAO;IAI1C;;;SAGK;IACL,MAAM,CAAC,uBAAuB,IAAI,OAAO;CAG1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/logger/environment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,oCAAmC;AAEnC;;GAEG;AACH,MAAa,mBAAmB;IAC9B;;;SAGK;IACG,MAAM,CAAC,oBAAoB;QACjC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3D,CAAC;IAED;;;SAGK;IACL,MAA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