@wgtechlabs/log-engine 2.1.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/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} +1 -0
- 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} +5 -4
- 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/{index.js → cjs/index.cjs} +5 -4
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/{logger/advanced-outputs.js → cjs/logger/advanced-outputs.cjs} +1 -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} +4 -3
- package/dist/cjs/logger/config.d.ts.map +1 -0
- package/dist/cjs/logger/config.js.map +1 -0
- package/dist/{logger/core.js → cjs/logger/core.cjs} +7 -6
- 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} +2 -1
- package/dist/cjs/logger/environment.d.ts.map +1 -0
- package/dist/cjs/logger/environment.js.map +1 -0
- package/dist/{logger/filtering.js → cjs/logger/filtering.cjs} +2 -1
- 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} +1 -0
- 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/{redaction/redactor.js → cjs/redaction/redactor.cjs} +2 -1
- 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/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 +19 -5
- 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.map +0 -1
- package/dist/formatter/timestamp.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logger/advanced-outputs.d.ts.map +0 -1
- package/dist/logger/config.d.ts.map +0 -1
- package/dist/logger/core.d.ts.map +0 -1
- package/dist/logger/environment.d.ts.map +0 -1
- package/dist/logger/filtering.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- /package/dist/{formatter → cjs/formatter}/colors.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/data-formatter.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/index.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/message-formatter.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/timestamp.d.ts +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{logger → cjs/logger}/advanced-outputs.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/config.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/core.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/environment.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/filtering.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/index.d.ts +0 -0
- /package/dist/{redaction → cjs/redaction}/config.d.ts +0 -0
- /package/dist/{redaction → cjs/redaction}/index.d.ts +0 -0
- /package/dist/{redaction → cjs/redaction}/redactor.d.ts +0 -0
- /package/dist/{types → cjs/types}/index.d.ts +0 -0
|
@@ -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":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAW,MAAM,UAAU,CAAC;AAC7C,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;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;;;;;SAOK;IACL,MAAM,CAAC,MAAM,CAAC,KAAe,EAAE,OAAe,EAAE,IAAc;QAC5D,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,sBAAsB,EAAE,CAAC;QAC9D,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAEzE,MAAM,SAAS,GAAG,gBAAgB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACvD,MAAM,UAAU,GAAG,gBAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,YAAY,GAAG,GAAG,UAAU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,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC;YAChC,OAAO,CAAC,CAAC,OAAO,SAAS,CAAC;QAC1B,CAAC;IACH,CAAC;IAED;;;;;SAKK;IACG,MAAM,CAAC,aAAa,CAAC,KAAe;QAC1C,QAAQ,KAAK,EAAE,CAAC;YAChB,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAE,wBAAwB;YACrE,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAM,wBAAwB;YACrE,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAI,sBAAsB;YACnE,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAM,iBAAiB;YAC9D,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAM,mCAAmC;YAChF,OAAO,CAAC,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAgB,2BAA2B;QACxE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,194 @@
|
|
|
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 { Logger } from './logger/index.js';
|
|
23
|
+
import { DataRedactor, defaultRedactionConfig } from './redaction/index.js';
|
|
24
|
+
// Create a singleton logger instance
|
|
25
|
+
const logger = new Logger();
|
|
26
|
+
/**
|
|
27
|
+
* LogEngine - The main interface for logging operations
|
|
28
|
+
* Provides a simple, intuitive API for all logging needs with security-first design
|
|
29
|
+
*/
|
|
30
|
+
export const LogEngine = {
|
|
31
|
+
/**
|
|
32
|
+
* Configure the logger with new settings
|
|
33
|
+
* @param config - Configuration object containing logger settings
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* LogEngine.configure({ mode: LogMode.PRODUCTION });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
configure: (config) => logger.configure(config),
|
|
40
|
+
// Standard logging methods with automatic redaction
|
|
41
|
+
/**
|
|
42
|
+
* Log a debug message with automatic data redaction
|
|
43
|
+
* Only shown in DEVELOPMENT mode
|
|
44
|
+
* @param message - The debug message to log
|
|
45
|
+
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* LogEngine.debug('Processing user data', { userId: 123, email: 'user@example.com' });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
debug: (message, data) => logger.debug(message, data),
|
|
52
|
+
/**
|
|
53
|
+
* Log an info message with automatic data redaction
|
|
54
|
+
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
55
|
+
* @param message - The info message to log
|
|
56
|
+
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* LogEngine.info('User login successful', { username: 'john' });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
info: (message, data) => logger.info(message, data),
|
|
63
|
+
/**
|
|
64
|
+
* Log a warning message with automatic data redaction
|
|
65
|
+
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
66
|
+
* @param message - The warning message to log
|
|
67
|
+
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* LogEngine.warn('API rate limit approaching', { requestsRemaining: 10 });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
warn: (message, data) => logger.warn(message, data),
|
|
74
|
+
/**
|
|
75
|
+
* Log an error message with automatic data redaction
|
|
76
|
+
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
77
|
+
* @param message - The error message to log
|
|
78
|
+
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* LogEngine.error('Database connection failed', { host: 'localhost', port: 5432 });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
error: (message, data) => logger.error(message, data),
|
|
85
|
+
/**
|
|
86
|
+
* Log a critical message with automatic data redaction
|
|
87
|
+
* Always shown regardless of mode (except OFF)
|
|
88
|
+
* @param message - The critical log message to log
|
|
89
|
+
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* LogEngine.log('Application starting', { version: '1.0.0' });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
log: (message, data) => logger.log(message, data),
|
|
96
|
+
// Raw methods that bypass redaction (use with caution)
|
|
97
|
+
/**
|
|
98
|
+
* Log a debug message without redaction (use with caution)
|
|
99
|
+
* Bypasses automatic data redaction for debugging purposes
|
|
100
|
+
* @param message - The debug message to log
|
|
101
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
102
|
+
*/
|
|
103
|
+
debugRaw: (message, data) => logger.debugRaw(message, data),
|
|
104
|
+
/**
|
|
105
|
+
* Log an info message without redaction (use with caution)
|
|
106
|
+
* Bypasses automatic data redaction for debugging purposes
|
|
107
|
+
* @param message - The info message to log
|
|
108
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
109
|
+
*/
|
|
110
|
+
infoRaw: (message, data) => logger.infoRaw(message, data),
|
|
111
|
+
/**
|
|
112
|
+
* Log a warning message without redaction (use with caution)
|
|
113
|
+
* Bypasses automatic data redaction for debugging purposes
|
|
114
|
+
* @param message - The warning message to log
|
|
115
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
116
|
+
*/
|
|
117
|
+
warnRaw: (message, data) => logger.warnRaw(message, data),
|
|
118
|
+
/**
|
|
119
|
+
* Log an error message without redaction (use with caution)
|
|
120
|
+
* Bypasses automatic data redaction for debugging purposes
|
|
121
|
+
* @param message - The error message to log
|
|
122
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
123
|
+
*/
|
|
124
|
+
errorRaw: (message, data) => logger.errorRaw(message, data),
|
|
125
|
+
/**
|
|
126
|
+
* Log a critical message without redaction (use with caution)
|
|
127
|
+
* Bypasses automatic data redaction for debugging purposes
|
|
128
|
+
* @param message - The critical log message to log
|
|
129
|
+
* @param data - Optional data object to log (no redaction applied)
|
|
130
|
+
*/
|
|
131
|
+
logRaw: (message, data) => logger.logRaw(message, data),
|
|
132
|
+
// Redaction configuration methods
|
|
133
|
+
/**
|
|
134
|
+
* Configure data redaction settings
|
|
135
|
+
* @param config - Partial redaction configuration to apply
|
|
136
|
+
*/
|
|
137
|
+
configureRedaction: (config) => DataRedactor.updateConfig(config),
|
|
138
|
+
/**
|
|
139
|
+
* Refresh redaction configuration from environment variables
|
|
140
|
+
* Useful for picking up runtime environment changes
|
|
141
|
+
*/
|
|
142
|
+
refreshRedactionConfig: () => DataRedactor.refreshConfig(),
|
|
143
|
+
/**
|
|
144
|
+
* Reset redaction configuration to defaults
|
|
145
|
+
*/
|
|
146
|
+
resetRedactionConfig: () => DataRedactor.updateConfig(defaultRedactionConfig),
|
|
147
|
+
/**
|
|
148
|
+
* Get current redaction configuration
|
|
149
|
+
* @returns Current redaction configuration
|
|
150
|
+
*/
|
|
151
|
+
getRedactionConfig: () => DataRedactor.getConfig(),
|
|
152
|
+
// Advanced redaction methods
|
|
153
|
+
/**
|
|
154
|
+
* Add custom regex patterns for advanced field detection
|
|
155
|
+
* @param patterns - Array of regex patterns to add
|
|
156
|
+
*/
|
|
157
|
+
addCustomRedactionPatterns: (patterns) => DataRedactor.addCustomPatterns(patterns),
|
|
158
|
+
/**
|
|
159
|
+
* Clear all custom redaction patterns
|
|
160
|
+
*/
|
|
161
|
+
clearCustomRedactionPatterns: () => DataRedactor.clearCustomPatterns(),
|
|
162
|
+
/**
|
|
163
|
+
* Add custom sensitive field names to the existing list
|
|
164
|
+
* @param fields - Array of field names to add
|
|
165
|
+
*/
|
|
166
|
+
addSensitiveFields: (fields) => DataRedactor.addSensitiveFields(fields),
|
|
167
|
+
/**
|
|
168
|
+
* Test if a field name would be redacted with current configuration
|
|
169
|
+
* @param fieldName - Field name to test
|
|
170
|
+
* @returns true if field would be redacted, false otherwise
|
|
171
|
+
*/
|
|
172
|
+
testFieldRedaction: (fieldName) => DataRedactor.testFieldRedaction(fieldName),
|
|
173
|
+
/**
|
|
174
|
+
* Temporarily disable redaction for a specific logging call
|
|
175
|
+
* @returns LogEngine instance with redaction bypassed
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* LogEngine.withoutRedaction().info('Debug data', sensitiveObject);
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
withoutRedaction: () => ({
|
|
182
|
+
debug: (message, data) => logger.debugRaw(message, data),
|
|
183
|
+
info: (message, data) => logger.infoRaw(message, data),
|
|
184
|
+
warn: (message, data) => logger.warnRaw(message, data),
|
|
185
|
+
error: (message, data) => logger.errorRaw(message, data),
|
|
186
|
+
log: (message, data) => logger.logRaw(message, data)
|
|
187
|
+
})
|
|
188
|
+
};
|
|
189
|
+
// Re-export types and utilities for external use
|
|
190
|
+
export { LogMode, LogLevel } from './types/index.js';
|
|
191
|
+
export { DataRedactor, defaultRedactionConfig, RedactionController } from './redaction/index.js';
|
|
192
|
+
// Default export for convenience
|
|
193
|
+
export default LogEngine;
|
|
194
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEnE,qCAAqC;AACrC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AAE5B;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;;;;;;SAOK;IACL,SAAS,EAAE,CAAC,MAA6B,EAAQ,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;IAE5E,oDAAoD;IACpD;;;;;;;;;SASK;IACL,KAAK,EAAE,CAAC,OAAe,EAAE,IAAc,EAAQ,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;IAE7E;;;;;;;;;SASK;IACL,IAAI,EAAE,CAAC,OAAe,EAAE,IAAc,EAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;IAE3E;;;;;;;;;SASK;IACL,IAAI,EAAE,CAAC,OAAe,EAAE,IAAc,EAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC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