logan-logger 1.0.2 → 1.1.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/dist/bun.d.ts ADDED
@@ -0,0 +1,323 @@
1
+ declare abstract class BaseLogger implements ILogger {
2
+ protected level: LogLevel;
3
+ protected config: Partial<LoggerConfig>;
4
+ protected runtime: RuntimeName;
5
+ protected childMetadata: Record<string, any>;
6
+ protected constructor(config?: Partial<LoggerConfig>);
7
+ debug(message: LogMessage, metadata?: any): void;
8
+ info(message: LogMessage, metadata?: any): void;
9
+ warn(message: LogMessage, metadata?: any): void;
10
+ error(message: LogMessage, metadata?: any): void;
11
+ log(level: LogLevel, message: LogMessage, metadata?: any): void;
12
+ setLevel(level: LogLevel): void;
13
+ getLevel(): LogLevel;
14
+ child(metadata: Record<string, any>): ILogger;
15
+ protected shouldLog(level: LogLevel): boolean;
16
+ protected abstract writeLog(entry: LogEntry): void;
17
+ protected abstract createChild(): BaseLogger;
18
+ }
19
+
20
+ /**
21
+ * Convenience function for creating a logger instance.
22
+ * @param config - Optional configuration for the logger
23
+ * @returns A logger instance appropriate for the current runtime
24
+ * @example
25
+ * ```typescript
26
+ * import { createLogger, LogLevel } from 'logan-logger';
27
+ *
28
+ * const logger = createLogger({
29
+ * level: LogLevel.DEBUG,
30
+ * colorize: true
31
+ * });
32
+ *
33
+ * logger.info('Hello world!');
34
+ * ```
35
+ */
36
+ export declare function createLogger(config?: Partial<LoggerConfig>): ILogger;
37
+
38
+ /**
39
+ * Create a logger with configuration based on the current environment.
40
+ * Automatically detects production/development/test environments and
41
+ * sets appropriate log levels and formatting.
42
+ * @returns A logger instance configured for the current environment
43
+ */
44
+ export declare function createLoggerForEnvironment(): ILogger;
45
+
46
+ /**
47
+ * Detects the current JavaScript runtime environment and its capabilities.
48
+ * @returns Information about the detected runtime
49
+ * @example
50
+ * ```typescript
51
+ * const runtime = detectRuntime();
52
+ * console.log(`Running on: ${runtime.name} ${runtime.version}`);
53
+ * ```
54
+ */
55
+ export declare function detectRuntime(): RuntimeInfo;
56
+
57
+ /**
58
+ * Filter out sensitive data from an object before logging.
59
+ * @param obj - The object to filter
60
+ * @param sensitiveKeys - Array of key names to redact (case-insensitive)
61
+ * @returns A new object with sensitive values replaced with '[REDACTED]'
62
+ * @example
63
+ * ```typescript
64
+ * const data = { username: 'john', password: 'secret123' };
65
+ * const filtered = filterSensitiveData(data);
66
+ * // Result: { username: 'john', password: '[REDACTED]' }
67
+ * ```
68
+ */
69
+ export declare function filterSensitiveData(obj: any, sensitiveKeys?: string[]): any;
70
+
71
+ /**
72
+ * Format log level as a colored string for terminal output.
73
+ * @param level - The log level to format
74
+ * @param colorize - Whether to apply ANSI color codes
75
+ * @returns Formatted level string with optional colors
76
+ */
77
+ export declare function formatLevel(level: LogLevel, colorize?: boolean): string;
78
+
79
+ /**
80
+ * Format a log entry for output in different formats.
81
+ * @param entry - The log entry to format
82
+ * @param format - Output format ('json' or 'text')
83
+ * @returns Formatted log string
84
+ * @example
85
+ * ```typescript
86
+ * const entry: LogEntry = {
87
+ * timestamp: new Date(),
88
+ * level: LogLevel.INFO,
89
+ * message: 'User logged in',
90
+ * metadata: { userId: 123 },
91
+ * runtime: 'node'
92
+ * };
93
+ *
94
+ * const textFormat = formatLogEntry(entry, 'text');
95
+ * // Result: "[2024-01-01T12:00:00.000Z] INFO: User logged in {\"userId\":123}"
96
+ *
97
+ * const jsonFormat = formatLogEntry(entry, 'json');
98
+ * // Result: {"timestamp":"2024-01-01T12:00:00.000Z","level":"info","message":"User logged in","metadata":{"userId":123},"runtime":"node"}
99
+ * ```
100
+ */
101
+ export declare function formatLogEntry(entry: LogEntry, format?: 'json' | 'text'): string;
102
+
103
+ export declare function getDefaultConfig(): LoggerConfig;
104
+
105
+ /**
106
+ * Main logger interface providing methods for logging at different levels.
107
+ * This interface is implemented by all logger implementations across different runtimes.
108
+ */
109
+ export declare interface ILogger {
110
+ /**
111
+ * Log a debug message. Only shown when log level is DEBUG.
112
+ * @param message - The message to log (string or lazy function)
113
+ * @param metadata - Optional structured data to include
114
+ */
115
+ debug(message: LogMessage, metadata?: any): void;
116
+ /**
117
+ * Log an informational message.
118
+ * @param message - The message to log (string or lazy function)
119
+ * @param metadata - Optional structured data to include
120
+ */
121
+ info(message: LogMessage, metadata?: any): void;
122
+ /**
123
+ * Log a warning message.
124
+ * @param message - The message to log (string or lazy function)
125
+ * @param metadata - Optional structured data to include
126
+ */
127
+ warn(message: LogMessage, metadata?: any): void;
128
+ /**
129
+ * Log an error message.
130
+ * @param message - The message to log (string or lazy function)
131
+ * @param metadata - Optional structured data to include
132
+ */
133
+ error(message: LogMessage, metadata?: any): void;
134
+ /**
135
+ * Log a message at a specific level.
136
+ * @param level - The log level
137
+ * @param message - The message to log (string or lazy function)
138
+ * @param metadata - Optional structured data to include
139
+ */
140
+ log(level: LogLevel, message: LogMessage, metadata?: any): void;
141
+ /**
142
+ * Set the minimum log level for this logger.
143
+ * @param level - The minimum log level
144
+ */
145
+ setLevel(level: LogLevel): void;
146
+ /**
147
+ * Get the current minimum log level.
148
+ * @returns The current log level
149
+ */
150
+ getLevel(): LogLevel;
151
+ /**
152
+ * Create a child logger with additional metadata.
153
+ * @param metadata - Additional metadata to include in all child log messages
154
+ * @returns A new logger instance with the additional metadata
155
+ */
156
+ child(metadata: Record<string, any>): ILogger;
157
+ }
158
+
159
+ /**
160
+ * Check if the current runtime is a browser.
161
+ * @returns True if running in a browser
162
+ */
163
+ export declare function isBrowser(): boolean;
164
+
165
+ /**
166
+ * Check if the current runtime is Bun.
167
+ * @returns True if running in Bun
168
+ */
169
+ export declare function isBun(): boolean;
170
+
171
+ /**
172
+ * Check if the current runtime is Deno.
173
+ * @returns True if running in Deno
174
+ */
175
+ export declare function isDeno(): boolean;
176
+
177
+ /**
178
+ * Check if the current runtime is Node.js.
179
+ * @returns True if running in Node.js
180
+ */
181
+ export declare function isNode(): boolean;
182
+
183
+ export declare function loadConfigFromEnvironment(): Partial<LoggerConfig>;
184
+
185
+ export declare function loadConfigFromFile(configPath?: string): Promise<Partial<LoggerConfig>>;
186
+
187
+ /**
188
+ * Internal representation of a log entry.
189
+ */
190
+ declare interface LogEntry {
191
+ /** When the log entry was created */
192
+ timestamp: Date;
193
+ /** Log level of this entry */
194
+ level: LogLevel;
195
+ /** The log message */
196
+ message: string;
197
+ /** Additional structured data */
198
+ metadata?: Record<string, any>;
199
+ /** Runtime that generated this log entry */
200
+ runtime: RuntimeName;
201
+ }
202
+
203
+ /**
204
+ * Configuration options for creating a logger instance.
205
+ */
206
+ export declare interface LoggerConfig {
207
+ /** Minimum log level to output */
208
+ level: LogLevel;
209
+ /** Output format for log messages */
210
+ format: 'json' | 'text' | 'custom';
211
+ /** Whether to include timestamps in log output */
212
+ timestamp: boolean;
213
+ /** Whether to colorize log output (if supported) */
214
+ colorize: boolean;
215
+ /** Default metadata to include with all log messages */
216
+ metadata: Record<string, any>;
217
+ /** Transport configurations for log output */
218
+ transports?: TransportConfig[];
219
+ }
220
+
221
+ /**
222
+ * Log levels in ascending order of severity.
223
+ * Used to filter which messages should be logged.
224
+ */
225
+ export declare enum LogLevel {
226
+ /** Debug messages - most verbose */
227
+ DEBUG = 0,
228
+ /** Informational messages */
229
+ INFO = 1,
230
+ /** Warning messages */
231
+ WARN = 2,
232
+ /** Error messages */
233
+ ERROR = 3,
234
+ /** No messages - silent mode */
235
+ SILENT = 4
236
+ }
237
+
238
+ /**
239
+ * A log message can be a string or a function that returns a string.
240
+ * Functions enable lazy evaluation for expensive log message generation.
241
+ */
242
+ declare type LogMessage = string | (() => string);
243
+
244
+ export declare function mergeConfigs(...configs: Partial<LoggerConfig>[]): LoggerConfig;
245
+
246
+ export declare class NodeLogger extends BaseLogger {
247
+ private winston?;
248
+ constructor(config?: Partial<LoggerConfig>);
249
+ private initializeWinston;
250
+ private createWinstonLogger;
251
+ protected writeLog(entry: LogEntry): void;
252
+ protected createChild(): BaseLogger;
253
+ private writeToConsole;
254
+ private getWinstonLevel;
255
+ setLevel(level: LogLevel): void;
256
+ }
257
+
258
+ /**
259
+ * Capabilities that a runtime may or may not support.
260
+ */
261
+ declare interface RuntimeCapabilities {
262
+ /** Whether the runtime supports file system operations */
263
+ fileSystem: boolean;
264
+ /** Whether the runtime supports colored console output */
265
+ colorSupport: boolean;
266
+ /** Whether the runtime provides process information */
267
+ processInfo: boolean;
268
+ /** Whether the runtime supports streams */
269
+ streams: boolean;
270
+ }
271
+
272
+ /**
273
+ * Information about the detected JavaScript runtime environment.
274
+ */
275
+ declare interface RuntimeInfo {
276
+ /** The name of the runtime */
277
+ name: RuntimeName;
278
+ /** Version string of the runtime (if available) */
279
+ version?: string;
280
+ /** Capabilities supported by this runtime */
281
+ capabilities: RuntimeCapabilities;
282
+ }
283
+
284
+ /**
285
+ * Supported JavaScript runtime environments.
286
+ */
287
+ declare type RuntimeName = 'node' | 'deno' | 'bun' | 'browser' | 'webworker' | 'unknown';
288
+
289
+ /**
290
+ * Safely stringify an object to JSON, handling circular references,
291
+ * Error objects, functions, and other non-serializable values.
292
+ * @param obj - The object to stringify
293
+ * @param space - Number of spaces for pretty-printing (optional)
294
+ * @returns JSON string representation
295
+ */
296
+ export declare function safeStringify(obj: any, space?: number): string;
297
+
298
+ /**
299
+ * Serialize Error objects to plain objects for logging.
300
+ * @param error - The error to serialize
301
+ * @returns Serialized error object or original value if not an Error
302
+ * @example
303
+ * ```typescript
304
+ * const error = new Error('Something went wrong');
305
+ * const serialized = serializeError(error);
306
+ * // Result: { name: 'Error', message: 'Something went wrong', stack: '...' }
307
+ * ```
308
+ */
309
+ export declare function serializeError(error: any): any;
310
+
311
+ /**
312
+ * Configuration for a specific log transport (output destination).
313
+ */
314
+ declare interface TransportConfig {
315
+ /** Type of transport */
316
+ type: 'console' | 'file' | 'http' | 'custom';
317
+ /** Minimum log level for this transport */
318
+ level?: LogLevel;
319
+ /** Transport-specific options */
320
+ options: Record<string, any>;
321
+ }
322
+
323
+ export { }
@@ -0,0 +1,21 @@
1
+ import { N as o, a as r, c as s, e as i, p as t, j as n, f as g, h as f, g as m, i as l, k as d, m as L, n as c, o as v, q as C } from "./node-BqvVrzA_.mjs";
2
+ import { formatLevel as F, formatLogEntry as p } from "./deno.esm.js";
3
+ export {
4
+ o as NodeLogger,
5
+ r as createLogger,
6
+ s as createLoggerForEnvironment,
7
+ i as detectRuntime,
8
+ t as filterSensitiveData,
9
+ F as formatLevel,
10
+ p as formatLogEntry,
11
+ n as getDefaultConfig,
12
+ g as isBrowser,
13
+ f as isBun,
14
+ m as isDeno,
15
+ l as isNode,
16
+ d as loadConfigFromEnvironment,
17
+ L as loadConfigFromFile,
18
+ c as mergeConfigs,
19
+ v as safeStringify,
20
+ C as serializeError
21
+ };
package/dist/bun.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./node-BKsollr4.js"),o=require("./deno.js");exports.NodeLogger=e.NodeLogger;exports.createLogger=e.createLogger;exports.createLoggerForEnvironment=e.createLoggerForEnvironment;exports.detectRuntime=e.detectRuntime;exports.filterSensitiveData=e.filterSensitiveData;exports.getDefaultConfig=e.getDefaultConfig;exports.isBrowser=e.isBrowser;exports.isBun=e.isBun;exports.isDeno=e.isDeno;exports.isNode=e.isNode;exports.loadConfigFromEnvironment=e.loadConfigFromEnvironment;exports.loadConfigFromFile=e.loadConfigFromFile;exports.mergeConfigs=e.mergeConfigs;exports.safeStringify=e.safeStringify;exports.serializeError=e.serializeError;exports.formatLevel=o.formatLevel;exports.formatLogEntry=o.formatLogEntry;
package/dist/deno.d.ts ADDED
@@ -0,0 +1,343 @@
1
+ declare abstract class BaseLogger implements ILogger {
2
+ protected level: LogLevel;
3
+ protected config: Partial<LoggerConfig>;
4
+ protected runtime: RuntimeName;
5
+ protected childMetadata: Record<string, any>;
6
+ protected constructor(config?: Partial<LoggerConfig>);
7
+ debug(message: LogMessage, metadata?: any): void;
8
+ info(message: LogMessage, metadata?: any): void;
9
+ warn(message: LogMessage, metadata?: any): void;
10
+ error(message: LogMessage, metadata?: any): void;
11
+ log(level: LogLevel, message: LogMessage, metadata?: any): void;
12
+ setLevel(level: LogLevel): void;
13
+ getLevel(): LogLevel;
14
+ child(metadata: Record<string, any>): ILogger;
15
+ protected shouldLog(level: LogLevel): boolean;
16
+ protected abstract writeLog(entry: LogEntry): void;
17
+ protected abstract createChild(): BaseLogger;
18
+ }
19
+
20
+ export declare class BrowserLogger extends BaseLogger {
21
+ constructor(config?: Partial<LoggerConfig>);
22
+ protected writeLog(entry: LogEntry): void;
23
+ protected createChild(): BaseLogger;
24
+ private formatMessage;
25
+ private getConsoleStyle;
26
+ private shouldLogInProduction;
27
+ protected shouldLog(level: LogLevel): boolean;
28
+ }
29
+
30
+ export declare class ConsoleGroupLogger extends BrowserLogger {
31
+ private groupStack;
32
+ group(label: string): void;
33
+ groupCollapsed(label: string): void;
34
+ groupEnd(): void;
35
+ getCurrentGroupStack(): string[];
36
+ getCurrentGroupPath(): string;
37
+ time(label: string): void;
38
+ timeEnd(label: string): void;
39
+ trace(message: string, metadata?: any): void;
40
+ count(label?: string): void;
41
+ countReset(label?: string): void;
42
+ table(data: any): void;
43
+ }
44
+
45
+ /**
46
+ * Convenience function for creating a logger instance.
47
+ * @param config - Optional configuration for the logger
48
+ * @returns A logger instance appropriate for the current runtime
49
+ * @example
50
+ * ```typescript
51
+ * import { createLogger, LogLevel } from 'logan-logger';
52
+ *
53
+ * const logger = createLogger({
54
+ * level: LogLevel.DEBUG,
55
+ * colorize: true
56
+ * });
57
+ *
58
+ * logger.info('Hello world!');
59
+ * ```
60
+ */
61
+ export declare function createLogger(config?: Partial<LoggerConfig>): ILogger;
62
+
63
+ /**
64
+ * Create a logger with configuration based on the current environment.
65
+ * Automatically detects production/development/test environments and
66
+ * sets appropriate log levels and formatting.
67
+ * @returns A logger instance configured for the current environment
68
+ */
69
+ export declare function createLoggerForEnvironment(): ILogger;
70
+
71
+ /**
72
+ * Detects the current JavaScript runtime environment and its capabilities.
73
+ * @returns Information about the detected runtime
74
+ * @example
75
+ * ```typescript
76
+ * const runtime = detectRuntime();
77
+ * console.log(`Running on: ${runtime.name} ${runtime.version}`);
78
+ * ```
79
+ */
80
+ export declare function detectRuntime(): RuntimeInfo;
81
+
82
+ /**
83
+ * Filter out sensitive data from an object before logging.
84
+ * @param obj - The object to filter
85
+ * @param sensitiveKeys - Array of key names to redact (case-insensitive)
86
+ * @returns A new object with sensitive values replaced with '[REDACTED]'
87
+ * @example
88
+ * ```typescript
89
+ * const data = { username: 'john', password: 'secret123' };
90
+ * const filtered = filterSensitiveData(data);
91
+ * // Result: { username: 'john', password: '[REDACTED]' }
92
+ * ```
93
+ */
94
+ export declare function filterSensitiveData(obj: any, sensitiveKeys?: string[]): any;
95
+
96
+ /**
97
+ * Format log level as a colored string for terminal output.
98
+ * @param level - The log level to format
99
+ * @param colorize - Whether to apply ANSI color codes
100
+ * @returns Formatted level string with optional colors
101
+ */
102
+ export declare function formatLevel(level: LogLevel, colorize?: boolean): string;
103
+
104
+ /**
105
+ * Format a log entry for output in different formats.
106
+ * @param entry - The log entry to format
107
+ * @param format - Output format ('json' or 'text')
108
+ * @returns Formatted log string
109
+ * @example
110
+ * ```typescript
111
+ * const entry: LogEntry = {
112
+ * timestamp: new Date(),
113
+ * level: LogLevel.INFO,
114
+ * message: 'User logged in',
115
+ * metadata: { userId: 123 },
116
+ * runtime: 'node'
117
+ * };
118
+ *
119
+ * const textFormat = formatLogEntry(entry, 'text');
120
+ * // Result: "[2024-01-01T12:00:00.000Z] INFO: User logged in {\"userId\":123}"
121
+ *
122
+ * const jsonFormat = formatLogEntry(entry, 'json');
123
+ * // Result: {"timestamp":"2024-01-01T12:00:00.000Z","level":"info","message":"User logged in","metadata":{"userId":123},"runtime":"node"}
124
+ * ```
125
+ */
126
+ export declare function formatLogEntry(entry: LogEntry, format?: 'json' | 'text'): string;
127
+
128
+ export declare function getDefaultConfig(): LoggerConfig;
129
+
130
+ /**
131
+ * Main logger interface providing methods for logging at different levels.
132
+ * This interface is implemented by all logger implementations across different runtimes.
133
+ */
134
+ export declare interface ILogger {
135
+ /**
136
+ * Log a debug message. Only shown when log level is DEBUG.
137
+ * @param message - The message to log (string or lazy function)
138
+ * @param metadata - Optional structured data to include
139
+ */
140
+ debug(message: LogMessage, metadata?: any): void;
141
+ /**
142
+ * Log an informational message.
143
+ * @param message - The message to log (string or lazy function)
144
+ * @param metadata - Optional structured data to include
145
+ */
146
+ info(message: LogMessage, metadata?: any): void;
147
+ /**
148
+ * Log a warning message.
149
+ * @param message - The message to log (string or lazy function)
150
+ * @param metadata - Optional structured data to include
151
+ */
152
+ warn(message: LogMessage, metadata?: any): void;
153
+ /**
154
+ * Log an error message.
155
+ * @param message - The message to log (string or lazy function)
156
+ * @param metadata - Optional structured data to include
157
+ */
158
+ error(message: LogMessage, metadata?: any): void;
159
+ /**
160
+ * Log a message at a specific level.
161
+ * @param level - The log level
162
+ * @param message - The message to log (string or lazy function)
163
+ * @param metadata - Optional structured data to include
164
+ */
165
+ log(level: LogLevel, message: LogMessage, metadata?: any): void;
166
+ /**
167
+ * Set the minimum log level for this logger.
168
+ * @param level - The minimum log level
169
+ */
170
+ setLevel(level: LogLevel): void;
171
+ /**
172
+ * Get the current minimum log level.
173
+ * @returns The current log level
174
+ */
175
+ getLevel(): LogLevel;
176
+ /**
177
+ * Create a child logger with additional metadata.
178
+ * @param metadata - Additional metadata to include in all child log messages
179
+ * @returns A new logger instance with the additional metadata
180
+ */
181
+ child(metadata: Record<string, any>): ILogger;
182
+ }
183
+
184
+ /**
185
+ * Check if the current runtime is a browser.
186
+ * @returns True if running in a browser
187
+ */
188
+ export declare function isBrowser(): boolean;
189
+
190
+ /**
191
+ * Check if the current runtime is Bun.
192
+ * @returns True if running in Bun
193
+ */
194
+ export declare function isBun(): boolean;
195
+
196
+ /**
197
+ * Check if the current runtime is Deno.
198
+ * @returns True if running in Deno
199
+ */
200
+ export declare function isDeno(): boolean;
201
+
202
+ /**
203
+ * Check if the current runtime is Node.js.
204
+ * @returns True if running in Node.js
205
+ */
206
+ export declare function isNode(): boolean;
207
+
208
+ export declare function loadConfigFromEnvironment(): Partial<LoggerConfig>;
209
+
210
+ export declare function loadConfigFromFile(configPath?: string): Promise<Partial<LoggerConfig>>;
211
+
212
+ /**
213
+ * Internal representation of a log entry.
214
+ */
215
+ declare interface LogEntry {
216
+ /** When the log entry was created */
217
+ timestamp: Date;
218
+ /** Log level of this entry */
219
+ level: LogLevel;
220
+ /** The log message */
221
+ message: string;
222
+ /** Additional structured data */
223
+ metadata?: Record<string, any>;
224
+ /** Runtime that generated this log entry */
225
+ runtime: RuntimeName;
226
+ }
227
+
228
+ /**
229
+ * Configuration options for creating a logger instance.
230
+ */
231
+ export declare interface LoggerConfig {
232
+ /** Minimum log level to output */
233
+ level: LogLevel;
234
+ /** Output format for log messages */
235
+ format: 'json' | 'text' | 'custom';
236
+ /** Whether to include timestamps in log output */
237
+ timestamp: boolean;
238
+ /** Whether to colorize log output (if supported) */
239
+ colorize: boolean;
240
+ /** Default metadata to include with all log messages */
241
+ metadata: Record<string, any>;
242
+ /** Transport configurations for log output */
243
+ transports?: TransportConfig[];
244
+ }
245
+
246
+ /**
247
+ * Log levels in ascending order of severity.
248
+ * Used to filter which messages should be logged.
249
+ */
250
+ export declare enum LogLevel {
251
+ /** Debug messages - most verbose */
252
+ DEBUG = 0,
253
+ /** Informational messages */
254
+ INFO = 1,
255
+ /** Warning messages */
256
+ WARN = 2,
257
+ /** Error messages */
258
+ ERROR = 3,
259
+ /** No messages - silent mode */
260
+ SILENT = 4
261
+ }
262
+
263
+ /**
264
+ * A log message can be a string or a function that returns a string.
265
+ * Functions enable lazy evaluation for expensive log message generation.
266
+ */
267
+ declare type LogMessage = string | (() => string);
268
+
269
+ export declare function mergeConfigs(...configs: Partial<LoggerConfig>[]): LoggerConfig;
270
+
271
+ export declare class PerformanceLogger extends BrowserLogger {
272
+ mark(name: string): void;
273
+ measure(name: string, startMark?: string, endMark?: string): void;
274
+ clearMarks(name?: string): void;
275
+ clearMeasures(name?: string): void;
276
+ }
277
+
278
+ /**
279
+ * Capabilities that a runtime may or may not support.
280
+ */
281
+ declare interface RuntimeCapabilities {
282
+ /** Whether the runtime supports file system operations */
283
+ fileSystem: boolean;
284
+ /** Whether the runtime supports colored console output */
285
+ colorSupport: boolean;
286
+ /** Whether the runtime provides process information */
287
+ processInfo: boolean;
288
+ /** Whether the runtime supports streams */
289
+ streams: boolean;
290
+ }
291
+
292
+ /**
293
+ * Information about the detected JavaScript runtime environment.
294
+ */
295
+ declare interface RuntimeInfo {
296
+ /** The name of the runtime */
297
+ name: RuntimeName;
298
+ /** Version string of the runtime (if available) */
299
+ version?: string;
300
+ /** Capabilities supported by this runtime */
301
+ capabilities: RuntimeCapabilities;
302
+ }
303
+
304
+ /**
305
+ * Supported JavaScript runtime environments.
306
+ */
307
+ declare type RuntimeName = 'node' | 'deno' | 'bun' | 'browser' | 'webworker' | 'unknown';
308
+
309
+ /**
310
+ * Safely stringify an object to JSON, handling circular references,
311
+ * Error objects, functions, and other non-serializable values.
312
+ * @param obj - The object to stringify
313
+ * @param space - Number of spaces for pretty-printing (optional)
314
+ * @returns JSON string representation
315
+ */
316
+ export declare function safeStringify(obj: any, space?: number): string;
317
+
318
+ /**
319
+ * Serialize Error objects to plain objects for logging.
320
+ * @param error - The error to serialize
321
+ * @returns Serialized error object or original value if not an Error
322
+ * @example
323
+ * ```typescript
324
+ * const error = new Error('Something went wrong');
325
+ * const serialized = serializeError(error);
326
+ * // Result: { name: 'Error', message: 'Something went wrong', stack: '...' }
327
+ * ```
328
+ */
329
+ export declare function serializeError(error: any): any;
330
+
331
+ /**
332
+ * Configuration for a specific log transport (output destination).
333
+ */
334
+ declare interface TransportConfig {
335
+ /** Type of transport */
336
+ type: 'console' | 'file' | 'http' | 'custom';
337
+ /** Minimum log level for this transport */
338
+ level?: LogLevel;
339
+ /** Transport-specific options */
340
+ options: Record<string, any>;
341
+ }
342
+
343
+ export { }