import { type LogConfig, type LogFilter, type LogLevel } from './config'; import { type CallMetadata } from './meta'; /** * Optional object passed to the logging API. */ export type LogContext = Record | Error | any; /** * Normalized call-site metadata suitable for display and serialization. */ export interface ComputedLogMeta { /** Relative filename (normalized via {@link getRelativeFilename}). */ filename?: string; /** Line number within the file. */ line?: number; /** Debug name of the enclosing scope (class instance), e.g. `MyClass#3`. */ context?: string; } /** * Fields required to construct a {@link LogEntry}. */ export interface LogEntryInit { level: LogLevel; message?: string; context?: LogContext; meta?: CallMetadata; error?: Error; /** Overrides the default timestamp ({@link Date.now}). */ timestamp?: number; } /** * Record for a single log line processed by the logging pipeline. * * Raw fields (`level`, `message`, `context`, `meta`, `error`) are preserved so processors * can access unmodified inputs. Derived, lazily computed getters * ({@link computedContext}, {@link computedError}, {@link computedMeta}) centralize * the formatting logic shared across processors that write to serialized stores. */ export declare class LogEntry { #private; /** Severity of this entry. */ readonly level: LogLevel; /** Human-readable log message, if any. */ readonly message?: string; /** * Raw context value passed at the call site. May be a record, an Error, a function * returning either, or any other value. Processors that need the flattened / * JSON-safe view should prefer {@link computedContext}. */ readonly context?: LogContext; /** Raw call-site metadata injected by the log transform plugin. */ readonly meta?: CallMetadata; /** Error passed to `log.catch()` / `log.error(err)`, if any. */ readonly error?: Error; /** Unix timestamp in milliseconds of when the entry was created. */ readonly timestamp: number; constructor(init: LogEntryInit); /** * Flattened, JSON-safe context intended for serialized stores. * * - Single-level key-value map. * - Primitives (`boolean`, `number`, `string`, `null`, `undefined`) pass through. * - Non-primitive values are stringified one level deep via `JSON.stringify` (no recursion). * - The reserved `error` / `err` keys are stripped — use {@link computedError} instead. * - Properties from `@logInfo`-decorated members of the scope (`meta.S`) are inlined. * * Lazily computed and memoized on first access. */ get computedContext(): Record; /** * Stringified error for this entry, sourced (in priority order) from: * 1. {@link error} (e.g. `log.catch(err)`), * 2. {@link context} when the context itself is an {@link Error}, * 3. `context.error` or `context.err`. * * Formatted as `.stack` when available, falling back to `.message` or `String(err)`. * * Lazily computed and memoized on first access. */ get computedError(): string | undefined; /** * Normalized call-site metadata suitable for display / serialization. * * Lazily computed and memoized on first access. */ get computedMeta(): ComputedLogMeta; } /** * Processes (e.g., prints, forwards) log entries. */ export type LogProcessor = (config: LogConfig, entry: LogEntry) => void; /** * Determines if the current line should be logged (called by the processor). */ export declare const shouldLog: (entry: LogEntry, filters?: LogFilter[]) => boolean; /** * Merges scope info, entry context, and error into a single record — preserving nested * objects and Error instances so rich consumers (console inspect, devtools) can format them. * * Prefer {@link LogEntry.computedContext} for serialized / JSON outputs. */ export declare const getContextFromEntry: (entry: LogEntry) => Record | undefined; //# sourceMappingURL=context.d.ts.map