import { C as TailSamplingContext, T as WideEvent, g as RequestLogger, i as EnrichContext, r as DrainContext, v as RouteConfig } from "./types-B82IuY7M.mjs"; //#region src/shared/middleware.d.ts /** * Base options shared by all framework integrations. * * Every framework-specific options interface (e.g. `MxllogExpressOptions`) * extends this type. If a framework needs extra fields it can add them * on top; otherwise the base is used as-is. * * @beta Part of `@safaricom-mxl/log/toolkit` — the public API for building custom integrations. */ interface BaseMxllogOptions { /** Route patterns to include in logging (glob). If not set, all routes are logged */ include?: string[]; /** Route patterns to exclude from logging. Exclusions take precedence over inclusions */ exclude?: string[]; /** Route-specific service configuration */ routes?: Record; /** * Drain callback called with every emitted event. * Use with drain adapters (Axiom, OTLP, Sentry, etc.) or custom endpoints. */ drain?: (ctx: DrainContext) => void | Promise; /** * Enrich callback called after emit, before drain. * Use to add derived context (geo, deployment info, user agent, etc.). */ enrich?: (ctx: EnrichContext) => void | Promise; /** * Custom tail sampling callback. * Set `ctx.shouldKeep = true` to force-keep the log regardless of head sampling. */ keep?: (ctx: TailSamplingContext) => void | Promise; } /** * Internal options consumed by `createMiddlewareLogger`. * Extends `BaseMxllogOptions` with the request-specific fields * that framework adapters must provide. */ interface MiddlewareLoggerOptions extends BaseMxllogOptions { method: string; path: string; requestId?: string; /** Pre-filtered safe request headers (used for enrich/drain context) */ headers?: Record; } interface MiddlewareLoggerResult { logger: RequestLogger; finish: (opts?: { status?: number; error?: Error; }) => Promise; skipped: boolean; } /** * Create a middleware-aware request logger with full lifecycle management. * * Handles the complete pipeline shared across all framework integrations: * route filtering, logger creation, service overrides, duration tracking, * tail sampling evaluation, event emission, enrichment, and draining. * * Framework adapters only need to: * 1. Extract method/path/requestId/headers from the framework request * 2. Call `createMiddlewareLogger()` with those + user options * 3. Check `skipped` — if true, skip to next middleware * 4. Store `logger` in framework-specific context (e.g., `c.set('log', logger)`) * 5. Call `finish({ status })` or `finish({ error })` at response end * * @beta Part of `@safaricom-mxl/log/toolkit` — the public API for building custom integrations. */ declare function createMiddlewareLogger(options: MiddlewareLoggerOptions): MiddlewareLoggerResult; //#endregion export { createMiddlewareLogger as i, MiddlewareLoggerOptions as n, MiddlewareLoggerResult as r, BaseMxllogOptions as t }; //# sourceMappingURL=middleware-Cbh6eBkJ.d.mts.map