@wgtechlabs/log-engine 2.2.2 → 2.3.0-dev.8fdf09c
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 +234 -37
- package/dist/cjs/formatter/emoji-data.cjs +87 -0
- package/dist/cjs/formatter/emoji-data.d.ts +18 -0
- package/dist/cjs/formatter/emoji-data.d.ts.map +1 -0
- package/dist/cjs/formatter/emoji-data.js.map +1 -0
- package/dist/cjs/formatter/emoji-selector.cjs +209 -0
- package/dist/cjs/formatter/emoji-selector.d.ts +74 -0
- package/dist/cjs/formatter/emoji-selector.d.ts.map +1 -0
- package/dist/cjs/formatter/emoji-selector.js.map +1 -0
- package/dist/cjs/formatter/index.cjs +6 -1
- package/dist/cjs/formatter/index.d.ts +2 -0
- package/dist/cjs/formatter/index.d.ts.map +1 -1
- package/dist/cjs/formatter/index.js.map +1 -1
- package/dist/cjs/formatter/message-formatter.cjs +24 -3
- 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 +36 -16
- package/dist/cjs/index.d.ts +29 -12
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger/core.cjs +43 -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 +59 -15
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/formatter/emoji-data.d.ts +18 -0
- package/dist/esm/formatter/emoji-data.d.ts.map +1 -0
- package/dist/esm/formatter/emoji-data.js +84 -0
- package/dist/esm/formatter/emoji-data.js.map +1 -0
- package/dist/esm/formatter/emoji-selector.d.ts +74 -0
- package/dist/esm/formatter/emoji-selector.d.ts.map +1 -0
- package/dist/esm/formatter/emoji-selector.js +205 -0
- package/dist/esm/formatter/emoji-selector.js.map +1 -0
- package/dist/esm/formatter/index.d.ts +2 -0
- package/dist/esm/formatter/index.d.ts.map +1 -1
- package/dist/esm/formatter/index.js +2 -0
- package/dist/esm/formatter/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 +24 -3
- package/dist/esm/formatter/message-formatter.js.map +1 -1
- package/dist/esm/index.d.ts +29 -12
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +32 -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 +44 -23
- package/dist/esm/logger/core.js.map +1 -1
- package/dist/esm/types/index.d.ts +59 -15
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Emoji selector for context-aware logging
|
|
4
|
+
* Analyzes log messages to select appropriate emoji based on context
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.EmojiSelector = void 0;
|
|
8
|
+
const types_1 = require("../types/index.cjs");
|
|
9
|
+
const emoji_data_1 = require("./emoji-data.cjs");
|
|
10
|
+
/**
|
|
11
|
+
* Emoji selector class
|
|
12
|
+
* Provides context-aware emoji selection for log messages
|
|
13
|
+
*/
|
|
14
|
+
class EmojiSelector {
|
|
15
|
+
/**
|
|
16
|
+
* Configure the emoji selector
|
|
17
|
+
* @param config - Configuration options
|
|
18
|
+
*/
|
|
19
|
+
static configure(config) {
|
|
20
|
+
EmojiSelector.config = {
|
|
21
|
+
...EmojiSelector.config,
|
|
22
|
+
...config
|
|
23
|
+
};
|
|
24
|
+
// Invalidate compiled cache when config changes
|
|
25
|
+
EmojiSelector.compiledMappings = null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get current configuration
|
|
29
|
+
* @returns Current emoji configuration
|
|
30
|
+
*/
|
|
31
|
+
static getConfig() {
|
|
32
|
+
const { customMappings = [], customFallbacks = {}, ...rest } = EmojiSelector.config;
|
|
33
|
+
return {
|
|
34
|
+
...rest,
|
|
35
|
+
customMappings: [...customMappings],
|
|
36
|
+
customFallbacks: { ...customFallbacks }
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Reset configuration to defaults
|
|
41
|
+
*/
|
|
42
|
+
static reset() {
|
|
43
|
+
EmojiSelector.config = {
|
|
44
|
+
customMappings: [],
|
|
45
|
+
customFallbacks: {},
|
|
46
|
+
useCustomOnly: false
|
|
47
|
+
};
|
|
48
|
+
// Clear compiled cache
|
|
49
|
+
EmojiSelector.compiledMappings = null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get compiled emoji mappings with precompiled regex patterns
|
|
53
|
+
* This is cached to avoid recompiling regex on every log line
|
|
54
|
+
*/
|
|
55
|
+
static getCompiledMappings() {
|
|
56
|
+
if (EmojiSelector.compiledMappings) {
|
|
57
|
+
return EmojiSelector.compiledMappings;
|
|
58
|
+
}
|
|
59
|
+
const { customMappings = [], useCustomOnly } = EmojiSelector.config;
|
|
60
|
+
const mappings = useCustomOnly ? customMappings : [...customMappings, ...emoji_data_1.EMOJI_MAPPINGS];
|
|
61
|
+
EmojiSelector.compiledMappings = mappings.map(mapping => ({
|
|
62
|
+
...mapping,
|
|
63
|
+
regexes: mapping.keywords.map(keyword => {
|
|
64
|
+
// Escape regex metacharacters to prevent ReDoS and invalid patterns
|
|
65
|
+
const escapedKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
66
|
+
// Precompile regex for performance
|
|
67
|
+
// eslint-disable-next-line security/detect-non-literal-regexp -- Safe: keyword is escaped above to prevent ReDoS
|
|
68
|
+
return new RegExp(`\\b${escapedKeyword}\\b`, 'i');
|
|
69
|
+
})
|
|
70
|
+
}));
|
|
71
|
+
return EmojiSelector.compiledMappings;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Select appropriate emoji based on log level and message content
|
|
75
|
+
* @param level - Log level
|
|
76
|
+
* @param message - Log message
|
|
77
|
+
* @param data - Optional log data
|
|
78
|
+
* @returns Selected emoji or empty string
|
|
79
|
+
*/
|
|
80
|
+
static selectEmoji(level, message, data) {
|
|
81
|
+
// Try to find context-aware emoji
|
|
82
|
+
const contextEmoji = EmojiSelector.findContextEmoji(message, data);
|
|
83
|
+
if (contextEmoji) {
|
|
84
|
+
return contextEmoji;
|
|
85
|
+
}
|
|
86
|
+
// Fall back to level-based emoji
|
|
87
|
+
return EmojiSelector.getFallbackEmoji(level);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Find emoji based on message and data context
|
|
91
|
+
* @param message - Log message
|
|
92
|
+
* @param data - Optional log data
|
|
93
|
+
* @returns Emoji if match found, null otherwise
|
|
94
|
+
*/
|
|
95
|
+
static findContextEmoji(message, data) {
|
|
96
|
+
const searchText = EmojiSelector.prepareSearchText(message, data);
|
|
97
|
+
const compiledMappings = EmojiSelector.getCompiledMappings();
|
|
98
|
+
// Search through compiled mappings for keyword matches
|
|
99
|
+
for (const mapping of compiledMappings) {
|
|
100
|
+
if (EmojiSelector.matchesWithCompiledRegexes(searchText, mapping.regexes)) {
|
|
101
|
+
return mapping.emoji;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Prepare text for searching by combining message and data
|
|
108
|
+
* @param message - Log message
|
|
109
|
+
* @param data - Optional log data
|
|
110
|
+
* @returns Lowercase combined text
|
|
111
|
+
*/
|
|
112
|
+
static prepareSearchText(message, data) {
|
|
113
|
+
let text = message.toLowerCase();
|
|
114
|
+
// If data is provided and is an object, include only keys for analysis
|
|
115
|
+
// Avoid expensive JSON.stringify on full object to optimize performance
|
|
116
|
+
if (data && typeof data === 'object') {
|
|
117
|
+
try {
|
|
118
|
+
const keys = Object.keys(data).join(' ').toLowerCase();
|
|
119
|
+
text += ' ' + keys;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Ignore circular references or stringify errors
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (data && typeof data === 'string') {
|
|
126
|
+
text += ' ' + data.toLowerCase();
|
|
127
|
+
}
|
|
128
|
+
return text;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Check if search text matches any of the precompiled regexes
|
|
132
|
+
* @param searchText - Lowercase text to search in
|
|
133
|
+
* @param regexes - Precompiled regex patterns
|
|
134
|
+
* @returns true if any regex matches
|
|
135
|
+
*/
|
|
136
|
+
static matchesWithCompiledRegexes(searchText, regexes) {
|
|
137
|
+
return regexes.some(regex => regex.test(searchText));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get fallback emoji for a given log level
|
|
141
|
+
* @param level - Log level
|
|
142
|
+
* @returns Fallback emoji for the level
|
|
143
|
+
*/
|
|
144
|
+
static getFallbackEmoji(level) {
|
|
145
|
+
const levelName = EmojiSelector.getLevelName(level);
|
|
146
|
+
// Explicitly handle unknown levels: no emoji by default
|
|
147
|
+
if (levelName === 'UNKNOWN') {
|
|
148
|
+
return '';
|
|
149
|
+
}
|
|
150
|
+
const { customFallbacks = {} } = EmojiSelector.config;
|
|
151
|
+
// Check custom fallbacks first using safe property access
|
|
152
|
+
if (Object.prototype.hasOwnProperty.call(customFallbacks, levelName)) {
|
|
153
|
+
switch (levelName) {
|
|
154
|
+
case 'DEBUG':
|
|
155
|
+
return customFallbacks.DEBUG || '';
|
|
156
|
+
case 'INFO':
|
|
157
|
+
return customFallbacks.INFO || '';
|
|
158
|
+
case 'WARN':
|
|
159
|
+
return customFallbacks.WARN || '';
|
|
160
|
+
case 'ERROR':
|
|
161
|
+
return customFallbacks.ERROR || '';
|
|
162
|
+
case 'LOG':
|
|
163
|
+
return customFallbacks.LOG || '';
|
|
164
|
+
default:
|
|
165
|
+
// levelName is type-constrained, but default defensively returns empty
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Use default fallback with explicit switch
|
|
170
|
+
switch (levelName) {
|
|
171
|
+
case 'DEBUG':
|
|
172
|
+
return emoji_data_1.FALLBACK_EMOJI.DEBUG;
|
|
173
|
+
case 'INFO':
|
|
174
|
+
return emoji_data_1.FALLBACK_EMOJI.INFO;
|
|
175
|
+
case 'WARN':
|
|
176
|
+
return emoji_data_1.FALLBACK_EMOJI.WARN;
|
|
177
|
+
case 'ERROR':
|
|
178
|
+
return emoji_data_1.FALLBACK_EMOJI.ERROR;
|
|
179
|
+
case 'LOG':
|
|
180
|
+
return emoji_data_1.FALLBACK_EMOJI.LOG;
|
|
181
|
+
default:
|
|
182
|
+
return '';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Convert LogLevel enum to string
|
|
187
|
+
* @param level - Log level
|
|
188
|
+
* @returns Level name as string
|
|
189
|
+
*/
|
|
190
|
+
static getLevelName(level) {
|
|
191
|
+
switch (level) {
|
|
192
|
+
case types_1.LogLevel.DEBUG: return 'DEBUG';
|
|
193
|
+
case types_1.LogLevel.INFO: return 'INFO';
|
|
194
|
+
case types_1.LogLevel.WARN: return 'WARN';
|
|
195
|
+
case types_1.LogLevel.ERROR: return 'ERROR';
|
|
196
|
+
case types_1.LogLevel.LOG: return 'LOG';
|
|
197
|
+
default: return 'UNKNOWN';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.EmojiSelector = EmojiSelector;
|
|
202
|
+
EmojiSelector.config = {
|
|
203
|
+
customMappings: [],
|
|
204
|
+
customFallbacks: {},
|
|
205
|
+
useCustomOnly: false
|
|
206
|
+
};
|
|
207
|
+
// Cache for precompiled regex patterns
|
|
208
|
+
EmojiSelector.compiledMappings = null;
|
|
209
|
+
//# sourceMappingURL=emoji-selector.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emoji selector for context-aware logging
|
|
3
|
+
* Analyzes log messages to select appropriate emoji based on context
|
|
4
|
+
*/
|
|
5
|
+
import { LogLevel, LogData, EmojiConfig } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Emoji selector class
|
|
8
|
+
* Provides context-aware emoji selection for log messages
|
|
9
|
+
*/
|
|
10
|
+
export declare class EmojiSelector {
|
|
11
|
+
private static config;
|
|
12
|
+
private static compiledMappings;
|
|
13
|
+
/**
|
|
14
|
+
* Configure the emoji selector
|
|
15
|
+
* @param config - Configuration options
|
|
16
|
+
*/
|
|
17
|
+
static configure(config: Partial<EmojiConfig>): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get current configuration
|
|
20
|
+
* @returns Current emoji configuration
|
|
21
|
+
*/
|
|
22
|
+
static getConfig(): EmojiConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Reset configuration to defaults
|
|
25
|
+
*/
|
|
26
|
+
static reset(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get compiled emoji mappings with precompiled regex patterns
|
|
29
|
+
* This is cached to avoid recompiling regex on every log line
|
|
30
|
+
*/
|
|
31
|
+
private static getCompiledMappings;
|
|
32
|
+
/**
|
|
33
|
+
* Select appropriate emoji based on log level and message content
|
|
34
|
+
* @param level - Log level
|
|
35
|
+
* @param message - Log message
|
|
36
|
+
* @param data - Optional log data
|
|
37
|
+
* @returns Selected emoji or empty string
|
|
38
|
+
*/
|
|
39
|
+
static selectEmoji(level: LogLevel, message: string, data?: LogData): string;
|
|
40
|
+
/**
|
|
41
|
+
* Find emoji based on message and data context
|
|
42
|
+
* @param message - Log message
|
|
43
|
+
* @param data - Optional log data
|
|
44
|
+
* @returns Emoji if match found, null otherwise
|
|
45
|
+
*/
|
|
46
|
+
private static findContextEmoji;
|
|
47
|
+
/**
|
|
48
|
+
* Prepare text for searching by combining message and data
|
|
49
|
+
* @param message - Log message
|
|
50
|
+
* @param data - Optional log data
|
|
51
|
+
* @returns Lowercase combined text
|
|
52
|
+
*/
|
|
53
|
+
private static prepareSearchText;
|
|
54
|
+
/**
|
|
55
|
+
* Check if search text matches any of the precompiled regexes
|
|
56
|
+
* @param searchText - Lowercase text to search in
|
|
57
|
+
* @param regexes - Precompiled regex patterns
|
|
58
|
+
* @returns true if any regex matches
|
|
59
|
+
*/
|
|
60
|
+
private static matchesWithCompiledRegexes;
|
|
61
|
+
/**
|
|
62
|
+
* Get fallback emoji for a given log level
|
|
63
|
+
* @param level - Log level
|
|
64
|
+
* @returns Fallback emoji for the level
|
|
65
|
+
*/
|
|
66
|
+
private static getFallbackEmoji;
|
|
67
|
+
/**
|
|
68
|
+
* Convert LogLevel enum to string
|
|
69
|
+
* @param level - Log level
|
|
70
|
+
* @returns Level name as string
|
|
71
|
+
*/
|
|
72
|
+
private static getLevelName;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=emoji-selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emoji-selector.d.ts","sourceRoot":"","sources":["../../../src/formatter/emoji-selector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAc1D;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,MAAM,CAInB;IAGF,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAuC;IAEtE;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IASpD;;;OAGG;IACH,MAAM,CAAC,SAAS,IAAI,WAAW;IAU/B;;OAEG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;IAUpB;;;OAGG;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C5B;gBACE,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,YAAY,CAAC,KAAe;QACzC,QAAQ,KAAK,EAAE,CAAC;YAChB,KAAK,gBAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC;YACpC,KAAK,gBAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC;YAClC,KAAK,gBAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC;YAClC,KAAK,gBAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC;YACpC,KAAK,gBAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC;YAChC,OAAO,CAAC,CAAC,OAAO,SAAS,CAAC;QAC1B,CAAC;IACH,CAAC;;AAtNH,sCAuNC;AAtNgB,oBAAM,GAAgB;IACnC,cAAc,EAAE,EAAE;IAClB,eAAe,EAAE,EAAE;IACnB,aAAa,EAAE,KAAK;CACrB,CAAC;AAEF,uCAAuC;AACxB,8BAAgB,GAAkC,IAAI,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides centralized access to all formatting functionality
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.LogFormatter = exports.styleData = exports.formatData = exports.formatTimestamp = exports.getTimestampComponents = exports.colorScheme = exports.colors = exports.MessageFormatter = void 0;
|
|
7
|
+
exports.LogFormatter = exports.FALLBACK_EMOJI = exports.EMOJI_MAPPINGS = exports.EmojiSelector = exports.styleData = exports.formatData = exports.formatTimestamp = exports.getTimestampComponents = exports.colorScheme = exports.colors = exports.MessageFormatter = void 0;
|
|
8
8
|
var message_formatter_1 = require("./message-formatter.cjs");
|
|
9
9
|
Object.defineProperty(exports, "MessageFormatter", { enumerable: true, get: function () { return message_formatter_1.MessageFormatter; } });
|
|
10
10
|
var colors_1 = require("./colors.cjs");
|
|
@@ -16,6 +16,11 @@ Object.defineProperty(exports, "formatTimestamp", { enumerable: true, get: funct
|
|
|
16
16
|
var data_formatter_1 = require("./data-formatter.cjs");
|
|
17
17
|
Object.defineProperty(exports, "formatData", { enumerable: true, get: function () { return data_formatter_1.formatData; } });
|
|
18
18
|
Object.defineProperty(exports, "styleData", { enumerable: true, get: function () { return data_formatter_1.styleData; } });
|
|
19
|
+
var emoji_selector_1 = require("./emoji-selector.cjs");
|
|
20
|
+
Object.defineProperty(exports, "EmojiSelector", { enumerable: true, get: function () { return emoji_selector_1.EmojiSelector; } });
|
|
21
|
+
var emoji_data_1 = require("./emoji-data.cjs");
|
|
22
|
+
Object.defineProperty(exports, "EMOJI_MAPPINGS", { enumerable: true, get: function () { return emoji_data_1.EMOJI_MAPPINGS; } });
|
|
23
|
+
Object.defineProperty(exports, "FALLBACK_EMOJI", { enumerable: true, get: function () { return emoji_data_1.FALLBACK_EMOJI; } });
|
|
19
24
|
// Backward compatibility - maintain the original LogFormatter class interface
|
|
20
25
|
var message_formatter_2 = require("./message-formatter.cjs");
|
|
21
26
|
Object.defineProperty(exports, "LogFormatter", { enumerable: true, get: function () { return message_formatter_2.MessageFormatter; } });
|
|
@@ -6,5 +6,7 @@ export { MessageFormatter } from './message-formatter';
|
|
|
6
6
|
export { colors, colorScheme } from './colors';
|
|
7
7
|
export { getTimestampComponents, formatTimestamp } from './timestamp';
|
|
8
8
|
export { formatData, styleData } from './data-formatter';
|
|
9
|
+
export { EmojiSelector } from './emoji-selector';
|
|
10
|
+
export { EMOJI_MAPPINGS, FALLBACK_EMOJI } from './emoji-data';
|
|
9
11
|
export { MessageFormatter as LogFormatter } from './message-formatter';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,mCAA+C;AAAtC,gGAAA,MAAM,OAAA;AAAE,qGAAA,WAAW,OAAA;AAC5B,yCAAsE;AAA7D,mHAAA,sBAAsB,OAAA;AAAE,4GAAA,eAAe,OAAA;AAChD,mDAAyD;AAAhD,4GAAA,UAAU,OAAA;AAAE,2GAAA,SAAS,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,mCAA+C;AAAtC,gGAAA,MAAM,OAAA;AAAE,qGAAA,WAAW,OAAA;AAC5B,yCAAsE;AAA7D,mHAAA,sBAAsB,OAAA;AAAE,4GAAA,eAAe,OAAA;AAChD,mDAAyD;AAAhD,4GAAA,UAAU,OAAA;AAAE,2GAAA,SAAS,OAAA;AAC9B,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,2CAA8D;AAArD,4GAAA,cAAc,OAAA;AAAE,4GAAA,cAAc,OAAA;AAEvC,8EAA8E;AAC9E,yDAAuE;AAA9D,iHAAA,gBAAgB,OAAgB"}
|
|
@@ -9,6 +9,7 @@ const types_1 = require("../types/index.cjs");
|
|
|
9
9
|
const colors_1 = require("./colors.cjs");
|
|
10
10
|
const timestamp_1 = require("./timestamp.cjs");
|
|
11
11
|
const data_formatter_1 = require("./data-formatter.cjs");
|
|
12
|
+
const emoji_selector_1 = require("./emoji-selector.cjs");
|
|
12
13
|
/**
|
|
13
14
|
* Core message formatter class
|
|
14
15
|
* Provides the main formatting functionality for log messages
|
|
@@ -21,14 +22,18 @@ class MessageFormatter {
|
|
|
21
22
|
* @param message - The message content to format
|
|
22
23
|
* @param data - Optional data object to include in the log output
|
|
23
24
|
* @param formatConfig - Optional format configuration to control element inclusion
|
|
25
|
+
* @param options - Optional per-call options (e.g., emoji override)
|
|
24
26
|
* @returns Formatted string with ANSI colors and timestamps
|
|
25
27
|
*/
|
|
26
|
-
static format(level, message, data, formatConfig) {
|
|
28
|
+
static format(level, message, data, formatConfig, options) {
|
|
27
29
|
// Merge provided format configuration with the default configuration
|
|
28
30
|
const config = {
|
|
29
31
|
...MessageFormatter.DEFAULT_FORMAT_CONFIG,
|
|
30
32
|
...formatConfig
|
|
31
33
|
};
|
|
34
|
+
// Note: EmojiSelector configuration is handled at the Logger.configure() level
|
|
35
|
+
// to avoid invalidating the compiled regex cache on every log call.
|
|
36
|
+
// This preserves the performance optimization of regex precompilation.
|
|
32
37
|
// Build timestamp string conditionally
|
|
33
38
|
let timestamp = '';
|
|
34
39
|
if (config.includeIsoTimestamp || config.includeLocalTime) {
|
|
@@ -49,8 +54,23 @@ class MessageFormatter {
|
|
|
49
54
|
const levelName = MessageFormatter.getLevelName(level);
|
|
50
55
|
const levelColor = MessageFormatter.getLevelColor(level);
|
|
51
56
|
const coloredLevel = `${levelColor}[${levelName}]${colors_1.colors.reset}`;
|
|
57
|
+
// Select emoji based on context if includeEmoji is true (default)
|
|
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
|
+
}
|
|
70
|
+
const emojiPart = emoji ? `[${emoji}]` : '';
|
|
52
71
|
// Format the base message (level is always included as per requirements)
|
|
53
|
-
|
|
72
|
+
// Format: [TIMESTAMP][LEVEL][EMOJI]: message
|
|
73
|
+
let formattedMessage = `${timestamp}${coloredLevel}${emojiPart}: ${message}`;
|
|
54
74
|
// Append data if provided
|
|
55
75
|
if (data !== undefined) {
|
|
56
76
|
const dataString = (0, data_formatter_1.formatData)(data);
|
|
@@ -132,6 +152,7 @@ exports.MessageFormatter = MessageFormatter;
|
|
|
132
152
|
*/
|
|
133
153
|
MessageFormatter.DEFAULT_FORMAT_CONFIG = {
|
|
134
154
|
includeIsoTimestamp: true,
|
|
135
|
-
includeLocalTime: true
|
|
155
|
+
includeLocalTime: true,
|
|
156
|
+
includeEmoji: true
|
|
136
157
|
};
|
|
137
158
|
//# sourceMappingURL=message-formatter.js.map
|
|
@@ -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,GAAE,CAAC;YAE9D,IAAI,MAAM,CAAC,mBAAmB,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;gBAC1D,2BAA2B;gBAC3B,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AM,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
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.RedactionController = exports.defaultRedactionConfig = exports.DataRedactor = exports.LogLevel = exports.LogMode = exports.LogEngine = void 0;
|
|
24
|
+
exports.FALLBACK_EMOJI = exports.EMOJI_MAPPINGS = exports.EmojiSelector = exports.RedactionController = exports.defaultRedactionConfig = exports.DataRedactor = exports.LogLevel = exports.LogMode = exports.LogEngine = void 0;
|
|
25
25
|
const logger_1 = require("./logger/index.cjs");
|
|
26
26
|
const redaction_1 = require("./redaction/index.cjs");
|
|
27
27
|
// Create a singleton logger instance
|
|
@@ -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
|
|
@@ -197,6 +213,10 @@ var redaction_2 = require("./redaction/index.cjs");
|
|
|
197
213
|
Object.defineProperty(exports, "DataRedactor", { enumerable: true, get: function () { return redaction_2.DataRedactor; } });
|
|
198
214
|
Object.defineProperty(exports, "defaultRedactionConfig", { enumerable: true, get: function () { return redaction_2.defaultRedactionConfig; } });
|
|
199
215
|
Object.defineProperty(exports, "RedactionController", { enumerable: true, get: function () { return redaction_2.RedactionController; } });
|
|
216
|
+
var formatter_1 = require("./formatter/index.cjs");
|
|
217
|
+
Object.defineProperty(exports, "EmojiSelector", { enumerable: true, get: function () { return formatter_1.EmojiSelector; } });
|
|
218
|
+
Object.defineProperty(exports, "EMOJI_MAPPINGS", { enumerable: true, get: function () { return formatter_1.EMOJI_MAPPINGS; } });
|
|
219
|
+
Object.defineProperty(exports, "FALLBACK_EMOJI", { enumerable: true, get: function () { return formatter_1.FALLBACK_EMOJI; } });
|
|
200
220
|
// Default export for convenience
|
|
201
221
|
exports.default = exports.LogEngine;
|
|
202
222
|
//# sourceMappingURL=index.js.map
|