@wgtechlabs/log-engine 2.3.0-dev.6fe3f93 → 2.3.0-dev.aafa39c
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/README.md +2 -2
- package/dist/cjs/formatter/message-formatter.cjs +14 -2
- package/dist/cjs/formatter/message-formatter.d.ts +3 -2
- package/dist/cjs/formatter/message-formatter.d.ts.map +1 -1
- package/dist/cjs/formatter/message-formatter.js.map +1 -1
- package/dist/cjs/index.cjs +31 -15
- package/dist/cjs/index.d.ts +28 -12
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger/core.cjs +33 -22
- package/dist/cjs/logger/core.d.ts +22 -11
- package/dist/cjs/logger/core.d.ts.map +1 -1
- package/dist/cjs/logger/core.js.map +1 -1
- package/dist/cjs/types/index.d.ts +30 -15
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/formatter/message-formatter.d.ts +3 -2
- package/dist/esm/formatter/message-formatter.d.ts.map +1 -1
- package/dist/esm/formatter/message-formatter.js +14 -2
- package/dist/esm/formatter/message-formatter.js.map +1 -1
- package/dist/esm/index.d.ts +28 -12
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +31 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger/core.d.ts +22 -11
- package/dist/esm/logger/core.d.ts.map +1 -1
- package/dist/esm/logger/core.js +33 -22
- package/dist/esm/logger/core.js.map +1 -1
- package/dist/esm/types/index.d.ts +30 -15
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -592,12 +592,12 @@ EmojiSelector.configure({
|
|
|
592
592
|
|
|
593
593
|
With emoji (enabled by default), the log format is:
|
|
594
594
|
|
|
595
|
-
```
|
|
595
|
+
```text
|
|
596
596
|
[ISO_TIMESTAMP][LOCAL_TIME][LEVEL][EMOJI]: message [data]
|
|
597
597
|
```
|
|
598
598
|
|
|
599
599
|
Example:
|
|
600
|
-
```
|
|
600
|
+
```text
|
|
601
601
|
[2026-02-11T14:00:00.000Z][2:00PM][ERROR][🗃️]: Database connection failed
|
|
602
602
|
```
|
|
603
603
|
|
|
@@ -22,9 +22,10 @@ class MessageFormatter {
|
|
|
22
22
|
* @param message - The message content to format
|
|
23
23
|
* @param data - Optional data object to include in the log output
|
|
24
24
|
* @param formatConfig - Optional format configuration to control element inclusion
|
|
25
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
25
26
|
* @returns Formatted string with ANSI colors and timestamps
|
|
26
27
|
*/
|
|
27
|
-
static format(level, message, data, formatConfig) {
|
|
28
|
+
static format(level, message, data, formatConfig, options) {
|
|
28
29
|
// Merge provided format configuration with the default configuration
|
|
29
30
|
const config = {
|
|
30
31
|
...MessageFormatter.DEFAULT_FORMAT_CONFIG,
|
|
@@ -54,7 +55,18 @@ class MessageFormatter {
|
|
|
54
55
|
const levelColor = MessageFormatter.getLevelColor(level);
|
|
55
56
|
const coloredLevel = `${levelColor}[${levelName}]${colors_1.colors.reset}`;
|
|
56
57
|
// Select emoji based on context if includeEmoji is true (default)
|
|
57
|
-
|
|
58
|
+
// Use override emoji from options if provided (including empty string to suppress), otherwise use EmojiSelector
|
|
59
|
+
let emoji = '';
|
|
60
|
+
if (config.includeEmoji !== false) {
|
|
61
|
+
if (options?.emoji !== undefined) {
|
|
62
|
+
// Use override emoji (even if empty string)
|
|
63
|
+
emoji = options.emoji;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Auto-select emoji
|
|
67
|
+
emoji = emoji_selector_1.EmojiSelector.selectEmoji(level, message, data);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
58
70
|
const emojiPart = emoji ? `[${emoji}]` : '';
|
|
59
71
|
// Format the base message (level is always included as per requirements)
|
|
60
72
|
// Format: [TIMESTAMP][LEVEL][EMOJI]: message
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Core message formatting functionality
|
|
3
3
|
* Handles the main log message formatting with colors, timestamps, and levels
|
|
4
4
|
*/
|
|
5
|
-
import { LogLevel, LogData, LogFormatConfig } from '../types';
|
|
5
|
+
import { LogLevel, LogData, LogFormatConfig, LogCallOptions } from '../types';
|
|
6
6
|
/**
|
|
7
7
|
* Core message formatter class
|
|
8
8
|
* Provides the main formatting functionality for log messages
|
|
@@ -19,9 +19,10 @@ export declare class MessageFormatter {
|
|
|
19
19
|
* @param message - The message content to format
|
|
20
20
|
* @param data - Optional data object to include in the log output
|
|
21
21
|
* @param formatConfig - Optional format configuration to control element inclusion
|
|
22
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
22
23
|
* @returns Formatted string with ANSI colors and timestamps
|
|
23
24
|
*/
|
|
24
|
-
static format(level: LogLevel, message: string, data?: LogData, formatConfig?: LogFormatConfig): string;
|
|
25
|
+
static format(level: LogLevel, message: string, data?: LogData, formatConfig?: LogFormatConfig, options?: LogCallOptions): string;
|
|
25
26
|
/**
|
|
26
27
|
* Formats a Log Engine system message with [LOG ENGINE] prefix instead of log levels
|
|
27
28
|
* Used for internal messages like deprecation warnings that should be distinguished from user logs
|
|
@@ -1 +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,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
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,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM9E;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAI3C;IAEF;;;;;;;;;SASK;IACL,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;IA6DjI;;;;;;SAMK;IACL,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,MAAM;IA8BnF;;;;SAIK;IACL,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B;;;;;SAKK;IACL,OAAO,CAAC,MAAM,CAAC,aAAa;CAU7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-formatter.js","sourceRoot":"","sources":["../../../src/formatter/message-formatter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"message-formatter.js","sourceRoot":"","sources":["../../../src/formatter/message-formatter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,oCAA8E;AAC9E,qCAA+C;AAC/C,2CAAsE;AACtE,qDAAyD;AACzD,qDAAiD;AAEjD;;;GAGG;AACH,MAAa,gBAAgB;IAU3B;;;;;;;;;SASK;IACL,MAAM,CAAC,MAAM,CAAC,KAAe,EAAE,OAAe,EAAE,IAAc,EAAE,YAA8B,EAAE,OAAwB;QACtH,qEAAqE;QACrE,MAAM,MAAM,GAAoB;YAC9B,GAAG,gBAAgB,CAAC,qBAAqB;YACzC,GAAG,YAAY;SAChB,CAAC;QAEF,+EAA+E;QAC/E,oEAAoE;QACpE,uEAAuE;QAEvE,uCAAuC;QACvC,IAAI,SAAS,GAAG,EAAE,CAAC;QACnB,IAAI,MAAM,CAAC,mBAAmB,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC1D,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAA,kCAAsB,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AAC,GAAG,CAAC,CAAM,iBAAiB;YAC9D,KAAK,gBAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,eAAM,CAAC,KAAK,CAAC,CAAM,mCAAmC;YAChF,OAAO,CAAC,CAAC,OAAO,eAAM,CAAC,KAAK,CAAC,CAAgB,2BAA2B;QACxE,CAAC;IACH,CAAC;;AArJH,4CAsJC;AArJC;;GAEG;AACqB,sCAAqB,GAAoB;IAC/D,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,EAAE,IAAI;IACtB,YAAY,EAAE,IAAI;CACnB,CAAC"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -46,92 +46,107 @@ exports.LogEngine = {
|
|
|
46
46
|
* Only shown in DEVELOPMENT mode
|
|
47
47
|
* @param message - The debug message to log
|
|
48
48
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
49
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
49
50
|
* @example
|
|
50
51
|
* ```typescript
|
|
51
52
|
* LogEngine.debug('Processing user data', { userId: 123, email: 'user@example.com' });
|
|
53
|
+
* LogEngine.debug('Starting process', undefined, { emoji: '🔍' });
|
|
52
54
|
* ```
|
|
53
55
|
*/
|
|
54
|
-
debug: (message, data) => logger.debug(message, data),
|
|
56
|
+
debug: (message, data, options) => logger.debug(message, data, options),
|
|
55
57
|
/**
|
|
56
58
|
* Log an info message with automatic data redaction
|
|
57
59
|
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
58
60
|
* @param message - The info message to log
|
|
59
61
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
62
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
60
63
|
* @example
|
|
61
64
|
* ```typescript
|
|
62
65
|
* LogEngine.info('User login successful', { username: 'john' });
|
|
66
|
+
* LogEngine.info('Database initialized', undefined, { emoji: '✅' });
|
|
63
67
|
* ```
|
|
64
68
|
*/
|
|
65
|
-
info: (message, data) => logger.info(message, data),
|
|
69
|
+
info: (message, data, options) => logger.info(message, data, options),
|
|
66
70
|
/**
|
|
67
71
|
* Log a warning message with automatic data redaction
|
|
68
72
|
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
69
73
|
* @param message - The warning message to log
|
|
70
74
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
75
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
71
76
|
* @example
|
|
72
77
|
* ```typescript
|
|
73
78
|
* LogEngine.warn('API rate limit approaching', { requestsRemaining: 10 });
|
|
79
|
+
* LogEngine.warn('Low disk space', undefined, { emoji: '💾' });
|
|
74
80
|
* ```
|
|
75
81
|
*/
|
|
76
|
-
warn: (message, data) => logger.warn(message, data),
|
|
82
|
+
warn: (message, data, options) => logger.warn(message, data, options),
|
|
77
83
|
/**
|
|
78
84
|
* Log an error message with automatic data redaction
|
|
79
85
|
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
80
86
|
* @param message - The error message to log
|
|
81
87
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
88
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
82
89
|
* @example
|
|
83
90
|
* ```typescript
|
|
84
91
|
* LogEngine.error('Database connection failed', { host: 'localhost', port: 5432 });
|
|
92
|
+
* LogEngine.error('Critical failure', undefined, { emoji: '💥' });
|
|
85
93
|
* ```
|
|
86
94
|
*/
|
|
87
|
-
error: (message, data) => logger.error(message, data),
|
|
95
|
+
error: (message, data, options) => logger.error(message, data, options),
|
|
88
96
|
/**
|
|
89
97
|
* Log a critical message with automatic data redaction
|
|
90
98
|
* Always shown regardless of mode (except OFF)
|
|
91
99
|
* @param message - The critical log message to log
|
|
92
100
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
101
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
93
102
|
* @example
|
|
94
103
|
* ```typescript
|
|
95
104
|
* LogEngine.log('Application starting', { version: '1.0.0' });
|
|
105
|
+
* LogEngine.log('System ready', undefined, { emoji: '🚀' });
|
|
96
106
|
* ```
|
|
97
107
|
*/
|
|
98
|
-
log: (message, data) => logger.log(message, data),
|
|
108
|
+
log: (message, data, options) => logger.log(message, data, options),
|
|
99
109
|
// Raw methods that bypass redaction (use with caution)
|
|
100
110
|
/**
|
|
101
111
|
* Log a debug message without redaction (use with caution)
|
|
102
112
|
* Bypasses automatic data redaction for debugging purposes
|
|
103
113
|
* @param message - The debug message to log
|
|
104
114
|
* @param data - Optional data object to log (no redaction applied)
|
|
115
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
105
116
|
*/
|
|
106
|
-
debugRaw: (message, data) => logger.debugRaw(message, data),
|
|
117
|
+
debugRaw: (message, data, options) => logger.debugRaw(message, data, options),
|
|
107
118
|
/**
|
|
108
119
|
* Log an info message without redaction (use with caution)
|
|
109
120
|
* Bypasses automatic data redaction for debugging purposes
|
|
110
121
|
* @param message - The info message to log
|
|
111
122
|
* @param data - Optional data object to log (no redaction applied)
|
|
123
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
112
124
|
*/
|
|
113
|
-
infoRaw: (message, data) => logger.infoRaw(message, data),
|
|
125
|
+
infoRaw: (message, data, options) => logger.infoRaw(message, data, options),
|
|
114
126
|
/**
|
|
115
127
|
* Log a warning message without redaction (use with caution)
|
|
116
128
|
* Bypasses automatic data redaction for debugging purposes
|
|
117
129
|
* @param message - The warning message to log
|
|
118
130
|
* @param data - Optional data object to log (no redaction applied)
|
|
131
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
119
132
|
*/
|
|
120
|
-
warnRaw: (message, data) => logger.warnRaw(message, data),
|
|
133
|
+
warnRaw: (message, data, options) => logger.warnRaw(message, data, options),
|
|
121
134
|
/**
|
|
122
135
|
* Log an error message without redaction (use with caution)
|
|
123
136
|
* Bypasses automatic data redaction for debugging purposes
|
|
124
137
|
* @param message - The error message to log
|
|
125
138
|
* @param data - Optional data object to log (no redaction applied)
|
|
139
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
126
140
|
*/
|
|
127
|
-
errorRaw: (message, data) => logger.errorRaw(message, data),
|
|
141
|
+
errorRaw: (message, data, options) => logger.errorRaw(message, data, options),
|
|
128
142
|
/**
|
|
129
143
|
* Log a critical message without redaction (use with caution)
|
|
130
144
|
* Bypasses automatic data redaction for debugging purposes
|
|
131
145
|
* @param message - The critical log message to log
|
|
132
146
|
* @param data - Optional data object to log (no redaction applied)
|
|
147
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
133
148
|
*/
|
|
134
|
-
logRaw: (message, data) => logger.logRaw(message, data),
|
|
149
|
+
logRaw: (message, data, options) => logger.logRaw(message, data, options),
|
|
135
150
|
// Redaction configuration methods
|
|
136
151
|
/**
|
|
137
152
|
* Configure data redaction settings
|
|
@@ -179,14 +194,15 @@ exports.LogEngine = {
|
|
|
179
194
|
* @example
|
|
180
195
|
* ```typescript
|
|
181
196
|
* LogEngine.withoutRedaction().info('Debug data', sensitiveObject);
|
|
197
|
+
* LogEngine.withoutRedaction().info('Custom emoji', undefined, { emoji: '🔍' });
|
|
182
198
|
* ```
|
|
183
199
|
*/
|
|
184
200
|
withoutRedaction: () => ({
|
|
185
|
-
debug: (message, data) => logger.debugRaw(message, data),
|
|
186
|
-
info: (message, data) => logger.infoRaw(message, data),
|
|
187
|
-
warn: (message, data) => logger.warnRaw(message, data),
|
|
188
|
-
error: (message, data) => logger.errorRaw(message, data),
|
|
189
|
-
log: (message, data) => logger.logRaw(message, data)
|
|
201
|
+
debug: (message, data, options) => logger.debugRaw(message, data, options),
|
|
202
|
+
info: (message, data, options) => logger.infoRaw(message, data, options),
|
|
203
|
+
warn: (message, data, options) => logger.warnRaw(message, data, options),
|
|
204
|
+
error: (message, data, options) => logger.errorRaw(message, data, options),
|
|
205
|
+
log: (message, data, options) => logger.logRaw(message, data, options)
|
|
190
206
|
})
|
|
191
207
|
};
|
|
192
208
|
// Re-export types and utilities for external use
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* // Output: [2025-06-18T...][3:45PM][INFO]: User login { username: 'john', password: '[REDACTED]' }
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
import type { LoggerConfig, RedactionConfig, ILogEngineWithoutRedaction, LogData } from './types';
|
|
22
|
+
import type { LoggerConfig, RedactionConfig, ILogEngineWithoutRedaction, LogData, LogCallOptions } from './types';
|
|
23
23
|
/**
|
|
24
24
|
* LogEngine - The main interface for logging operations
|
|
25
25
|
* Provides a simple, intuitive API for all logging needs with security-first design
|
|
@@ -39,91 +39,106 @@ export declare const LogEngine: {
|
|
|
39
39
|
* Only shown in DEVELOPMENT mode
|
|
40
40
|
* @param message - The debug message to log
|
|
41
41
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
42
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
42
43
|
* @example
|
|
43
44
|
* ```typescript
|
|
44
45
|
* LogEngine.debug('Processing user data', { userId: 123, email: 'user@example.com' });
|
|
46
|
+
* LogEngine.debug('Starting process', undefined, { emoji: '🔍' });
|
|
45
47
|
* ```
|
|
46
48
|
*/
|
|
47
|
-
debug: (message: string, data?: LogData) => void;
|
|
49
|
+
debug: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
48
50
|
/**
|
|
49
51
|
* Log an info message with automatic data redaction
|
|
50
52
|
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
51
53
|
* @param message - The info message to log
|
|
52
54
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
55
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
53
56
|
* @example
|
|
54
57
|
* ```typescript
|
|
55
58
|
* LogEngine.info('User login successful', { username: 'john' });
|
|
59
|
+
* LogEngine.info('Database initialized', undefined, { emoji: '✅' });
|
|
56
60
|
* ```
|
|
57
61
|
*/
|
|
58
|
-
info: (message: string, data?: LogData) => void;
|
|
62
|
+
info: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
59
63
|
/**
|
|
60
64
|
* Log a warning message with automatic data redaction
|
|
61
65
|
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
62
66
|
* @param message - The warning message to log
|
|
63
67
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
68
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
64
69
|
* @example
|
|
65
70
|
* ```typescript
|
|
66
71
|
* LogEngine.warn('API rate limit approaching', { requestsRemaining: 10 });
|
|
72
|
+
* LogEngine.warn('Low disk space', undefined, { emoji: '💾' });
|
|
67
73
|
* ```
|
|
68
74
|
*/
|
|
69
|
-
warn: (message: string, data?: LogData) => void;
|
|
75
|
+
warn: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
70
76
|
/**
|
|
71
77
|
* Log an error message with automatic data redaction
|
|
72
78
|
* Shown in DEVELOPMENT and PRODUCTION modes
|
|
73
79
|
* @param message - The error message to log
|
|
74
80
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
81
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
75
82
|
* @example
|
|
76
83
|
* ```typescript
|
|
77
84
|
* LogEngine.error('Database connection failed', { host: 'localhost', port: 5432 });
|
|
85
|
+
* LogEngine.error('Critical failure', undefined, { emoji: '💥' });
|
|
78
86
|
* ```
|
|
79
87
|
*/
|
|
80
|
-
error: (message: string, data?: LogData) => void;
|
|
88
|
+
error: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
81
89
|
/**
|
|
82
90
|
* Log a critical message with automatic data redaction
|
|
83
91
|
* Always shown regardless of mode (except OFF)
|
|
84
92
|
* @param message - The critical log message to log
|
|
85
93
|
* @param data - Optional data object to log (sensitive data will be redacted)
|
|
94
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
86
95
|
* @example
|
|
87
96
|
* ```typescript
|
|
88
97
|
* LogEngine.log('Application starting', { version: '1.0.0' });
|
|
98
|
+
* LogEngine.log('System ready', undefined, { emoji: '🚀' });
|
|
89
99
|
* ```
|
|
90
100
|
*/
|
|
91
|
-
log: (message: string, data?: LogData) => void;
|
|
101
|
+
log: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
92
102
|
/**
|
|
93
103
|
* Log a debug message without redaction (use with caution)
|
|
94
104
|
* Bypasses automatic data redaction for debugging purposes
|
|
95
105
|
* @param message - The debug message to log
|
|
96
106
|
* @param data - Optional data object to log (no redaction applied)
|
|
107
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
97
108
|
*/
|
|
98
|
-
debugRaw: (message: string, data?: LogData) => void;
|
|
109
|
+
debugRaw: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
99
110
|
/**
|
|
100
111
|
* Log an info message without redaction (use with caution)
|
|
101
112
|
* Bypasses automatic data redaction for debugging purposes
|
|
102
113
|
* @param message - The info message to log
|
|
103
114
|
* @param data - Optional data object to log (no redaction applied)
|
|
115
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
104
116
|
*/
|
|
105
|
-
infoRaw: (message: string, data?: LogData) => void;
|
|
117
|
+
infoRaw: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
106
118
|
/**
|
|
107
119
|
* Log a warning message without redaction (use with caution)
|
|
108
120
|
* Bypasses automatic data redaction for debugging purposes
|
|
109
121
|
* @param message - The warning message to log
|
|
110
122
|
* @param data - Optional data object to log (no redaction applied)
|
|
123
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
111
124
|
*/
|
|
112
|
-
warnRaw: (message: string, data?: LogData) => void;
|
|
125
|
+
warnRaw: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
113
126
|
/**
|
|
114
127
|
* Log an error message without redaction (use with caution)
|
|
115
128
|
* Bypasses automatic data redaction for debugging purposes
|
|
116
129
|
* @param message - The error message to log
|
|
117
130
|
* @param data - Optional data object to log (no redaction applied)
|
|
131
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
118
132
|
*/
|
|
119
|
-
errorRaw: (message: string, data?: LogData) => void;
|
|
133
|
+
errorRaw: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
120
134
|
/**
|
|
121
135
|
* Log a critical message without redaction (use with caution)
|
|
122
136
|
* Bypasses automatic data redaction for debugging purposes
|
|
123
137
|
* @param message - The critical log message to log
|
|
124
138
|
* @param data - Optional data object to log (no redaction applied)
|
|
139
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
125
140
|
*/
|
|
126
|
-
logRaw: (message: string, data?: LogData) => void;
|
|
141
|
+
logRaw: (message: string, data?: LogData, options?: LogCallOptions) => void;
|
|
127
142
|
/**
|
|
128
143
|
* Configure data redaction settings
|
|
129
144
|
* @param config - Partial redaction configuration to apply
|
|
@@ -169,12 +184,13 @@ export declare const LogEngine: {
|
|
|
169
184
|
* @example
|
|
170
185
|
* ```typescript
|
|
171
186
|
* LogEngine.withoutRedaction().info('Debug data', sensitiveObject);
|
|
187
|
+
* LogEngine.withoutRedaction().info('Custom emoji', undefined, { emoji: '🔍' });
|
|
172
188
|
* ```
|
|
173
189
|
*/
|
|
174
190
|
withoutRedaction: () => ILogEngineWithoutRedaction;
|
|
175
191
|
};
|
|
176
192
|
export { LogMode, LogLevel } from './types';
|
|
177
|
-
export type { LoggerConfig, LogFormatConfig, RedactionConfig, LogOutputHandler, BuiltInOutputHandler, OutputTarget, FileOutputConfig, HttpOutputConfig, AdvancedOutputConfig, EnhancedOutputTarget, EmojiConfig, EmojiMapping } from './types';
|
|
193
|
+
export type { LoggerConfig, LogFormatConfig, RedactionConfig, LogOutputHandler, BuiltInOutputHandler, OutputTarget, LogCallOptions, FileOutputConfig, HttpOutputConfig, AdvancedOutputConfig, EnhancedOutputTarget, EmojiConfig, EmojiMapping } from './types';
|
|
178
194
|
export { DataRedactor, defaultRedactionConfig, RedactionController } from './redaction';
|
|
179
195
|
export { EmojiSelector, EMOJI_MAPPINGS, FALLBACK_EMOJI } from './formatter';
|
|
180
196
|
export default LogEngine;
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names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CACuB,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;;;;;;;;SAQK;4BACiB,0BAA0B;CAOjD,CAAC;AAGF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EACV,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EAEd,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EAEpB,WAAW,EACX,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG5E,eAAe,SAAS,CAAC"}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,qCAAkC;AAElC,2CAAmE;AAEnE,qCAAqC;AACrC,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;AAE5B;;;GAGG;AACU,QAAA,SAAS,GAAG;IACvB;;;;;;;SAOK;IACL,SAAS,EAAE,CAAC,MAA6B,EAAQ,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;IAE5E,oDAAoD;IACpD
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;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AS,CAAC"}
|
package/dist/cjs/logger/core.cjs
CHANGED
|
@@ -48,11 +48,12 @@ class Logger {
|
|
|
48
48
|
* @param level - The log level to format for
|
|
49
49
|
* @param message - The message content to format
|
|
50
50
|
* @param data - Optional data object to include in the log output
|
|
51
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
51
52
|
* @returns Formatted string with appropriate configuration applied
|
|
52
53
|
*/
|
|
53
|
-
formatMessage(level, message, data) {
|
|
54
|
+
formatMessage(level, message, data, options) {
|
|
54
55
|
const cachedConfig = this.getCachedConfig();
|
|
55
|
-
return formatter_1.LogFormatter.format(level, message, data, cachedConfig.format);
|
|
56
|
+
return formatter_1.LogFormatter.format(level, message, data, cachedConfig.format, options);
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* Built-in output handlers for common use cases
|
|
@@ -286,11 +287,12 @@ class Logger {
|
|
|
286
287
|
* Automatically redacts sensitive data when provided
|
|
287
288
|
* @param message - The debug message to log
|
|
288
289
|
* @param data - Optional data object to log (will be redacted)
|
|
290
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
289
291
|
*/
|
|
290
|
-
debug(message, data) {
|
|
292
|
+
debug(message, data, options) {
|
|
291
293
|
if (this.shouldLog(types_1.LogLevel.DEBUG)) {
|
|
292
294
|
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
293
|
-
const formatted = this.formatMessage(types_1.LogLevel.DEBUG, message, processedData);
|
|
295
|
+
const formatted = this.formatMessage(types_1.LogLevel.DEBUG, message, processedData, options);
|
|
294
296
|
this.writeToOutput('debug', message, formatted, processedData);
|
|
295
297
|
}
|
|
296
298
|
}
|
|
@@ -300,11 +302,12 @@ class Logger {
|
|
|
300
302
|
* Automatically redacts sensitive data when provided
|
|
301
303
|
* @param message - The info message to log
|
|
302
304
|
* @param data - Optional data object to log (will be redacted)
|
|
305
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
303
306
|
*/
|
|
304
|
-
info(message, data) {
|
|
307
|
+
info(message, data, options) {
|
|
305
308
|
if (this.shouldLog(types_1.LogLevel.INFO)) {
|
|
306
309
|
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
307
|
-
const formatted = this.formatMessage(types_1.LogLevel.INFO, message, processedData);
|
|
310
|
+
const formatted = this.formatMessage(types_1.LogLevel.INFO, message, processedData, options);
|
|
308
311
|
this.writeToOutput('info', message, formatted, processedData);
|
|
309
312
|
}
|
|
310
313
|
}
|
|
@@ -314,11 +317,12 @@ class Logger {
|
|
|
314
317
|
* Automatically redacts sensitive data when provided
|
|
315
318
|
* @param message - The warning message to log
|
|
316
319
|
* @param data - Optional data object to log (will be redacted)
|
|
320
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
317
321
|
*/
|
|
318
|
-
warn(message, data) {
|
|
322
|
+
warn(message, data, options) {
|
|
319
323
|
if (this.shouldLog(types_1.LogLevel.WARN)) {
|
|
320
324
|
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
321
|
-
const formatted = this.formatMessage(types_1.LogLevel.WARN, message, processedData);
|
|
325
|
+
const formatted = this.formatMessage(types_1.LogLevel.WARN, message, processedData, options);
|
|
322
326
|
this.writeToOutput('warn', message, formatted, processedData, false, true);
|
|
323
327
|
}
|
|
324
328
|
}
|
|
@@ -328,11 +332,12 @@ class Logger {
|
|
|
328
332
|
* Automatically redacts sensitive data when provided
|
|
329
333
|
* @param message - The error message to log
|
|
330
334
|
* @param data - Optional data object to log (will be redacted)
|
|
335
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
331
336
|
*/
|
|
332
|
-
error(message, data) {
|
|
337
|
+
error(message, data, options) {
|
|
333
338
|
if (this.shouldLog(types_1.LogLevel.ERROR)) {
|
|
334
339
|
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
335
|
-
const formatted = this.formatMessage(types_1.LogLevel.ERROR, message, processedData);
|
|
340
|
+
const formatted = this.formatMessage(types_1.LogLevel.ERROR, message, processedData, options);
|
|
336
341
|
this.writeToOutput('error', message, formatted, processedData, true, false);
|
|
337
342
|
}
|
|
338
343
|
}
|
|
@@ -343,11 +348,12 @@ class Logger {
|
|
|
343
348
|
* Automatically redacts sensitive data when provided
|
|
344
349
|
* @param message - The log message to output
|
|
345
350
|
* @param data - Optional data object to log (will be redacted)
|
|
351
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
346
352
|
*/
|
|
347
|
-
log(message, data) {
|
|
353
|
+
log(message, data, options) {
|
|
348
354
|
if (this.shouldLog(types_1.LogLevel.LOG)) {
|
|
349
355
|
const processedData = redaction_1.DataRedactor.redactData(data);
|
|
350
|
-
const formatted = this.formatMessage(types_1.LogLevel.LOG, message, processedData);
|
|
356
|
+
const formatted = this.formatMessage(types_1.LogLevel.LOG, message, processedData, options);
|
|
351
357
|
this.writeToOutput('log', message, formatted, processedData);
|
|
352
358
|
}
|
|
353
359
|
}
|
|
@@ -356,10 +362,11 @@ class Logger {
|
|
|
356
362
|
* Log a debug message without data redaction
|
|
357
363
|
* @param message - The debug message to log
|
|
358
364
|
* @param data - Optional data object to log (no redaction applied)
|
|
365
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
359
366
|
*/
|
|
360
|
-
debugRaw(message, data) {
|
|
367
|
+
debugRaw(message, data, options) {
|
|
361
368
|
if (this.shouldLog(types_1.LogLevel.DEBUG)) {
|
|
362
|
-
const formatted = this.formatMessage(types_1.LogLevel.DEBUG, message, data);
|
|
369
|
+
const formatted = this.formatMessage(types_1.LogLevel.DEBUG, message, data, options);
|
|
363
370
|
this.writeToOutput('debug', message, formatted, data);
|
|
364
371
|
}
|
|
365
372
|
}
|
|
@@ -367,10 +374,11 @@ class Logger {
|
|
|
367
374
|
* Log an info message without data redaction
|
|
368
375
|
* @param message - The info message to log
|
|
369
376
|
* @param data - Optional data object to log (no redaction applied)
|
|
377
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
370
378
|
*/
|
|
371
|
-
infoRaw(message, data) {
|
|
379
|
+
infoRaw(message, data, options) {
|
|
372
380
|
if (this.shouldLog(types_1.LogLevel.INFO)) {
|
|
373
|
-
const formatted = this.formatMessage(types_1.LogLevel.INFO, message, data);
|
|
381
|
+
const formatted = this.formatMessage(types_1.LogLevel.INFO, message, data, options);
|
|
374
382
|
this.writeToOutput('info', message, formatted, data);
|
|
375
383
|
}
|
|
376
384
|
}
|
|
@@ -378,10 +386,11 @@ class Logger {
|
|
|
378
386
|
* Log a warning message without data redaction
|
|
379
387
|
* @param message - The warning message to log
|
|
380
388
|
* @param data - Optional data object to log (no redaction applied)
|
|
389
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
381
390
|
*/
|
|
382
|
-
warnRaw(message, data) {
|
|
391
|
+
warnRaw(message, data, options) {
|
|
383
392
|
if (this.shouldLog(types_1.LogLevel.WARN)) {
|
|
384
|
-
const formatted = this.formatMessage(types_1.LogLevel.WARN, message, data);
|
|
393
|
+
const formatted = this.formatMessage(types_1.LogLevel.WARN, message, data, options);
|
|
385
394
|
this.writeToOutput('warn', message, formatted, data, false, true);
|
|
386
395
|
}
|
|
387
396
|
}
|
|
@@ -389,10 +398,11 @@ class Logger {
|
|
|
389
398
|
* Log an error message without data redaction
|
|
390
399
|
* @param message - The error message to log
|
|
391
400
|
* @param data - Optional data object to log (no redaction applied)
|
|
401
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
392
402
|
*/
|
|
393
|
-
errorRaw(message, data) {
|
|
403
|
+
errorRaw(message, data, options) {
|
|
394
404
|
if (this.shouldLog(types_1.LogLevel.ERROR)) {
|
|
395
|
-
const formatted = this.formatMessage(types_1.LogLevel.ERROR, message, data);
|
|
405
|
+
const formatted = this.formatMessage(types_1.LogLevel.ERROR, message, data, options);
|
|
396
406
|
this.writeToOutput('error', message, formatted, data, true, false);
|
|
397
407
|
}
|
|
398
408
|
}
|
|
@@ -400,10 +410,11 @@ class Logger {
|
|
|
400
410
|
* Log a message without data redaction (always outputs unless mode is OFF)
|
|
401
411
|
* @param message - The log message to output
|
|
402
412
|
* @param data - Optional data object to log (no redaction applied)
|
|
413
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
403
414
|
*/
|
|
404
|
-
logRaw(message, data) {
|
|
415
|
+
logRaw(message, data, options) {
|
|
405
416
|
if (this.shouldLog(types_1.LogLevel.LOG)) {
|
|
406
|
-
const formatted = this.formatMessage(types_1.LogLevel.LOG, message, data);
|
|
417
|
+
const formatted = this.formatMessage(types_1.LogLevel.LOG, message, data, options);
|
|
407
418
|
this.writeToOutput('log', message, formatted, data);
|
|
408
419
|
}
|
|
409
420
|
}
|