//#region src/mod.d.ts /** * Pino log levels as strings. * @since 1.3.0 */ type PinoLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal" | "silent"; /** * Options for configuring the Fastify LogTape logger. * @since 1.3.0 */ interface FastifyLogTapeOptions { /** * The LogTape category to use for logging. * @default ["fastify"] */ readonly category?: string | readonly string[]; /** * The initial log level. This is tracked internally to satisfy * Pino's level property requirement. * Note: Actual filtering is controlled by LogTape configuration. * @default "info" */ readonly level?: PinoLevel; } /** * Pino-style log method supporting multiple signatures. * * Supports the following calling conventions: * - `logger.info("message")` - Simple message * - `logger.info("message %s", arg)` - Printf-style interpolation * - `logger.info({ key: "value" }, "message")` - Object with message * - `logger.info({ key: "value" })` - Object only * - `logger.info({ msg: "message", key: "value" })` - Object with msg property * * @since 1.3.0 */ interface PinoLogMethod { /** Log with object and optional message */ (obj: Record, msg?: string, ...args: unknown[]): void; /** Log with just a message and optional interpolation args */ (msg: string, ...args: unknown[]): void; } /** * A Pino-compatible logger interface that wraps LogTape. * This interface satisfies Fastify's `loggerInstance` (v5) or `logger` (v4) requirements. * * @example Fastify v5 * ```typescript * import Fastify from "fastify"; * import { getLogTapeFastifyLogger } from "@logtape/fastify"; * * const fastify = Fastify({ * loggerInstance: getLogTapeFastifyLogger(), * }); * ``` * * @example Fastify v4 * ```typescript * import Fastify from "fastify"; * import { getLogTapeFastifyLogger } from "@logtape/fastify"; * * const fastify = Fastify({ * logger: getLogTapeFastifyLogger(), * }); * ``` * * @since 1.3.0 */ interface PinoLikeLogger { /** Log at trace level */ trace: PinoLogMethod; /** Log at debug level */ debug: PinoLogMethod; /** Log at info level */ info: PinoLogMethod; /** Log at warn level */ warn: PinoLogMethod; /** Log at error level */ error: PinoLogMethod; /** Log at fatal level */ fatal: PinoLogMethod; /** No-op silent method for Pino compatibility */ silent: () => void; /** Create a child logger with additional bindings */ child: (bindings: Record) => PinoLikeLogger; /** Current log level (readable/writable for Pino compatibility) */ level: string; } /** * Creates a Pino-compatible logger that wraps LogTape. * This logger can be used as Fastify's `loggerInstance` (v5) or `logger` (v4). * * @example Basic usage * ```typescript * import Fastify from "fastify"; * import { configure } from "@logtape/logtape"; * import { getLogTapeFastifyLogger } from "@logtape/fastify"; * * await configure({ * // ... LogTape configuration * }); * * const fastify = Fastify({ * loggerInstance: getLogTapeFastifyLogger(), * }); * ``` * * @example Basic usage (Fastify v4) * ```typescript * import Fastify from "fastify"; * import { configure } from "@logtape/logtape"; * import { getLogTapeFastifyLogger } from "@logtape/fastify"; * * await configure({ * // ... LogTape configuration * }); * * const fastify = Fastify({ * logger: getLogTapeFastifyLogger(), * }); * ``` * * @example With custom category * ```typescript * const fastify = Fastify({ * loggerInstance: getLogTapeFastifyLogger({ * category: ["myapp", "http"], * }), * }); * ``` * * @param options Configuration options for the logger. * @returns A Pino-compatible logger wrapping LogTape. * @since 1.3.0 */ declare function getLogTapeFastifyLogger(options?: FastifyLogTapeOptions): PinoLikeLogger; //# sourceMappingURL=mod.d.ts.map //#endregion export { FastifyLogTapeOptions, PinoLevel, PinoLikeLogger, PinoLogMethod, getLogTapeFastifyLogger }; //# sourceMappingURL=mod.d.cts.map