@mks2508/better-logger 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/package.json +1 -1
- package/src/terminal/terminal-renderer.ts +12 -4
- package/src/utils/stackTrace.ts +54 -5
- package/bun.lock +0 -333
- package/dist/Logger.d.ts +0 -704
- package/dist/Logger.d.ts.map +0 -1
- package/dist/ScopedLogger.d.ts +0 -310
- package/dist/ScopedLogger.d.ts.map +0 -1
- package/dist/chunks/Logger-BynuRJQf.js +0 -3503
- package/dist/chunks/Logger-BynuRJQf.js.map +0 -1
- package/dist/chunks/Logger-DMjlVQWi.js +0 -2
- package/dist/chunks/Logger-DMjlVQWi.js.map +0 -1
- package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +0 -33
- package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +0 -1
- package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +0 -2
- package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +0 -1
- package/dist/chunks/ScopedLogger-Bl56WovH.js +0 -361
- package/dist/chunks/ScopedLogger-Bl56WovH.js.map +0 -1
- package/dist/chunks/ScopedLogger-D2HzayKH.js +0 -2
- package/dist/chunks/ScopedLogger-D2HzayKH.js.map +0 -1
- package/dist/chunks/environment--eaTrhRu.js +0 -4
- package/dist/chunks/environment--eaTrhRu.js.map +0 -1
- package/dist/chunks/environment-BanAyF-K.js +0 -1172
- package/dist/chunks/environment-BanAyF-K.js.map +0 -1
- package/dist/chunks/formatting-BSNvAxLK.js +0 -2
- package/dist/chunks/formatting-BSNvAxLK.js.map +0 -1
- package/dist/chunks/formatting-CgQSWgXR.js +0 -380
- package/dist/chunks/formatting-CgQSWgXR.js.map +0 -1
- package/dist/cli/CommandProcessor.d.ts +0 -100
- package/dist/cli/CommandProcessor.d.ts.map +0 -1
- package/dist/cli/commands/ConfigCommand.d.ts +0 -14
- package/dist/cli/commands/ConfigCommand.d.ts.map +0 -1
- package/dist/cli/commands/ExportCommand.d.ts +0 -48
- package/dist/cli/commands/ExportCommand.d.ts.map +0 -1
- package/dist/cli/commands/HistoryCommand.d.ts +0 -47
- package/dist/cli/commands/HistoryCommand.d.ts.map +0 -1
- package/dist/cli/commands/StatusCommand.d.ts +0 -30
- package/dist/cli/commands/StatusCommand.d.ts.map +0 -1
- package/dist/cli/commands/ThemeCommand.d.ts +0 -30
- package/dist/cli/commands/ThemeCommand.d.ts.map +0 -1
- package/dist/cli/help.d.ts +0 -12
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/index.d.ts +0 -15
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/constants.d.ts +0 -227
- package/dist/constants.d.ts.map +0 -1
- package/dist/core.cjs +0 -2
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.ts +0 -127
- package/dist/core.d.ts.map +0 -1
- package/dist/core.js +0 -291
- package/dist/core.js.map +0 -1
- package/dist/example.d.ts +0 -18
- package/dist/example.d.ts.map +0 -1
- package/dist/exports-module.d.ts +0 -196
- package/dist/exports-module.d.ts.map +0 -1
- package/dist/exports.cjs +0 -2
- package/dist/exports.cjs.map +0 -1
- package/dist/exports.js +0 -238
- package/dist/exports.js.map +0 -1
- package/dist/handlers/AnalyticsLogHandler.d.ts +0 -8
- package/dist/handlers/AnalyticsLogHandler.d.ts.map +0 -1
- package/dist/handlers/ExportLogHandler.d.ts +0 -100
- package/dist/handlers/ExportLogHandler.d.ts.map +0 -1
- package/dist/handlers/FileLogHandler.d.ts +0 -33
- package/dist/handlers/FileLogHandler.d.ts.map +0 -1
- package/dist/handlers/RemoteLogHandler.d.ts +0 -11
- package/dist/handlers/RemoteLogHandler.d.ts.map +0 -1
- package/dist/handlers/index.d.ts +0 -8
- package/dist/handlers/index.d.ts.map +0 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -124
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -247
- package/dist/index.js.map +0 -1
- package/dist/main.d.ts +0 -2
- package/dist/main.d.ts.map +0 -1
- package/dist/styling/LogStyleBuilder.d.ts +0 -146
- package/dist/styling/LogStyleBuilder.d.ts.map +0 -1
- package/dist/styling/SemanticStyles.d.ts +0 -178
- package/dist/styling/SemanticStyles.d.ts.map +0 -1
- package/dist/styling/SmartPresets.d.ts +0 -22
- package/dist/styling/SmartPresets.d.ts.map +0 -1
- package/dist/styling/StyleBuilder.d.ts +0 -140
- package/dist/styling/StyleBuilder.d.ts.map +0 -1
- package/dist/styling/banners.d.ts +0 -42
- package/dist/styling/banners.d.ts.map +0 -1
- package/dist/styling/index.d.ts +0 -10
- package/dist/styling/index.d.ts.map +0 -1
- package/dist/styling/themes.d.ts +0 -7
- package/dist/styling/themes.d.ts.map +0 -1
- package/dist/styling-module.d.ts +0 -178
- package/dist/styling-module.d.ts.map +0 -1
- package/dist/styling.cjs +0 -2
- package/dist/styling.cjs.map +0 -1
- package/dist/styling.js +0 -146
- package/dist/styling.js.map +0 -1
- package/dist/terminal/terminal-renderer.d.ts +0 -63
- package/dist/terminal/terminal-renderer.d.ts.map +0 -1
- package/dist/types/core.d.ts +0 -234
- package/dist/types/core.d.ts.map +0 -1
- package/dist/types/handlers.d.ts +0 -85
- package/dist/types/handlers.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/adapter.d.ts +0 -48
- package/dist/utils/adapter.d.ts.map +0 -1
- package/dist/utils/ansi-colors.d.ts +0 -156
- package/dist/utils/ansi-colors.d.ts.map +0 -1
- package/dist/utils/environment-detector.d.ts +0 -35
- package/dist/utils/environment-detector.d.ts.map +0 -1
- package/dist/utils/environment.d.ts +0 -47
- package/dist/utils/environment.d.ts.map +0 -1
- package/dist/utils/formatting.d.ts +0 -58
- package/dist/utils/formatting.d.ts.map +0 -1
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/opentui-detection.d.ts +0 -34
- package/dist/utils/opentui-detection.d.ts.map +0 -1
- package/dist/utils/output.d.ts +0 -46
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/stackTrace.d.ts +0 -6
- package/dist/utils/stackTrace.d.ts.map +0 -1
- package/dist/utils/timestamps.d.ts +0 -20
- package/dist/utils/timestamps.d.ts.map +0 -1
- package/dist/vite.svg +0 -1
package/dist/core.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { D as DEFAULT_CONFIG, a as isBrowser, p as parseStackTrace, s as supportsCSSColors, c as createStyledOutput, L as LEVEL_STYLES, i as isNode } from "./chunks/environment-BanAyF-K.js";
|
|
2
|
-
import { o as getConsoleMethod, c as createOutput, p as createLogEntry, q as formatTablePlain, r as createPlainOutput } from "./chunks/formatting-CgQSWgXR.js";
|
|
3
|
-
class CoreLogger {
|
|
4
|
-
config;
|
|
5
|
-
scopedPrefix;
|
|
6
|
-
handlers = [];
|
|
7
|
-
timers = /* @__PURE__ */ new Map();
|
|
8
|
-
groupDepth = 0;
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new CoreLogger instance
|
|
11
|
-
* @param config - Optional configuration
|
|
12
|
-
*/
|
|
13
|
-
constructor(config = {}) {
|
|
14
|
-
this.config = {
|
|
15
|
-
...DEFAULT_CONFIG,
|
|
16
|
-
...config,
|
|
17
|
-
// Auto-configure based on environment
|
|
18
|
-
enableColors: config.enableColors ?? (isBrowser ? true : false),
|
|
19
|
-
enableTimestamps: config.enableTimestamps ?? true,
|
|
20
|
-
enableStackTrace: config.enableStackTrace ?? false,
|
|
21
|
-
autoDetectTheme: config.autoDetectTheme ?? true,
|
|
22
|
-
outputFormat: config.outputFormat ?? "auto"
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
// ===== CONFIGURATION METHODS =====
|
|
26
|
-
/**
|
|
27
|
-
* Get current configuration
|
|
28
|
-
*/
|
|
29
|
-
getConfig() {
|
|
30
|
-
return { ...this.config };
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Sets the global prefix for all log messages
|
|
34
|
-
*/
|
|
35
|
-
setGlobalPrefix(prefix) {
|
|
36
|
-
this.config.globalPrefix = prefix;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Sets the verbosity level for filtering log output
|
|
40
|
-
*/
|
|
41
|
-
setVerbosity(level) {
|
|
42
|
-
this.config.verbosity = level;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Creates a scoped logger with a specific prefix
|
|
46
|
-
*/
|
|
47
|
-
scope(prefix) {
|
|
48
|
-
const scopedLogger = new CoreLogger(this.config);
|
|
49
|
-
scopedLogger.scopedPrefix = prefix;
|
|
50
|
-
scopedLogger.handlers = [...this.handlers];
|
|
51
|
-
return scopedLogger;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Adds a custom log handler for extensibility
|
|
55
|
-
*/
|
|
56
|
-
addHandler(handler) {
|
|
57
|
-
this.handlers.push(handler);
|
|
58
|
-
}
|
|
59
|
-
// ===== CORE LOGGING METHODS =====
|
|
60
|
-
/**
|
|
61
|
-
* Checks if a log level should be output based on current verbosity
|
|
62
|
-
*/
|
|
63
|
-
shouldLog(level) {
|
|
64
|
-
if (this.config.verbosity === "silent") return false;
|
|
65
|
-
const levels = { debug: 0, info: 1, warn: 2, error: 3, critical: 4 };
|
|
66
|
-
return levels[level] >= levels[this.config.verbosity];
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Gets the effective prefix (global + scoped)
|
|
70
|
-
*/
|
|
71
|
-
getEffectivePrefix() {
|
|
72
|
-
const parts = [this.config.globalPrefix, this.scopedPrefix].filter(Boolean);
|
|
73
|
-
return parts.length > 0 ? parts.join(":") : void 0;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Core logging method with universal formatting
|
|
77
|
-
*/
|
|
78
|
-
log(level, ...args) {
|
|
79
|
-
if (!this.shouldLog(level)) return;
|
|
80
|
-
const prefix = this.getEffectivePrefix();
|
|
81
|
-
const message = String(args[0] || "");
|
|
82
|
-
const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;
|
|
83
|
-
const consoleMethod = getConsoleMethod(level);
|
|
84
|
-
if (isBrowser && this.config.enableColors && supportsCSSColors()) {
|
|
85
|
-
try {
|
|
86
|
-
const [format, ...styles] = createStyledOutput(
|
|
87
|
-
level,
|
|
88
|
-
LEVEL_STYLES,
|
|
89
|
-
prefix,
|
|
90
|
-
message,
|
|
91
|
-
stackInfo,
|
|
92
|
-
this.config.autoDetectTheme
|
|
93
|
-
);
|
|
94
|
-
console[consoleMethod](format, ...styles, ...args.slice(1));
|
|
95
|
-
} catch (error2) {
|
|
96
|
-
const output = createOutput(level, message, prefix, stackInfo, this.config.outputFormat);
|
|
97
|
-
console[consoleMethod](output, ...args.slice(1));
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
const groupIndent = " ".repeat(this.groupDepth);
|
|
101
|
-
const output = groupIndent + createOutput(level, message, prefix, stackInfo, this.config.outputFormat);
|
|
102
|
-
console[consoleMethod](output, ...args.slice(1));
|
|
103
|
-
}
|
|
104
|
-
const logEntry = createLogEntry(level, message, args, prefix, stackInfo);
|
|
105
|
-
const metadata = {
|
|
106
|
-
timestamp: logEntry.timestamp,
|
|
107
|
-
level,
|
|
108
|
-
prefix,
|
|
109
|
-
stackInfo: logEntry.location
|
|
110
|
-
};
|
|
111
|
-
this.handlers.forEach((handler) => {
|
|
112
|
-
try {
|
|
113
|
-
handler.handle(level, message, args, metadata);
|
|
114
|
-
} catch (error2) {
|
|
115
|
-
console.error("Log handler failed:", error2);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Logs debug information (lowest priority)
|
|
121
|
-
*/
|
|
122
|
-
debug(...args) {
|
|
123
|
-
this.log("debug", ...args);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Logs informational messages
|
|
127
|
-
*/
|
|
128
|
-
info(...args) {
|
|
129
|
-
this.log("info", ...args);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Logs warning messages
|
|
133
|
-
*/
|
|
134
|
-
warn(...args) {
|
|
135
|
-
this.log("warn", ...args);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Logs error messages
|
|
139
|
-
*/
|
|
140
|
-
error(...args) {
|
|
141
|
-
this.log("error", ...args);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Logs critical errors (highest priority)
|
|
145
|
-
*/
|
|
146
|
-
critical(...args) {
|
|
147
|
-
this.log("critical", ...args);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Logs trace information (detailed debugging)
|
|
151
|
-
*/
|
|
152
|
-
trace(...args) {
|
|
153
|
-
this.log("debug", ...args);
|
|
154
|
-
if (this.shouldLog("debug")) {
|
|
155
|
-
console.trace(...args);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// ===== BASIC ADVANCED FEATURES =====
|
|
159
|
-
/**
|
|
160
|
-
* Displays data in a table format
|
|
161
|
-
*/
|
|
162
|
-
table(data, columns) {
|
|
163
|
-
if (!this.shouldLog("info")) return;
|
|
164
|
-
const prefix = this.getEffectivePrefix();
|
|
165
|
-
const tableHeader = `[TABLE]${prefix ? ` [${prefix}]` : ""}:`;
|
|
166
|
-
if (isBrowser && typeof console.table === "function") {
|
|
167
|
-
console.log(tableHeader);
|
|
168
|
-
if (columns) {
|
|
169
|
-
console.table(data, columns);
|
|
170
|
-
} else {
|
|
171
|
-
console.table(data);
|
|
172
|
-
}
|
|
173
|
-
} else {
|
|
174
|
-
console.log(tableHeader);
|
|
175
|
-
const tableText = formatTablePlain(data, columns);
|
|
176
|
-
console.log(tableText);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Starts a collapsible group in the console
|
|
181
|
-
*/
|
|
182
|
-
group(label, collapsed = false) {
|
|
183
|
-
const prefix = this.getEffectivePrefix();
|
|
184
|
-
const fullLabel = `${prefix ? `[${prefix}] ` : ""}${label}`;
|
|
185
|
-
if (isBrowser && console.group && console.groupCollapsed) {
|
|
186
|
-
if (collapsed) {
|
|
187
|
-
console.groupCollapsed(fullLabel);
|
|
188
|
-
} else {
|
|
189
|
-
console.group(fullLabel);
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
const groupStart = "┌─ " + fullLabel;
|
|
193
|
-
console.log(groupStart);
|
|
194
|
-
}
|
|
195
|
-
this.groupDepth++;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Ends the current console group
|
|
199
|
-
*/
|
|
200
|
-
groupEnd() {
|
|
201
|
-
if (this.groupDepth > 0) {
|
|
202
|
-
if (isBrowser && console.groupEnd) {
|
|
203
|
-
console.groupEnd();
|
|
204
|
-
} else {
|
|
205
|
-
const groupEnd2 = "└─ (end group)";
|
|
206
|
-
console.log(groupEnd2);
|
|
207
|
-
}
|
|
208
|
-
this.groupDepth--;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Starts a timer with the given label
|
|
213
|
-
*/
|
|
214
|
-
time(label) {
|
|
215
|
-
const startTime = this.getPerformanceNow();
|
|
216
|
-
const timer = {
|
|
217
|
-
label,
|
|
218
|
-
startTime
|
|
219
|
-
};
|
|
220
|
-
this.timers.set(label, timer);
|
|
221
|
-
const prefix = this.getEffectivePrefix();
|
|
222
|
-
const message = `Timer started: ${label}`;
|
|
223
|
-
const output = createPlainOutput("info", message, prefix);
|
|
224
|
-
console.log(output);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Ends a timer and logs the elapsed time
|
|
228
|
-
*/
|
|
229
|
-
timeEnd(label) {
|
|
230
|
-
const timer = this.timers.get(label);
|
|
231
|
-
if (!timer) {
|
|
232
|
-
this.warn(`Timer '${label}' does not exist`);
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const elapsed = this.getPerformanceNow() - timer.startTime;
|
|
236
|
-
this.timers.delete(label);
|
|
237
|
-
const prefix = this.getEffectivePrefix();
|
|
238
|
-
const message = `Timer ended: ${label} - ${elapsed.toFixed(2)}ms`;
|
|
239
|
-
const output = createPlainOutput("info", message, prefix);
|
|
240
|
-
console.log(output);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Gets performance.now() or fallback for older environments
|
|
244
|
-
*/
|
|
245
|
-
getPerformanceNow() {
|
|
246
|
-
if (typeof performance !== "undefined" && performance.now) {
|
|
247
|
-
return performance.now();
|
|
248
|
-
}
|
|
249
|
-
if (isNode && process.hrtime) {
|
|
250
|
-
const [seconds, nanoseconds] = process.hrtime();
|
|
251
|
-
return seconds * 1e3 + nanoseconds / 1e6;
|
|
252
|
-
}
|
|
253
|
-
return Date.now();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
const coreLogger = new CoreLogger();
|
|
257
|
-
const debug = (...args) => coreLogger.debug(...args);
|
|
258
|
-
const info = (...args) => coreLogger.info(...args);
|
|
259
|
-
const warn = (...args) => coreLogger.warn(...args);
|
|
260
|
-
const error = (...args) => coreLogger.error(...args);
|
|
261
|
-
const critical = (...args) => coreLogger.critical(...args);
|
|
262
|
-
const trace = (...args) => coreLogger.trace(...args);
|
|
263
|
-
const table = (data, columns) => coreLogger.table(data, columns);
|
|
264
|
-
const group = (label, collapsed) => coreLogger.group(label, collapsed);
|
|
265
|
-
const groupEnd = () => coreLogger.groupEnd();
|
|
266
|
-
const time = (label) => coreLogger.time(label);
|
|
267
|
-
const timeEnd = (label) => coreLogger.timeEnd(label);
|
|
268
|
-
const setGlobalPrefix = (prefix) => coreLogger.setGlobalPrefix(prefix);
|
|
269
|
-
const scope = (prefix) => coreLogger.scope(prefix);
|
|
270
|
-
const setVerbosity = (level) => coreLogger.setVerbosity(level);
|
|
271
|
-
const addHandler = (handler) => coreLogger.addHandler(handler);
|
|
272
|
-
export {
|
|
273
|
-
CoreLogger,
|
|
274
|
-
addHandler,
|
|
275
|
-
critical,
|
|
276
|
-
debug,
|
|
277
|
-
coreLogger as default,
|
|
278
|
-
error,
|
|
279
|
-
group,
|
|
280
|
-
groupEnd,
|
|
281
|
-
info,
|
|
282
|
-
scope,
|
|
283
|
-
setGlobalPrefix,
|
|
284
|
-
setVerbosity,
|
|
285
|
-
table,
|
|
286
|
-
time,
|
|
287
|
-
timeEnd,
|
|
288
|
-
trace,
|
|
289
|
-
warn
|
|
290
|
-
};
|
|
291
|
-
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../src/core.ts"],"sourcesContent":["/**\n * @fileoverview Core Logger Module - Minimal logging without advanced features\n * @version 0.0.1\n * \n * This module provides the essential logging functionality without visual enhancements,\n * SVG support, or advanced styling. Perfect for lightweight applications or server-side usage.\n */\n\n// Core types\nimport type {\n LogLevel,\n Verbosity,\n LoggerConfig,\n ILogHandler,\n LogMetadata,\n TimerEntry\n} from './types/index.js';\n\n// Core utilities\nimport {\n parseStackTrace,\n formatTimestamp\n} from './utils/index.js';\n\n// Universal formatting and environment detection\nimport {\n createPlainOutput,\n createOutput,\n getConsoleMethod,\n createLogEntry,\n formatTablePlain,\n safeSerialize,\n detectOptimalFormat,\n type OutputFormat\n} from './utils/formatting.js';\n\nimport {\n isBrowser,\n isNode,\n getRuntimeEnvironment,\n supportsColors,\n supportsCSSColors\n} from './utils/environment.js';\n\nimport { createStyledOutput } from './utils/output.js';\n\n// Constants\nimport { DEFAULT_CONFIG, LEVEL_STYLES } from './constants.js';\n\n/**\n * Minimal Logger class with core functionality only\n * \n * @example\n * ```typescript\n * import { CoreLogger } from '@mks2508/better-logger/core';\n * \n * const logger = new CoreLogger();\n * logger.info('Hello world');\n * logger.error('Something went wrong', error);\n * ```\n */\nexport class CoreLogger {\n private config: LoggerConfig;\n private scopedPrefix?: string;\n private handlers: ILogHandler[] = [];\n private timers: Map<string, TimerEntry> = new Map();\n private groupDepth: number = 0;\n\n /**\n * Creates a new CoreLogger instance\n * @param config - Optional configuration\n */\n constructor(config: Partial<LoggerConfig> = {}) {\n this.config = {\n ...DEFAULT_CONFIG,\n ...config,\n // Auto-configure based on environment\n enableColors: config.enableColors ?? (isBrowser ? true : false),\n enableTimestamps: config.enableTimestamps ?? true,\n enableStackTrace: config.enableStackTrace ?? false,\n autoDetectTheme: config.autoDetectTheme ?? true,\n outputFormat: config.outputFormat ?? 'auto'\n };\n }\n\n // ===== CONFIGURATION METHODS =====\n\n /**\n * Get current configuration\n */\n getConfig(): LoggerConfig {\n return { ...this.config };\n }\n\n /**\n * Sets the global prefix for all log messages\n */\n setGlobalPrefix(prefix: string): void {\n this.config.globalPrefix = prefix;\n }\n\n /**\n * Sets the verbosity level for filtering log output\n */\n setVerbosity(level: Verbosity): void {\n this.config.verbosity = level;\n }\n\n /**\n * Creates a scoped logger with a specific prefix\n */\n scope(prefix: string): CoreLogger {\n const scopedLogger = new CoreLogger(this.config);\n scopedLogger.scopedPrefix = prefix;\n scopedLogger.handlers = [...this.handlers];\n return scopedLogger;\n }\n\n /**\n * Adds a custom log handler for extensibility\n */\n addHandler(handler: ILogHandler): void {\n this.handlers.push(handler);\n }\n\n // ===== CORE LOGGING METHODS =====\n\n /**\n * Checks if a log level should be output based on current verbosity\n */\n private shouldLog(level: LogLevel): boolean {\n if (this.config.verbosity === 'silent') return false;\n const levels = { debug: 0, info: 1, warn: 2, error: 3, critical: 4 };\n return levels[level] >= levels[this.config.verbosity];\n }\n\n /**\n * Gets the effective prefix (global + scoped)\n */\n private getEffectivePrefix(): string | undefined {\n const parts = [this.config.globalPrefix, this.scopedPrefix].filter(Boolean);\n return parts.length > 0 ? parts.join(':') : undefined;\n }\n\n /**\n * Core logging method with universal formatting\n */\n private log(level: LogLevel, ...args: any[]): void {\n if (!this.shouldLog(level)) return;\n\n const prefix = this.getEffectivePrefix();\n const message = String(args[0] || '');\n const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;\n const consoleMethod = getConsoleMethod(level);\n\n // Choose formatting based on environment and configuration\n if (isBrowser && this.config.enableColors && supportsCSSColors()) {\n // Browser with CSS styling\n try {\n const [format, ...styles] = createStyledOutput(\n level,\n LEVEL_STYLES,\n prefix,\n message,\n stackInfo,\n this.config.autoDetectTheme\n );\n console[consoleMethod](format, ...styles, ...args.slice(1));\n } catch (error) {\n // Fallback to universal formatting if CSS fails\n const output = createOutput(level, message, prefix, stackInfo, this.config.outputFormat);\n console[consoleMethod](output, ...args.slice(1));\n }\n } else {\n // Node.js or browser without colors - use universal formatting\n const groupIndent = ' '.repeat(this.groupDepth);\n const output = groupIndent + createOutput(level, message, prefix, stackInfo, this.config.outputFormat);\n console[consoleMethod](output, ...args.slice(1));\n }\n\n // Call custom handlers with structured metadata\n const logEntry = createLogEntry(level, message, args, prefix, stackInfo);\n const metadata: LogMetadata = {\n timestamp: logEntry.timestamp,\n level,\n prefix,\n stackInfo: logEntry.location,\n };\n\n this.handlers.forEach(handler => {\n try {\n handler.handle(level, message, args, metadata);\n } catch (error) {\n console.error('Log handler failed:', error);\n }\n });\n }\n\n /**\n * Logs debug information (lowest priority)\n */\n debug(...args: any[]): void {\n this.log('debug', ...args);\n }\n\n /**\n * Logs informational messages\n */\n info(...args: any[]): void {\n this.log('info', ...args);\n }\n\n /**\n * Logs warning messages\n */\n warn(...args: any[]): void {\n this.log('warn', ...args);\n }\n\n /**\n * Logs error messages\n */\n error(...args: any[]): void {\n this.log('error', ...args);\n }\n\n /**\n * Logs critical errors (highest priority)\n */\n critical(...args: any[]): void {\n this.log('critical', ...args);\n }\n\n /**\n * Logs trace information (detailed debugging)\n */\n trace(...args: any[]): void {\n this.log('debug', ...args);\n if (this.shouldLog('debug')) {\n console.trace(...args);\n }\n }\n\n // ===== BASIC ADVANCED FEATURES =====\n\n /**\n * Displays data in a table format\n */\n table(data: any, columns?: string[]): void {\n if (!this.shouldLog('info')) return;\n\n const prefix = this.getEffectivePrefix();\n const tableHeader = `[TABLE]${prefix ? ` [${prefix}]` : ''}:`;\n \n if (isBrowser && typeof console.table === 'function') {\n // Browser has native table support\n console.log(tableHeader);\n if (columns) {\n console.table(data, columns);\n } else {\n console.table(data);\n }\n } else {\n // Node.js or fallback - use plain text formatting\n console.log(tableHeader);\n const tableText = formatTablePlain(data, columns);\n console.log(tableText);\n }\n }\n\n /**\n * Starts a collapsible group in the console\n */\n group(label: string, collapsed: boolean = false): void {\n const prefix = this.getEffectivePrefix();\n const fullLabel = `${prefix ? `[${prefix}] ` : ''}${label}`;\n \n if (isBrowser && console.group && console.groupCollapsed) {\n // Browser supports native grouping\n if (collapsed) {\n console.groupCollapsed(fullLabel);\n } else {\n console.group(fullLabel);\n }\n } else {\n // Node.js fallback - just log the group label\n const groupStart = '┌─ ' + fullLabel;\n console.log(groupStart);\n }\n \n this.groupDepth++;\n }\n\n /**\n * Ends the current console group\n */\n groupEnd(): void {\n if (this.groupDepth > 0) {\n if (isBrowser && console.groupEnd) {\n console.groupEnd();\n } else {\n // Node.js fallback - log group end\n const groupEnd = '└─ (end group)';\n console.log(groupEnd);\n }\n this.groupDepth--;\n }\n }\n\n /**\n * Starts a timer with the given label\n */\n time(label: string): void {\n const startTime = this.getPerformanceNow();\n const timer: TimerEntry = {\n label,\n startTime,\n };\n this.timers.set(label, timer);\n \n const prefix = this.getEffectivePrefix();\n const message = `Timer started: ${label}`;\n const output = createPlainOutput('info', message, prefix);\n console.log(output);\n }\n\n /**\n * Ends a timer and logs the elapsed time\n */\n timeEnd(label: string): void {\n const timer = this.timers.get(label);\n if (!timer) {\n this.warn(`Timer '${label}' does not exist`);\n return;\n }\n\n const elapsed = this.getPerformanceNow() - timer.startTime;\n this.timers.delete(label);\n \n const prefix = this.getEffectivePrefix();\n const message = `Timer ended: ${label} - ${elapsed.toFixed(2)}ms`;\n const output = createPlainOutput('info', message, prefix);\n console.log(output);\n }\n\n /**\n * Gets performance.now() or fallback for older environments\n */\n private getPerformanceNow(): number {\n if (typeof performance !== 'undefined' && performance.now) {\n return performance.now();\n }\n \n if (isNode && process.hrtime) {\n // Node.js high-resolution time\n const [seconds, nanoseconds] = process.hrtime();\n return seconds * 1000 + nanoseconds / 1000000;\n }\n \n // Fallback to Date.now()\n return Date.now();\n }\n}\n\n// Create and export singleton instance for convenience\nconst coreLogger = new CoreLogger();\n\n/**\n * Export individual methods for convenience (with proper binding)\n */\nexport const debug = (...args: any[]) => coreLogger.debug(...args);\nexport const info = (...args: any[]) => coreLogger.info(...args);\nexport const warn = (...args: any[]) => coreLogger.warn(...args);\nexport const error = (...args: any[]) => coreLogger.error(...args);\nexport const critical = (...args: any[]) => coreLogger.critical(...args);\nexport const trace = (...args: any[]) => coreLogger.trace(...args);\nexport const table = (data: any, columns?: string[]) => coreLogger.table(data, columns);\nexport const group = (label: string, collapsed?: boolean) => coreLogger.group(label, collapsed);\nexport const groupEnd = () => coreLogger.groupEnd();\nexport const time = (label: string) => coreLogger.time(label);\nexport const timeEnd = (label: string) => coreLogger.timeEnd(label);\nexport const setGlobalPrefix = (prefix: string) => coreLogger.setGlobalPrefix(prefix);\nexport const scope = (prefix: string) => coreLogger.scope(prefix);\nexport const setVerbosity = (level: Verbosity) => coreLogger.setVerbosity(level);\nexport const addHandler = (handler: ILogHandler) => coreLogger.addHandler(handler);\n\n// Export the singleton as default\nexport default coreLogger;\n\n// Re-export core types\nexport type {\n LogLevel,\n Verbosity,\n LoggerConfig,\n ILogHandler,\n LogMetadata\n} from './types/index.js';"],"names":["error","groupEnd"],"mappings":";;AA6DO,MAAM,WAAW;AAAA,EACZ;AAAA,EACA;AAAA,EACA,WAA0B,CAAA;AAAA,EAC1B,6BAAsC,IAAA;AAAA,EACtC,aAAqB;AAAA;AAAA;AAAA;AAAA;AAAA,EAM7B,YAAY,SAAgC,IAAI;AAC5C,SAAK,SAAS;AAAA,MACV,GAAG;AAAA,MACH,GAAG;AAAA;AAAA,MAEH,cAAc,OAAO,iBAAiB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export declare function demonstrateBanners(): void;
|
|
5
|
-
export declare function demonstrateThemes(): void;
|
|
6
|
-
export declare function demonstrateSVG(): void;
|
|
7
|
-
export declare function demonstrateAnimations(): void;
|
|
8
|
-
export declare function demonstrateCLI(): void;
|
|
9
|
-
export declare function demonstrateExports(): void;
|
|
10
|
-
export declare function demonstrateBasicLogging(): void;
|
|
11
|
-
export declare function demonstrateTable(): void;
|
|
12
|
-
export declare function demonstrateGrouping(): void;
|
|
13
|
-
export declare function demonstrateTiming(): void;
|
|
14
|
-
export declare function demonstrateScopedLogger(): void;
|
|
15
|
-
export declare function demonstrateTrace(): void;
|
|
16
|
-
export declare function demonstrateCustomStyles(): void;
|
|
17
|
-
export declare function demonstrateAllFeatures(): void;
|
|
18
|
-
//# sourceMappingURL=example.d.ts.map
|
package/dist/example.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":"AAAA;;GAEG;AA0BH,wBAAgB,kBAAkB,SAQjC;AAED,wBAAgB,iBAAiB,SAUhC;AAED,wBAAgB,cAAc,SAW7B;AAED,wBAAgB,qBAAqB,SAGpC;AAED,wBAAgB,cAAc,SAgB7B;AAED,wBAAgB,kBAAkB,SAWjC;AAGD,wBAAgB,uBAAuB,SAUtC;AAED,wBAAgB,gBAAgB,SAS/B;AAED,wBAAgB,mBAAmB,SAgBlC;AAED,wBAAgB,iBAAiB,SAShC;AAED,wBAAgB,uBAAuB,SAWtC;AAED,wBAAgB,gBAAgB,SAQ/B;AAED,wBAAgB,uBAAuB,SActC;AAGD,wBAAgB,sBAAsB,SAcrC"}
|
package/dist/exports-module.d.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { Logger } from './Logger.js';
|
|
2
|
-
import { LogLevel, Verbosity, ILogHandler } from './types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Logger with export and remote capabilities
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { ExportLogger } from '@mks2508/better-logger/exports';
|
|
9
|
-
*
|
|
10
|
-
* const logger = new ExportLogger({ bufferSize: 1000 });
|
|
11
|
-
*
|
|
12
|
-
* // Log some data
|
|
13
|
-
* logger.info('User logged in', { userId: 123 });
|
|
14
|
-
* logger.error('Failed to process', { error: 'timeout' });
|
|
15
|
-
*
|
|
16
|
-
* // Export logs
|
|
17
|
-
* const csvData = await logger.exportLogs('csv');
|
|
18
|
-
* const jsonData = await logger.exportLogs('json');
|
|
19
|
-
*
|
|
20
|
-
* // Setup remote logging
|
|
21
|
-
* logger.addRemoteHandler('https://api.myapp.com/logs', 'api-key');
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare class ExportLogger extends Logger {
|
|
25
|
-
private exportLogHandler?;
|
|
26
|
-
private remoteHandlers;
|
|
27
|
-
constructor(config?: {
|
|
28
|
-
bufferSize?: number;
|
|
29
|
-
} & any);
|
|
30
|
-
/**
|
|
31
|
-
* Export logs in specified format
|
|
32
|
-
*
|
|
33
|
-
* @param format - Export format (csv, json, xml)
|
|
34
|
-
* @param options - Export options
|
|
35
|
-
* @returns Promise resolving to exported data
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const csvData = await logger.exportLogs('csv');
|
|
40
|
-
* const jsonData = await logger.exportLogs('json', {
|
|
41
|
-
* filter: { level: 'error' },
|
|
42
|
-
* limit: 100
|
|
43
|
-
* });
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
exportLogs(format: 'csv' | 'json' | 'xml', options?: {
|
|
47
|
-
filter?: {
|
|
48
|
-
level?: LogLevel;
|
|
49
|
-
from?: Date;
|
|
50
|
-
to?: Date;
|
|
51
|
-
};
|
|
52
|
-
limit?: number;
|
|
53
|
-
}): Promise<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Get current log buffer
|
|
56
|
-
*
|
|
57
|
-
* @returns Array of log entries
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* const logs = logger.getLogs();
|
|
62
|
-
* console.log(`Buffered ${logs.length} log entries`);
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
getLogs(): any[];
|
|
66
|
-
/**
|
|
67
|
-
* Clear the log buffer
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* logger.clearLogs();
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
clearLogs(): void;
|
|
75
|
-
/**
|
|
76
|
-
* Get log statistics
|
|
77
|
-
*
|
|
78
|
-
* @returns Statistics object with counts by level
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* const stats = logger.getLogStats();
|
|
83
|
-
* console.log(`Errors: ${stats.error}, Warnings: ${stats.warn}`);
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
getLogStats(): Record<string, number>;
|
|
87
|
-
/**
|
|
88
|
-
* Add remote logging handler
|
|
89
|
-
*
|
|
90
|
-
* @param endpoint - Remote endpoint URL
|
|
91
|
-
* @param apiKey - Optional API key for authentication
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```typescript
|
|
95
|
-
* logger.addRemoteHandler('https://logs.myservice.com/api', 'secret-key');
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
addRemoteHandler(endpoint: string, apiKey?: string): void;
|
|
99
|
-
/**
|
|
100
|
-
* Remove all remote handlers
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* logger.clearRemoteHandlers();
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
clearRemoteHandlers(): void;
|
|
108
|
-
/**
|
|
109
|
-
* Flush all remote handlers (force send pending logs)
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* await logger.flushRemoteHandlers();
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
flushRemoteHandlers(): Promise<void>;
|
|
117
|
-
}
|
|
118
|
-
declare const exportLogger: ExportLogger;
|
|
119
|
-
/**
|
|
120
|
-
* Export management utilities
|
|
121
|
-
*/
|
|
122
|
-
export declare const exportUtils: {
|
|
123
|
-
/**
|
|
124
|
-
* Export current logs as CSV
|
|
125
|
-
*/
|
|
126
|
-
exportCSV(options?: any): Promise<string>;
|
|
127
|
-
/**
|
|
128
|
-
* Export current logs as JSON
|
|
129
|
-
*/
|
|
130
|
-
exportJSON(options?: any): Promise<string>;
|
|
131
|
-
/**
|
|
132
|
-
* Export current logs as XML
|
|
133
|
-
*/
|
|
134
|
-
exportXML(options?: any): Promise<string>;
|
|
135
|
-
/**
|
|
136
|
-
* Get log statistics
|
|
137
|
-
*/
|
|
138
|
-
getStats(): Record<string, number>;
|
|
139
|
-
/**
|
|
140
|
-
* Clear all logs
|
|
141
|
-
*/
|
|
142
|
-
clear(): void;
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Remote logging utilities
|
|
146
|
-
*/
|
|
147
|
-
export declare const remoteUtils: {
|
|
148
|
-
/**
|
|
149
|
-
* Add remote logging endpoint
|
|
150
|
-
*/
|
|
151
|
-
addEndpoint(url: string, apiKey?: string): void;
|
|
152
|
-
/**
|
|
153
|
-
* Clear all remote endpoints
|
|
154
|
-
*/
|
|
155
|
-
clearEndpoints(): void;
|
|
156
|
-
/**
|
|
157
|
-
* Flush all remote logs
|
|
158
|
-
*/
|
|
159
|
-
flush(): Promise<void>;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Export individual logging methods with export capabilities
|
|
163
|
-
*/
|
|
164
|
-
export declare const debug: (...args: any[]) => void;
|
|
165
|
-
export declare const info: (...args: any[]) => void;
|
|
166
|
-
export declare const warn: (...args: any[]) => void;
|
|
167
|
-
export declare const error: (...args: any[]) => void;
|
|
168
|
-
export declare const success: (...args: any[]) => void;
|
|
169
|
-
export declare const critical: (...args: any[]) => void;
|
|
170
|
-
export declare const trace: (...args: any[]) => void;
|
|
171
|
-
export declare const table: (data: any, columns?: string[]) => void;
|
|
172
|
-
export declare const group: (label: string, collapsed?: boolean) => void;
|
|
173
|
-
export declare const groupEnd: () => void;
|
|
174
|
-
export declare const time: (label: string) => void;
|
|
175
|
-
export declare const timeEnd: (label: string) => void;
|
|
176
|
-
export declare const setGlobalPrefix: (prefix: string) => void;
|
|
177
|
-
export declare const scope: (prefix: string) => any;
|
|
178
|
-
export declare const setVerbosity: (level: Verbosity) => void;
|
|
179
|
-
export declare const addHandler: (handler: ILogHandler) => void;
|
|
180
|
-
/**
|
|
181
|
-
* Export functionality
|
|
182
|
-
*/
|
|
183
|
-
export declare const exportLogs: (format: "csv" | "json" | "xml", options?: any) => Promise<string>;
|
|
184
|
-
export declare const getLogs: () => any[];
|
|
185
|
-
export declare const clearLogs: () => void;
|
|
186
|
-
export declare const getLogStats: () => Record<string, number>;
|
|
187
|
-
/**
|
|
188
|
-
* Remote logging functionality
|
|
189
|
-
*/
|
|
190
|
-
export declare const addRemoteHandler: (endpoint: string, apiKey?: string) => void;
|
|
191
|
-
export declare const clearRemoteHandlers: () => void;
|
|
192
|
-
export declare const flushRemoteHandlers: () => Promise<void>;
|
|
193
|
-
export default exportLogger;
|
|
194
|
-
export { ExportLogHandler, RemoteLogHandler } from './handlers/index.js';
|
|
195
|
-
export type { ILogHandler } from './types/index.js';
|
|
196
|
-
//# sourceMappingURL=exports-module.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports-module.d.ts","sourceRoot":"","sources":["../src/exports-module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACd,MAAM,kBAAkB,CAAC;AAQ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AEG;AACH,eAAO,MAAM,UAAU,GAAU,QAAQ,KAAK,GAAG,MAAM,GAAG,KAAK,EAAE,UAAU,GAAG,oBAC5B,CAAC;AACnD,eAAO,MAAM,OAAO,aAA+B,CAAC;AACpD,eAAO,MAAM,SAAS,YAAiC,CAAC;AACxD,eAAO,MAAM,WAAW,8BAAmC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,SACf,CAAC;AACpD,eAAO,MAAM,mBAAmB,YAA2C,CAAC;AAC5E,eAAO,MAAM,mBAAmB,qBAAuD,CAAC;AAGxF,eAAe,YAAY,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGzE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/exports.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/Logger-DMjlVQWi.js");require("./chunks/environment--eaTrhRu.js");const r=require("./chunks/RemoteLogHandler-ymkQ97xl.js");class ExportLogger extends e.Logger{exportLogHandler;remoteHandlers=[];constructor(r={}){super(r),r.bufferSize&&(this.exportLogHandler=new e.ExportLogHandler(r.bufferSize),this.addHandler(this.exportLogHandler))}async exportLogs(e,r){if(!this.exportLogHandler)throw new Error("Export handler not initialized. Set bufferSize in constructor.");return JSON.stringify([])}getLogs(){return this.exportLogHandler,[]}clearLogs(){this.exportLogHandler}getLogStats(){return this.exportLogHandler,{}}addRemoteHandler(e,t){const o=new r.RemoteLogHandler(e,t);this.remoteHandlers.push(o),this.addHandler(o)}clearRemoteHandlers(){const e=this.getHandlers();this.remoteHandlers.forEach(r=>{const t=e.indexOf(r);t>-1&&e.splice(t,1)}),this.remoteHandlers=[]}async flushRemoteHandlers(){const e=this.remoteHandlers.map(e=>Promise.resolve());await Promise.all(e)}}const t=new ExportLogger({bufferSize:1e3}),o={exportCSV:async e=>await t.exportLogs("csv",e),exportJSON:async e=>await t.exportLogs("json",e),exportXML:async e=>await t.exportLogs("xml",e),getStats:()=>t.getLogStats(),clear(){t.clearLogs()}},s={addEndpoint(e,r){t.addRemoteHandler(e,r)},clearEndpoints(){t.clearRemoteHandlers()},async flush(){await t.flushRemoteHandlers()}};exports.ExportLogHandler=e.ExportLogHandler,exports.RemoteLogHandler=r.RemoteLogHandler,exports.ExportLogger=ExportLogger,exports.addHandler=e=>t.addHandler(e),exports.addRemoteHandler=(e,r)=>t.addRemoteHandler(e,r),exports.clearLogs=()=>t.clearLogs(),exports.clearRemoteHandlers=()=>t.clearRemoteHandlers(),exports.critical=(...e)=>t.critical(...e),exports.debug=(...e)=>t.debug(...e),exports.default=t,exports.error=(...e)=>t.error(...e),exports.exportLogs=async(e,r)=>await t.exportLogs(e,r),exports.exportUtils=o,exports.flushRemoteHandlers=async()=>await t.flushRemoteHandlers(),exports.getLogStats=()=>t.getLogStats(),exports.getLogs=()=>t.getLogs(),exports.group=(e,r)=>t.group(e,r),exports.groupEnd=()=>t.groupEnd(),exports.info=(...e)=>t.info(...e),exports.remoteUtils=s,exports.scope=e=>t.scope(e),exports.setGlobalPrefix=e=>t.setGlobalPrefix(e),exports.setVerbosity=e=>t.setVerbosity(e),exports.success=(...e)=>t.success(...e),exports.table=(e,r)=>t.table(e,r),exports.time=e=>t.time(e),exports.timeEnd=e=>t.timeEnd(e),exports.trace=(...e)=>t.trace(...e),exports.warn=(...e)=>t.warn(...e);
|
|
2
|
-
//# sourceMappingURL=exports.cjs.map
|
package/dist/exports.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.cjs","sources":["../src/exports-module.ts"],"sourcesContent":["/**\n * @fileoverview Exports Module - Export and remote logging capabilities\n * @version 0.0.1\n * \n * This module provides export functionality for logs including CSV, JSON, XML formats\n * and remote logging capabilities for sending logs to external services.\n */\n\n// Core logger and types\nimport { Logger } from './Logger.js';\nimport type {\n LogLevel,\n Verbosity,\n ILogHandler\n} from './types/index.js';\n\n// Export handlers\nimport {\n ExportLogHandler,\n RemoteLogHandler\n} from './handlers/index.js';\n\n/**\n * Logger with export and remote capabilities\n * \n * @example\n * ```typescript\n * import { ExportLogger } from '@mks2508/better-logger/exports';\n * \n * const logger = new ExportLogger({ bufferSize: 1000 });\n * \n * // Log some data\n * logger.info('User logged in', { userId: 123 });\n * logger.error('Failed to process', { error: 'timeout' });\n * \n * // Export logs\n * const csvData = await logger.exportLogs('csv');\n * const jsonData = await logger.exportLogs('json');\n * \n * // Setup remote logging\n * logger.addRemoteHandler('https://api.myapp.com/logs', 'api-key');\n * ```\n */\nexport class ExportLogger extends Logger {\n private exportLogHandler?: ExportLogHandler;\n private remoteHandlers: RemoteLogHandler[] = [];\n\n constructor(config: { bufferSize?: number } & any = {}) {\n super(config);\n \n // Initialize export handler if buffer size specified\n if (config.bufferSize) {\n this.exportLogHandler = new ExportLogHandler(config.bufferSize);\n this.addHandler(this.exportLogHandler);\n }\n }\n\n /**\n * Export logs in specified format\n * \n * @param format - Export format (csv, json, xml)\n * @param options - Export options\n * @returns Promise resolving to exported data\n * \n * @example\n * ```typescript\n * const csvData = await logger.exportLogs('csv');\n * const jsonData = await logger.exportLogs('json', { \n * filter: { level: 'error' },\n * limit: 100 \n * });\n * ```\n */\n async exportLogs(\n format: 'csv' | 'json' | 'xml', \n options?: {\n filter?: { level?: LogLevel; from?: Date; to?: Date };\n limit?: number;\n }\n ): Promise<string> {\n if (!this.exportLogHandler) {\n throw new Error('Export handler not initialized. Set bufferSize in constructor.');\n }\n\n // Temporary implementation - ExportLogHandler needs these methods\n return JSON.stringify([]);\n }\n\n /**\n * Get current log buffer\n * \n * @returns Array of log entries\n * \n * @example\n * ```typescript\n * const logs = logger.getLogs();\n * console.log(`Buffered ${logs.length} log entries`);\n * ```\n */\n getLogs(): any[] {\n if (!this.exportLogHandler) {\n return [];\n }\n \n // Temporary implementation - ExportLogHandler needs these methods\n return [];\n }\n\n /**\n * Clear the log buffer\n * \n * @example\n * ```typescript\n * logger.clearLogs();\n * ```\n */\n clearLogs(): void {\n if (this.exportLogHandler) {\n // Temporary implementation - ExportLogHandler needs these methods\n }\n }\n\n /**\n * Get log statistics\n * \n * @returns Statistics object with counts by level\n * \n * @example\n * ```typescript\n * const stats = logger.getLogStats();\n * console.log(`Errors: ${stats.error}, Warnings: ${stats.warn}`);\n * ```\n */\n getLogStats(): Record<string, number> {\n if (!this.exportLogHandler) {\n return {};\n }\n\n // Temporary implementation - ExportLogHandler needs these methods\n return {};\n }\n\n /**\n * Add remote logging handler\n * \n * @param endpoint - Remote endpoint URL\n * @param apiKey - Optional API key for authentication\n * \n * @example\n * ```typescript\n * logger.addRemoteHandler('https://logs.myservice.com/api', 'secret-key');\n * ```\n */\n addRemoteHandler(endpoint: string, apiKey?: string): void {\n const remoteHandler = new RemoteLogHandler(endpoint, apiKey);\n this.remoteHandlers.push(remoteHandler);\n this.addHandler(remoteHandler);\n }\n\n /**\n * Remove all remote handlers\n * \n * @example\n * ```typescript\n * logger.clearRemoteHandlers();\n * ```\n */\n clearRemoteHandlers(): void {\n // Remove from handlers array\n const allHandlers = this.getHandlers();\n this.remoteHandlers.forEach(remoteHandler => {\n const index = allHandlers.indexOf(remoteHandler);\n if (index > -1) {\n allHandlers.splice(index, 1);\n }\n });\n \n this.remoteHandlers = [];\n }\n\n /**\n * Flush all remote handlers (force send pending logs)\n * \n * @example\n * ```typescript\n * await logger.flushRemoteHandlers();\n * ```\n */\n async flushRemoteHandlers(): Promise<void> {\n const flushPromises = this.remoteHandlers.map(handler => \n Promise.resolve() // RemoteLogHandler needs flush method\n );\n \n await Promise.all(flushPromises);\n }\n}\n\n// Create singleton instance with export capabilities\nconst exportLogger = new ExportLogger({ bufferSize: 1000 });\n\n/**\n * Export management utilities\n */\nexport const exportUtils = {\n /**\n * Export current logs as CSV\n */\n async exportCSV(options?: any): Promise<string> {\n return await exportLogger.exportLogs('csv', options);\n },\n\n /**\n * Export current logs as JSON\n */\n async exportJSON(options?: any): Promise<string> {\n return await exportLogger.exportLogs('json', options);\n },\n\n /**\n * Export current logs as XML\n */\n async exportXML(options?: any): Promise<string> {\n return await exportLogger.exportLogs('xml', options);\n },\n\n /**\n * Get log statistics\n */\n getStats(): Record<string, number> {\n return exportLogger.getLogStats();\n },\n\n /**\n * Clear all logs\n */\n clear(): void {\n exportLogger.clearLogs();\n }\n};\n\n/**\n * Remote logging utilities\n */\nexport const remoteUtils = {\n /**\n * Add remote logging endpoint\n */\n addEndpoint(url: string, apiKey?: string): void {\n exportLogger.addRemoteHandler(url, apiKey);\n },\n\n /**\n * Clear all remote endpoints\n */\n clearEndpoints(): void {\n exportLogger.clearRemoteHandlers();\n },\n\n /**\n * Flush all remote logs\n */\n async flush(): Promise<void> {\n await exportLogger.flushRemoteHandlers();\n }\n};\n\n/**\n * Export individual logging methods with export capabilities\n */\nexport const debug = (...args: any[]) => exportLogger.debug(...args);\nexport const info = (...args: any[]) => exportLogger.info(...args);\nexport const warn = (...args: any[]) => exportLogger.warn(...args);\nexport const error = (...args: any[]) => exportLogger.error(...args);\nexport const success = (...args: any[]) => exportLogger.success(...args);\nexport const critical = (...args: any[]) => exportLogger.critical(...args);\nexport const trace = (...args: any[]) => exportLogger.trace(...args);\nexport const table = (data: any, columns?: string[]) => exportLogger.table(data, columns);\nexport const group = (label: string, collapsed?: boolean) => exportLogger.group(label, collapsed);\nexport const groupEnd = () => exportLogger.groupEnd();\nexport const time = (label: string) => exportLogger.time(label);\nexport const timeEnd = (label: string) => exportLogger.timeEnd(label);\nexport const setGlobalPrefix = (prefix: string) => exportLogger.setGlobalPrefix(prefix);\nexport const scope = (prefix: string) => exportLogger.scope(prefix);\nexport const setVerbosity = (level: Verbosity) => exportLogger.setVerbosity(level);\nexport const addHandler = (handler: ILogHandler) => exportLogger.addHandler(handler);\n\n/**\n * Export functionality\n */\nexport const exportLogs = async (format: 'csv' | 'json' | 'xml', options?: any) => \n await exportLogger.exportLogs(format, options);\nexport const getLogs = () => exportLogger.getLogs();\nexport const clearLogs = () => exportLogger.clearLogs();\nexport const getLogStats = () => exportLogger.getLogStats();\n\n/**\n * Remote logging functionality\n */\nexport const addRemoteHandler = (endpoint: string, apiKey?: string) => \n exportLogger.addRemoteHandler(endpoint, apiKey);\nexport const clearRemoteHandlers = () => exportLogger.clearRemoteHandlers();\nexport const flushRemoteHandlers = async () => await exportLogger.flushRemoteHandlers();\n\n// Export the singleton as default\nexport default exportLogger;\n\n// Re-export handlers\nexport { ExportLogHandler, RemoteLogHandler } from './handlers/index.js';\n\n// Re-export types\nexport type { ILogHandler } from './types/index.js';"],"names":["ExportLogger","Logger","exportLogHandler","remoteHandlers","constructor","config","super","bufferSize","this","ExportLogHandler","addHandler","exportLogs","format","options","Error","JSON","stringify","getLogs","clearLogs","getLogStats","addRemoteHandler","endpoint","apiKey","remoteHandler","RemoteLogHandler","push","clearRemoteHandlers","allHandlers","getHandlers","forEach","index","indexOf","splice","flushRemoteHandlers","flushPromises","map","handler","Promise","resolve","all","exportLogger","exportUtils","async","getStats","clear","remoteUtils","addEndpoint","url","clearEndpoints","flush","args","critical","debug","error","label","collapsed","group","groupEnd","info","prefix","scope","setGlobalPrefix","level","setVerbosity","success","data","columns","table","time","timeEnd","trace","warn"],"mappings":"gQA2CO,MAAMA,qBAAqBC,EAAAA,OACtBC,iBACAC,eAAqC,GAE7C,WAAAC,CAAYC,EAAwC,IAChDC,MAAMD,GAGFA,EAAOE,aACPC,KAAKN,iBAAmB,IAAIO,mBAAiBJ,EAAOE,YACpDC,KAAKE,WAAWF,KAAKN,kBAE7B,CAkBA,gBAAMS,CACFC,EACAC,GAKA,IAAKL,KAAKN,iBACN,MAAM,IAAIY,MAAM,kEAIpB,OAAOC,KAAKC,UAAU,GAC1B,CAaA,OAAAC,GACI,OAAKT,KAAKN,iBAKH,EACX,CAUA,SAAAgB,GACQV,KAAKN,g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