import type { LogEntry } from "./config.js"; /** * In-memory sink for testing purposes. * Captures all log entries in an array that can be inspected in tests. * * **Note:** This is primarily intended for testing SDK integrations. * Most applications should use the default console sink. * * @example * ```ts * import { InMemorySink, setGlobalLoggerConfig, createLogger } from "@alchemy/common"; * * // In tests * const sink = new InMemorySink(); * * setGlobalLoggerConfig({ * sinks: [sink.sink] * }); * * const logger = createLogger({ * package: "@alchemy/aa-infra", * version: "1.0.0", * namespace: "aa-infra" * }); * * logger.info("test message"); * * // Inspect captured logs * expect(sink.count).toBe(1); * expect(sink.latest()?.message).toBe("test message"); * ``` */ export declare class InMemorySink { /** * Array of captured log entries */ entries: LogEntry[]; /** * Creates a new InMemorySink instance. * Binds the sink method to the instance for use as a callback. */ constructor(); /** * The sink function to pass to setGlobalLoggerConfig. * Captures log entries into the internal array. * * @param {LogEntry} entry - The log entry to capture * @returns {void} */ sink(entry: LogEntry): void; /** * Clear all captured entries * * @returns {void} */ clear(): void; /** * Get entries filtered by log level * * @param {number} level - The log level to filter by (LogLevel.ERROR, LogLevel.INFO, etc.) * @returns {LogEntry[]} Array of log entries matching the specified level */ getByLevel(level: number): LogEntry[]; /** * Get entries filtered by namespace * * @param {string} namespace - The namespace to filter by (e.g., "aa-infra", "wallet-apis") * @returns {LogEntry[]} Array of log entries matching the specified namespace */ getByNamespace(namespace: string): LogEntry[]; /** * Get entries filtered by message substring * * @param {string} substring - The substring to search for in log messages * @returns {LogEntry[]} Array of log entries containing the substring in their message */ getByMessage(substring: string): LogEntry[]; /** * Get the most recent log entry * * @returns {LogEntry | undefined} The latest log entry, or undefined if no entries have been captured */ latest(): LogEntry | undefined; /** * Get the number of captured entries * * @returns {number} The total count of captured log entries */ get count(): number; }