UNPKG

@beignet/core

Version:

Core framework primitives for Beignet

78 lines 2.4 kB
/** * Supported structured logger levels. */ export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal"; /** * App-facing structured logger port. * * Application code logs through this interface so production can use Pino, * Datadog, or another adapter while tests can use no-op or memory loggers. */ export interface LoggerPort { /** * Log very detailed diagnostic information. */ trace(message: string, meta?: Record<string, unknown>): void; /** * Log debug-level diagnostic information. */ debug(message: string, meta?: Record<string, unknown>): void; /** * Log normal application progress. */ info(message: string, meta?: Record<string, unknown>): void; /** * Log recoverable problems or unusual conditions. */ warn(message: string, meta?: Record<string, unknown>): void; /** * Log failed operations. */ error(message: string, meta?: Record<string, unknown>): void; /** * Log unrecoverable failures. */ fatal(message: string, meta?: Record<string, unknown>): void; /** * Return a logger with additional structured bindings. */ child(bindings: Record<string, unknown>): LoggerPort; } /** * Captured entry from `createMemoryLogger(...)`. */ export interface MemoryLogEntry { level: LogLevel; message: string; meta?: Record<string, unknown>; bindings: Record<string, unknown>; } /** * In-memory logger port used by tests and local assertions. */ export interface MemoryLoggerPort extends LoggerPort { /** * Captured log entries in call order. */ entries: MemoryLogEntry[]; } /** * Create a logger that discards every log call. * * Use this in tests where logging is irrelevant. * * @returns A logger port whose methods are no-ops. */ export declare function createNoopLogger(): LoggerPort; /** * Create a logger that captures entries in memory. * * Child loggers inherit existing bindings and append new bindings to each * captured entry. * * @param bindings - Structured bindings attached to every captured entry. * @param entries - Optional shared entry array. * @returns A logger port with an inspectable `entries` array. */ export declare function createMemoryLogger(bindings?: Record<string, unknown>, entries?: MemoryLogEntry[]): MemoryLoggerPort; //# sourceMappingURL=logger.d.ts.map