import { LogLevel, Sink, TextFormatter } from "@logtape/logtape"; //#region src/reporter.d.ts /** * Controls when buffered records are reported by a * {@link FailureLogReporter}. * * @since 2.3.0 */ type FailureLogReportMode = "on-failure" | "always" | "never"; /** * Options for {@link createFailureLogReporter}. * * @since 2.3.0 */ interface FailureLogReporterOptions { /** * When to report buffered records. Defaults to `"on-failure"`. */ readonly mode?: FailureLogReportMode; /** * The lowest severity level collected by the reporter's scoped * configuration. Defaults to `"info"`. */ readonly lowestLevel?: LogLevel; /** * The sink that receives buffered records when the reporter flushes. * Defaults to a console sink. */ readonly sink?: Sink; /** * The text formatter used by the default console sink. */ readonly formatter?: TextFormatter; } /** * Options for {@link getFailureLogReporterOptionsFromEnv}. * * @since 2.3.0 */ interface FailureLogReporterEnvOptions { /** * Reads an environment variable by name. * * The caller supplies this function so the shared parser can stay * runtime-agnostic. */ readonly getEnv: (name: string) => string | undefined; /** * The environment variable prefix. Defaults to `"LOGTAPE_TEST_"`. */ readonly prefix?: string; } /** * A reporter that buffers LogTape records while a test callback runs and * reports them depending on the configured mode. * * @since 2.3.0 */ interface FailureLogReporter { /** * Wraps a callback so matching LogTape records are reported according to the * configured mode. * * @param callback The test callback to wrap. * @returns An async callback with the same parameters. */ wrap(callback: (this: TThis, ...args: TArgs) => TResult): (this: TThis, ...args: TArgs) => Promise>; /** * Runs a callback and reports matching LogTape records according to the * configured mode. * * @param callback The callback to run. * @returns The callback result. */ run(callback: () => TResult): Promise>; } /** * Creates a failure log reporter for tests. * * The reporter uses LogTape's scoped configuration support. The process-wide * configuration must already include `Config.contextLocalStorage`, but the * reporter does not mutate global logger routing while a wrapped callback * runs. * * @example * ```ts * import { createFailureLogReporter } from "@logtape/testing/reporter"; * * const reporter = createFailureLogReporter({ lowestLevel: "debug" }); * * test("case", reporter.wrap(async () => { * // Logs emitted here are reported only if this callback throws. * })); * ``` * * @param options Reporter options. * @returns A failure log reporter. * @since 2.3.0 */ declare function createFailureLogReporter(options?: FailureLogReporterOptions): FailureLogReporter; /** * Reads failure log reporter options from environment variables. * * This helper parses `LOGTAPE_TEST_MODE` and `LOGTAPE_TEST_LOWEST_LEVEL` by * default. It does not access the environment directly; pass a runtime * specific `getEnv` callback such as `(name) => process.env[name]`. * * @param options Environment parsing options. * @returns Reporter options parsed from the environment. * @throws {TypeError} If an environment variable has an invalid value. * @since 2.3.0 */ declare function getFailureLogReporterOptionsFromEnv(options: FailureLogReporterEnvOptions): FailureLogReporterOptions; //# sourceMappingURL=reporter.d.ts.map //#endregion export { FailureLogReportMode, FailureLogReporter, FailureLogReporterEnvOptions, FailureLogReporterOptions, createFailureLogReporter, getFailureLogReporterOptionsFromEnv }; //# sourceMappingURL=reporter.d.cts.map