@omote/core 0.1.0 → 0.1.2

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.
@@ -0,0 +1,21 @@
1
+ import { L as LogFormatter } from '../Logger-I_k4sGhM.mjs';
2
+ export { D as DEFAULT_LOGGING_CONFIG, I as ILogger, e as LOG_LEVEL_PRIORITY, b as LogEntry, a as LogLevel, c as LogSink, d as LoggingConfig, j as clearLoggerCache, f as configureLogging, i as createLogger, g as getLoggingConfig, k as getNoopLogger, n as noopLogger, r as resetLoggingConfig, s as setLogLevel, h as setLoggingEnabled } from '../Logger-I_k4sGhM.mjs';
3
+
4
+ /**
5
+ * Log formatters for different output formats
6
+ */
7
+
8
+ /**
9
+ * JSON formatter - structured output for machine parsing
10
+ */
11
+ declare const jsonFormatter: LogFormatter;
12
+ /**
13
+ * Pretty formatter - human-readable output with colors
14
+ */
15
+ declare const prettyFormatter: LogFormatter;
16
+ /**
17
+ * Get formatter by name
18
+ */
19
+ declare function getFormatter(format: 'json' | 'pretty'): LogFormatter;
20
+
21
+ export { LogFormatter, getFormatter, jsonFormatter, prettyFormatter };
@@ -0,0 +1,21 @@
1
+ import { L as LogFormatter } from '../Logger-I_k4sGhM.js';
2
+ export { D as DEFAULT_LOGGING_CONFIG, I as ILogger, e as LOG_LEVEL_PRIORITY, b as LogEntry, a as LogLevel, c as LogSink, d as LoggingConfig, j as clearLoggerCache, f as configureLogging, i as createLogger, g as getLoggingConfig, k as getNoopLogger, n as noopLogger, r as resetLoggingConfig, s as setLogLevel, h as setLoggingEnabled } from '../Logger-I_k4sGhM.js';
3
+
4
+ /**
5
+ * Log formatters for different output formats
6
+ */
7
+
8
+ /**
9
+ * JSON formatter - structured output for machine parsing
10
+ */
11
+ declare const jsonFormatter: LogFormatter;
12
+ /**
13
+ * Pretty formatter - human-readable output with colors
14
+ */
15
+ declare const prettyFormatter: LogFormatter;
16
+ /**
17
+ * Get formatter by name
18
+ */
19
+ declare function getFormatter(format: 'json' | 'pretty'): LogFormatter;
20
+
21
+ export { LogFormatter, getFormatter, jsonFormatter, prettyFormatter };
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/logging/index.ts
21
+ var logging_exports = {};
22
+ __export(logging_exports, {
23
+ DEFAULT_LOGGING_CONFIG: () => DEFAULT_LOGGING_CONFIG,
24
+ LOG_LEVEL_PRIORITY: () => LOG_LEVEL_PRIORITY,
25
+ clearLoggerCache: () => clearLoggerCache,
26
+ configureLogging: () => configureLogging,
27
+ createLogger: () => createLogger,
28
+ getFormatter: () => getFormatter,
29
+ getLoggingConfig: () => getLoggingConfig,
30
+ getNoopLogger: () => getNoopLogger,
31
+ jsonFormatter: () => jsonFormatter,
32
+ noopLogger: () => noopLogger,
33
+ prettyFormatter: () => prettyFormatter,
34
+ resetLoggingConfig: () => resetLoggingConfig,
35
+ setLogLevel: () => setLogLevel,
36
+ setLoggingEnabled: () => setLoggingEnabled
37
+ });
38
+ module.exports = __toCommonJS(logging_exports);
39
+
40
+ // src/logging/types.ts
41
+ var LOG_LEVEL_PRIORITY = {
42
+ error: 0,
43
+ warn: 1,
44
+ info: 2,
45
+ debug: 3,
46
+ trace: 4,
47
+ verbose: 5
48
+ };
49
+ var DEFAULT_LOGGING_CONFIG = {
50
+ level: "info",
51
+ enabled: true,
52
+ format: "pretty",
53
+ timestamps: true,
54
+ includeModule: true
55
+ };
56
+
57
+ // src/logging/formatters.ts
58
+ var COLORS = {
59
+ reset: "\x1B[0m",
60
+ red: "\x1B[31m",
61
+ yellow: "\x1B[33m",
62
+ blue: "\x1B[34m",
63
+ cyan: "\x1B[36m",
64
+ gray: "\x1B[90m",
65
+ white: "\x1B[37m",
66
+ magenta: "\x1B[35m"
67
+ };
68
+ var LEVEL_COLORS = {
69
+ error: COLORS.red,
70
+ warn: COLORS.yellow,
71
+ info: COLORS.blue,
72
+ debug: COLORS.cyan,
73
+ trace: COLORS.magenta,
74
+ verbose: COLORS.gray
75
+ };
76
+ var LEVEL_NAMES = {
77
+ error: "ERROR ",
78
+ warn: "WARN ",
79
+ info: "INFO ",
80
+ debug: "DEBUG ",
81
+ trace: "TRACE ",
82
+ verbose: "VERBOSE"
83
+ };
84
+ var isBrowser = typeof window !== "undefined";
85
+ function formatTimestamp(timestamp) {
86
+ const date = new Date(timestamp);
87
+ return date.toISOString().substring(11, 23);
88
+ }
89
+ function safeStringify(data) {
90
+ const seen = /* @__PURE__ */ new WeakSet();
91
+ return JSON.stringify(data, (key, value) => {
92
+ if (typeof value === "object" && value !== null) {
93
+ if (seen.has(value)) {
94
+ return "[Circular]";
95
+ }
96
+ seen.add(value);
97
+ }
98
+ if (value instanceof Error) {
99
+ return {
100
+ name: value.name,
101
+ message: value.message,
102
+ stack: value.stack
103
+ };
104
+ }
105
+ if (value instanceof Float32Array || value instanceof Int16Array) {
106
+ return `${value.constructor.name}(${value.length})`;
107
+ }
108
+ if (ArrayBuffer.isView(value)) {
109
+ return `${value.constructor.name}(${value.byteLength})`;
110
+ }
111
+ return value;
112
+ });
113
+ }
114
+ var jsonFormatter = (entry) => {
115
+ const output = {
116
+ timestamp: entry.timestamp,
117
+ level: entry.level,
118
+ module: entry.module,
119
+ message: entry.message
120
+ };
121
+ if (entry.data && Object.keys(entry.data).length > 0) {
122
+ output.data = entry.data;
123
+ }
124
+ if (entry.error) {
125
+ output.error = {
126
+ name: entry.error.name,
127
+ message: entry.error.message,
128
+ stack: entry.error.stack
129
+ };
130
+ }
131
+ return safeStringify(output);
132
+ };
133
+ var prettyFormatter = (entry) => {
134
+ const time = formatTimestamp(entry.timestamp);
135
+ const level = LEVEL_NAMES[entry.level];
136
+ const module2 = entry.module;
137
+ const message = entry.message;
138
+ let output;
139
+ if (isBrowser) {
140
+ output = `${time} ${level} [${module2}] ${message}`;
141
+ } else {
142
+ const color = LEVEL_COLORS[entry.level];
143
+ output = `${COLORS.gray}${time}${COLORS.reset} ${color}${level}${COLORS.reset} ${COLORS.cyan}[${module2}]${COLORS.reset} ${message}`;
144
+ }
145
+ if (entry.data && Object.keys(entry.data).length > 0) {
146
+ const dataStr = safeStringify(entry.data);
147
+ if (dataStr.length > 80) {
148
+ output += "\n " + JSON.stringify(entry.data, null, 2).replace(/\n/g, "\n ");
149
+ } else {
150
+ output += " " + dataStr;
151
+ }
152
+ }
153
+ if (entry.error) {
154
+ output += `
155
+ ${entry.error.name}: ${entry.error.message}`;
156
+ if (entry.error.stack) {
157
+ const stackLines = entry.error.stack.split("\n").slice(1, 4);
158
+ output += "\n " + stackLines.join("\n ");
159
+ }
160
+ }
161
+ return output;
162
+ };
163
+ function getFormatter(format) {
164
+ return format === "json" ? jsonFormatter : prettyFormatter;
165
+ }
166
+ function createBrowserConsoleArgs(entry) {
167
+ const time = formatTimestamp(entry.timestamp);
168
+ const level = entry.level.toUpperCase().padEnd(7);
169
+ const module2 = entry.module;
170
+ const message = entry.message;
171
+ const styles = {
172
+ time: "color: gray;",
173
+ error: "color: red; font-weight: bold;",
174
+ warn: "color: orange; font-weight: bold;",
175
+ info: "color: blue;",
176
+ debug: "color: cyan;",
177
+ trace: "color: magenta;",
178
+ verbose: "color: gray;",
179
+ module: "color: teal; font-weight: bold;",
180
+ message: "color: inherit;"
181
+ };
182
+ let formatStr = "%c%s %c%s %c[%s]%c %s";
183
+ const args = [
184
+ styles.time,
185
+ time,
186
+ styles[entry.level],
187
+ level,
188
+ styles.module,
189
+ module2,
190
+ styles.message,
191
+ message
192
+ ];
193
+ if (entry.data && Object.keys(entry.data).length > 0) {
194
+ formatStr += " %o";
195
+ args.push(entry.data);
196
+ }
197
+ return [formatStr, ...args];
198
+ }
199
+
200
+ // src/logging/Logger.ts
201
+ var isBrowser2 = typeof window !== "undefined";
202
+ var globalConfig = { ...DEFAULT_LOGGING_CONFIG };
203
+ function configureLogging(config) {
204
+ globalConfig = { ...globalConfig, ...config };
205
+ }
206
+ function getLoggingConfig() {
207
+ return { ...globalConfig };
208
+ }
209
+ function resetLoggingConfig() {
210
+ globalConfig = { ...DEFAULT_LOGGING_CONFIG };
211
+ }
212
+ function setLogLevel(level) {
213
+ globalConfig.level = level;
214
+ }
215
+ function setLoggingEnabled(enabled) {
216
+ globalConfig.enabled = enabled;
217
+ }
218
+ var consoleSink = (entry) => {
219
+ const consoleMethod = entry.level === "error" ? "error" : entry.level === "warn" ? "warn" : "log";
220
+ if (globalConfig.format === "pretty" && isBrowser2) {
221
+ const args = createBrowserConsoleArgs(entry);
222
+ console[consoleMethod](...args);
223
+ } else {
224
+ const formatter = getFormatter(globalConfig.format);
225
+ const formatted = formatter(entry);
226
+ console[consoleMethod](formatted);
227
+ }
228
+ };
229
+ function getActiveSink() {
230
+ return globalConfig.sink || consoleSink;
231
+ }
232
+ function shouldLog(level) {
233
+ if (!globalConfig.enabled) return false;
234
+ return LOG_LEVEL_PRIORITY[level] <= LOG_LEVEL_PRIORITY[globalConfig.level];
235
+ }
236
+ var Logger = class _Logger {
237
+ constructor(module2) {
238
+ this.module = module2;
239
+ }
240
+ log(level, message, data) {
241
+ if (!shouldLog(level)) return;
242
+ const entry = {
243
+ timestamp: Date.now(),
244
+ level,
245
+ module: this.module,
246
+ message,
247
+ data
248
+ };
249
+ if (data?.error instanceof Error) {
250
+ entry.error = data.error;
251
+ const { error, ...rest } = data;
252
+ entry.data = Object.keys(rest).length > 0 ? rest : void 0;
253
+ }
254
+ getActiveSink()(entry);
255
+ }
256
+ error(message, data) {
257
+ this.log("error", message, data);
258
+ }
259
+ warn(message, data) {
260
+ this.log("warn", message, data);
261
+ }
262
+ info(message, data) {
263
+ this.log("info", message, data);
264
+ }
265
+ debug(message, data) {
266
+ this.log("debug", message, data);
267
+ }
268
+ trace(message, data) {
269
+ this.log("trace", message, data);
270
+ }
271
+ verbose(message, data) {
272
+ this.log("verbose", message, data);
273
+ }
274
+ child(subModule) {
275
+ return new _Logger(`${this.module}.${subModule}`);
276
+ }
277
+ };
278
+ var loggerCache = /* @__PURE__ */ new Map();
279
+ function createLogger(module2) {
280
+ let logger = loggerCache.get(module2);
281
+ if (!logger) {
282
+ logger = new Logger(module2);
283
+ loggerCache.set(module2, logger);
284
+ }
285
+ return logger;
286
+ }
287
+ function clearLoggerCache() {
288
+ loggerCache.clear();
289
+ }
290
+ var noopLogger = {
291
+ module: "noop",
292
+ error: () => {
293
+ },
294
+ warn: () => {
295
+ },
296
+ info: () => {
297
+ },
298
+ debug: () => {
299
+ },
300
+ trace: () => {
301
+ },
302
+ verbose: () => {
303
+ },
304
+ child: () => noopLogger
305
+ };
306
+ function getNoopLogger() {
307
+ return noopLogger;
308
+ }
309
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/logging/index.ts","../../src/logging/types.ts","../../src/logging/formatters.ts","../../src/logging/Logger.ts"],"sourcesContent":["/**\n * Omote SDK Logging Module\n *\n * Unified logging system for all Muse components with:\n * - 6 log levels: error, warn, info, debug, trace, verbose\n * - Structured JSON output for machine parsing\n * - Pretty output for human readability\n * - Module-based child loggers\n * - Runtime configuration\n * - Browser and Node.js compatible\n *\n * @example\n * ```typescript\n * import { configureLogging, createLogger } from '@omote/core';\n *\n * // Configure globally\n * configureLogging({\n * level: 'debug',\n * format: 'pretty',\n * });\n *\n * // Create module logger\n * const logger = createLogger('MyModule');\n * logger.info('Operation complete', { durationMs: 123 });\n * ```\n */\n\n// Types\nexport type {\n LogLevel,\n LogEntry,\n LogSink,\n LogFormatter,\n LoggingConfig,\n ILogger,\n} from './types';\n\nexport {\n LOG_LEVEL_PRIORITY,\n DEFAULT_LOGGING_CONFIG,\n} from './types';\n\n// Formatters\nexport {\n jsonFormatter,\n prettyFormatter,\n getFormatter,\n} from './formatters';\n\n// Logger\nexport {\n configureLogging,\n getLoggingConfig,\n resetLoggingConfig,\n setLogLevel,\n setLoggingEnabled,\n createLogger,\n clearLoggerCache,\n noopLogger,\n getNoopLogger,\n} from './Logger';\n","/**\n * Logging types for Omote SDK\n *\n * 6-level logging system with structured output:\n * - error: Critical failures that prevent operation\n * - warn: Recoverable issues or degraded performance\n * - info: Key lifecycle events (model loaded, inference complete)\n * - debug: Detailed operational info for development\n * - trace: Fine-grained tracing for performance analysis\n * - verbose: Extremely detailed output (tensor shapes, intermediate values)\n */\n\nexport type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'verbose';\n\n/**\n * Numeric priority for log levels (lower = more severe)\n */\nexport const LOG_LEVEL_PRIORITY: Record<LogLevel, number> = {\n error: 0,\n warn: 1,\n info: 2,\n debug: 3,\n trace: 4,\n verbose: 5,\n};\n\n/**\n * Structured log entry\n */\nexport interface LogEntry {\n /** Unix timestamp in milliseconds */\n timestamp: number;\n /** Log level */\n level: LogLevel;\n /** Module name (e.g., 'LocalInference', 'ModelCache') */\n module: string;\n /** Human-readable message */\n message: string;\n /** Optional structured data */\n data?: Record<string, unknown>;\n /** Optional error object */\n error?: Error;\n}\n\n/**\n * Log output sink interface\n */\nexport interface LogSink {\n (entry: LogEntry): void;\n}\n\n/**\n * Log formatter interface\n */\nexport interface LogFormatter {\n (entry: LogEntry): string;\n}\n\n/**\n * Global logging configuration\n */\nexport interface LoggingConfig {\n /** Minimum log level to output (default: 'info') */\n level: LogLevel;\n /** Enable/disable logging globally (default: true) */\n enabled: boolean;\n /** Output format: 'json' for structured, 'pretty' for human-readable */\n format: 'json' | 'pretty';\n /** Custom output sink (default: console) */\n sink?: LogSink;\n /** Include timestamps in output (default: true) */\n timestamps?: boolean;\n /** Include module name in output (default: true) */\n includeModule?: boolean;\n}\n\n/**\n * Logger interface for module-specific logging\n */\nexport interface ILogger {\n error(message: string, data?: Record<string, unknown>): void;\n warn(message: string, data?: Record<string, unknown>): void;\n info(message: string, data?: Record<string, unknown>): void;\n debug(message: string, data?: Record<string, unknown>): void;\n trace(message: string, data?: Record<string, unknown>): void;\n verbose(message: string, data?: Record<string, unknown>): void;\n\n /** Create a child logger with a sub-module name */\n child(subModule: string): ILogger;\n\n /** Get the module name for this logger */\n readonly module: string;\n}\n\n/**\n * Default configuration\n */\nexport const DEFAULT_LOGGING_CONFIG: LoggingConfig = {\n level: 'info',\n enabled: true,\n format: 'pretty',\n timestamps: true,\n includeModule: true,\n};\n","/**\n * Log formatters for different output formats\n */\n\nimport type { LogEntry, LogFormatter, LogLevel } from './types';\n\n/**\n * ANSI color codes for terminal output\n */\nconst COLORS = {\n reset: '\\x1b[0m',\n red: '\\x1b[31m',\n yellow: '\\x1b[33m',\n blue: '\\x1b[34m',\n cyan: '\\x1b[36m',\n gray: '\\x1b[90m',\n white: '\\x1b[37m',\n magenta: '\\x1b[35m',\n};\n\n/**\n * Level-specific colors\n */\nconst LEVEL_COLORS: Record<LogLevel, string> = {\n error: COLORS.red,\n warn: COLORS.yellow,\n info: COLORS.blue,\n debug: COLORS.cyan,\n trace: COLORS.magenta,\n verbose: COLORS.gray,\n};\n\n/**\n * Level display names (padded for alignment)\n */\nconst LEVEL_NAMES: Record<LogLevel, string> = {\n error: 'ERROR ',\n warn: 'WARN ',\n info: 'INFO ',\n debug: 'DEBUG ',\n trace: 'TRACE ',\n verbose: 'VERBOSE',\n};\n\n/**\n * Check if we're in a browser environment\n */\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Format timestamp as ISO string or relative time\n */\nfunction formatTimestamp(timestamp: number): string {\n const date = new Date(timestamp);\n return date.toISOString().substring(11, 23); // HH:mm:ss.SSS\n}\n\n/**\n * Safely serialize data to JSON, handling circular references\n */\nfunction safeStringify(data: unknown): string {\n const seen = new WeakSet();\n return JSON.stringify(data, (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return '[Circular]';\n }\n seen.add(value);\n }\n // Handle special types\n if (value instanceof Error) {\n return {\n name: value.name,\n message: value.message,\n stack: value.stack,\n };\n }\n if (value instanceof Float32Array || value instanceof Int16Array) {\n return `${value.constructor.name}(${value.length})`;\n }\n if (ArrayBuffer.isView(value)) {\n return `${value.constructor.name}(${value.byteLength})`;\n }\n return value;\n });\n}\n\n/**\n * JSON formatter - structured output for machine parsing\n */\nexport const jsonFormatter: LogFormatter = (entry: LogEntry): string => {\n const output: Record<string, unknown> = {\n timestamp: entry.timestamp,\n level: entry.level,\n module: entry.module,\n message: entry.message,\n };\n\n if (entry.data && Object.keys(entry.data).length > 0) {\n output.data = entry.data;\n }\n\n if (entry.error) {\n output.error = {\n name: entry.error.name,\n message: entry.error.message,\n stack: entry.error.stack,\n };\n }\n\n return safeStringify(output);\n};\n\n/**\n * Pretty formatter - human-readable output with colors\n */\nexport const prettyFormatter: LogFormatter = (entry: LogEntry): string => {\n const time = formatTimestamp(entry.timestamp);\n const level = LEVEL_NAMES[entry.level];\n const module = entry.module;\n const message = entry.message;\n\n // Build the base message\n let output: string;\n\n if (isBrowser) {\n // Browser: no ANSI colors, use plain text\n output = `${time} ${level} [${module}] ${message}`;\n } else {\n // Terminal: use ANSI colors\n const color = LEVEL_COLORS[entry.level];\n output = `${COLORS.gray}${time}${COLORS.reset} ${color}${level}${COLORS.reset} ${COLORS.cyan}[${module}]${COLORS.reset} ${message}`;\n }\n\n // Append data if present\n if (entry.data && Object.keys(entry.data).length > 0) {\n const dataStr = safeStringify(entry.data);\n // For pretty format, indent multi-line data\n if (dataStr.length > 80) {\n output += '\\n ' + JSON.stringify(entry.data, null, 2).replace(/\\n/g, '\\n ');\n } else {\n output += ' ' + dataStr;\n }\n }\n\n // Append error if present\n if (entry.error) {\n output += `\\n ${entry.error.name}: ${entry.error.message}`;\n if (entry.error.stack) {\n const stackLines = entry.error.stack.split('\\n').slice(1, 4);\n output += '\\n ' + stackLines.join('\\n ');\n }\n }\n\n return output;\n};\n\n/**\n * Get formatter by name\n */\nexport function getFormatter(format: 'json' | 'pretty'): LogFormatter {\n return format === 'json' ? jsonFormatter : prettyFormatter;\n}\n\n/**\n * Create browser console arguments for styled output\n * Returns [formatString, ...styleArgs] for console.log\n */\nexport function createBrowserConsoleArgs(entry: LogEntry): [string, ...string[]] {\n const time = formatTimestamp(entry.timestamp);\n const level = entry.level.toUpperCase().padEnd(7);\n const module = entry.module;\n const message = entry.message;\n\n // CSS styles for browser console\n const styles = {\n time: 'color: gray;',\n error: 'color: red; font-weight: bold;',\n warn: 'color: orange; font-weight: bold;',\n info: 'color: blue;',\n debug: 'color: cyan;',\n trace: 'color: magenta;',\n verbose: 'color: gray;',\n module: 'color: teal; font-weight: bold;',\n message: 'color: inherit;',\n };\n\n let formatStr = '%c%s %c%s %c[%s]%c %s';\n const args: string[] = [\n styles.time,\n time,\n styles[entry.level],\n level,\n styles.module,\n module,\n styles.message,\n message,\n ];\n\n // Append data\n if (entry.data && Object.keys(entry.data).length > 0) {\n formatStr += ' %o';\n args.push(entry.data as unknown as string);\n }\n\n return [formatStr, ...args];\n}\n","/**\n * Omote SDK Logger\n *\n * Unified logging system with:\n * - 6 log levels (error, warn, info, debug, trace, verbose)\n * - Structured JSON output for machine parsing\n * - Pretty output for human readability\n * - Module-based child loggers\n * - Runtime configuration\n * - Browser and Node.js compatible\n */\n\nimport type {\n LogLevel,\n LogEntry,\n LoggingConfig,\n LogSink,\n ILogger,\n} from './types';\nimport { LOG_LEVEL_PRIORITY, DEFAULT_LOGGING_CONFIG } from './types';\nimport { getFormatter, createBrowserConsoleArgs } from './formatters';\n\n/**\n * Check if running in browser\n */\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Global logging configuration\n */\nlet globalConfig: LoggingConfig = { ...DEFAULT_LOGGING_CONFIG };\n\n/**\n * Configure global logging settings\n */\nexport function configureLogging(config: Partial<LoggingConfig>): void {\n globalConfig = { ...globalConfig, ...config };\n}\n\n/**\n * Get current logging configuration\n */\nexport function getLoggingConfig(): LoggingConfig {\n return { ...globalConfig };\n}\n\n/**\n * Reset logging configuration to defaults\n */\nexport function resetLoggingConfig(): void {\n globalConfig = { ...DEFAULT_LOGGING_CONFIG };\n}\n\n/**\n * Set log level at runtime\n */\nexport function setLogLevel(level: LogLevel): void {\n globalConfig.level = level;\n}\n\n/**\n * Enable or disable logging\n */\nexport function setLoggingEnabled(enabled: boolean): void {\n globalConfig.enabled = enabled;\n}\n\n/**\n * Default console sink with browser-optimized output\n */\nconst consoleSink: LogSink = (entry: LogEntry): void => {\n const consoleMethod = entry.level === 'error' ? 'error'\n : entry.level === 'warn' ? 'warn'\n : 'log';\n\n if (globalConfig.format === 'pretty' && isBrowser) {\n // Use styled console output in browser\n const args = createBrowserConsoleArgs(entry);\n (console as any)[consoleMethod](...args);\n } else {\n // Use formatter for terminal or JSON output\n const formatter = getFormatter(globalConfig.format);\n const formatted = formatter(entry);\n (console as any)[consoleMethod](formatted);\n }\n};\n\n/**\n * Get the active sink (custom or default console)\n */\nfunction getActiveSink(): LogSink {\n return globalConfig.sink || consoleSink;\n}\n\n/**\n * Check if a log level should be output given current config\n */\nfunction shouldLog(level: LogLevel): boolean {\n if (!globalConfig.enabled) return false;\n return LOG_LEVEL_PRIORITY[level] <= LOG_LEVEL_PRIORITY[globalConfig.level];\n}\n\n/**\n * Logger implementation\n */\nclass Logger implements ILogger {\n readonly module: string;\n\n constructor(module: string) {\n this.module = module;\n }\n\n private log(level: LogLevel, message: string, data?: Record<string, unknown>): void {\n if (!shouldLog(level)) return;\n\n const entry: LogEntry = {\n timestamp: Date.now(),\n level,\n module: this.module,\n message,\n data,\n };\n\n // Extract error from data if present\n if (data?.error instanceof Error) {\n entry.error = data.error;\n // Remove from data to avoid duplication\n const { error, ...rest } = data;\n entry.data = Object.keys(rest).length > 0 ? rest : undefined;\n }\n\n getActiveSink()(entry);\n }\n\n error(message: string, data?: Record<string, unknown>): void {\n this.log('error', message, data);\n }\n\n warn(message: string, data?: Record<string, unknown>): void {\n this.log('warn', message, data);\n }\n\n info(message: string, data?: Record<string, unknown>): void {\n this.log('info', message, data);\n }\n\n debug(message: string, data?: Record<string, unknown>): void {\n this.log('debug', message, data);\n }\n\n trace(message: string, data?: Record<string, unknown>): void {\n this.log('trace', message, data);\n }\n\n verbose(message: string, data?: Record<string, unknown>): void {\n this.log('verbose', message, data);\n }\n\n child(subModule: string): ILogger {\n return new Logger(`${this.module}.${subModule}`);\n }\n}\n\n/**\n * Logger cache for reusing instances\n */\nconst loggerCache = new Map<string, Logger>();\n\n/**\n * Create a logger for a specific module\n *\n * @param module - Module name (e.g., 'LocalInference', 'ModelCache')\n * @returns Logger instance\n *\n * @example\n * ```typescript\n * const logger = createLogger('LocalInference');\n * logger.info('Model loaded', { backend: 'webgpu', loadTimeMs: 1234 });\n * ```\n */\nexport function createLogger(module: string): ILogger {\n let logger = loggerCache.get(module);\n if (!logger) {\n logger = new Logger(module);\n loggerCache.set(module, logger);\n }\n return logger;\n}\n\n/**\n * Clear logger cache (useful for testing)\n */\nexport function clearLoggerCache(): void {\n loggerCache.clear();\n}\n\n/**\n * No-op logger for when logging is completely disabled\n */\nexport const noopLogger: ILogger = {\n module: 'noop',\n error: () => {},\n warn: () => {},\n info: () => {},\n debug: () => {},\n trace: () => {},\n verbose: () => {},\n child: () => noopLogger,\n};\n\n/**\n * Get a no-op logger (for production builds that tree-shake logging)\n */\nexport function getNoopLogger(): ILogger {\n return noopLogger;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AC;AAAA,EACb,OAAO,MAAM;AAAA,EAAC;AAAA,EACd,OAAO,MAAM;AAAA,EAAC;AAAA,EACd,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,OAAO,MAAM;AACf;AAKO,SAAS,gBAAyB;AACvC,SAAO;AACT;","names":["module","isBrowser","module"]}
@@ -0,0 +1,34 @@
1
+ import {
2
+ DEFAULT_LOGGING_CONFIG,
3
+ LOG_LEVEL_PRIORITY,
4
+ clearLoggerCache,
5
+ configureLogging,
6
+ createLogger,
7
+ getFormatter,
8
+ getLoggingConfig,
9
+ getNoopLogger,
10
+ jsonFormatter,
11
+ noopLogger,
12
+ prettyFormatter,
13
+ resetLoggingConfig,
14
+ setLogLevel,
15
+ setLoggingEnabled
16
+ } from "../chunk-ESU52TDS.mjs";
17
+ import "../chunk-NSSMTXJJ.mjs";
18
+ export {
19
+ DEFAULT_LOGGING_CONFIG,
20
+ LOG_LEVEL_PRIORITY,
21
+ clearLoggerCache,
22
+ configureLogging,
23
+ createLogger,
24
+ getFormatter,
25
+ getLoggingConfig,
26
+ getNoopLogger,
27
+ jsonFormatter,
28
+ noopLogger,
29
+ prettyFormatter,
30
+ resetLoggingConfig,
31
+ setLogLevel,
32
+ setLoggingEnabled
33
+ };
34
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}