import { ContextLocalStorage, LogLevel } from "@logtape/logtape"; //#region src/types.d.ts /** * Configuration object schema for `configureFromObject()`. * @since 2.0.0 */ interface LogTapeConfig { /** * The sinks to configure. */ sinks?: Record; /** * The filters to configure. */ filters?: Record; /** * The loggers to configure. */ loggers?: LoggerConfig[]; /** * Whether to reset the configuration before applying this one. */ reset?: boolean; } /** * Sink configuration with module reference. * @since 2.0.0 */ interface SinkConfig { /** Module reference in `module#export()` format */ type: string; /** Formatter configuration or shorthand */ formatter?: string | FormatterConfig; /** Additional options passed to the factory function */ [key: string]: unknown; } /** * Filter configuration with module reference. * @since 2.0.0 */ interface FilterConfig { /** Module reference in `module#export()` format */ type: string; /** Additional options passed to the factory function */ [key: string]: unknown; } /** * Formatter configuration with module reference. * @since 2.0.0 */ interface FormatterConfig { /** Module reference in `module#export()` format */ type: string; /** Additional options passed to the factory function */ [key: string]: unknown; } /** * Logger configuration. * @since 2.0.0 */ interface LoggerConfig { /** * The category of the logger. */ category: string | string[]; /** * The sink identifiers to use. */ sinks?: string[]; /** * The filter identifiers to use. */ filters?: string[]; /** * The lowest log level to log. */ lowestLevel?: LogLevel; /** * Whether to inherit the parent's sinks. */ parentSinks?: "inherit" | "override"; } /** * Registry of shorthand mappings. * @since 2.0.0 */ interface ShorthandRegistry { /** * The shorthand mappings for sinks. */ sinks?: Record; /** * The shorthand mappings for filters. */ filters?: Record; /** * The shorthand mappings for formatters. */ formatters?: Record; } /** * Options for `configureFromObject()`. * @since 2.0.0 */ interface ConfigureOptions { /** * Custom shorthand mappings to extend or override defaults. */ shorthands?: ShorthandRegistry; /** * The context-local storage to use for implicit contexts. * * In Node.js, Deno, and Bun, you can use `AsyncLocalStorage` from * the `node:async_hooks` module. * * @example * ```typescript * import { AsyncLocalStorage } from "node:async_hooks"; * import { configureFromObject } from "@logtape/config"; * * await configureFromObject(config, { * contextLocalStorage: new AsyncLocalStorage(), * }); * ``` */ contextLocalStorage?: ContextLocalStorage>; /** * How to handle invalid configuration entries. * * - `"throw"` (default): Throw `ConfigError` on any invalid configuration. * - `"warn"`: Apply only valid parts and log warnings to meta logger. */ onInvalidConfig?: "throw" | "warn"; } /** * Options for environment variable expansion. * @since 2.0.0 */ interface EnvExpansionOptions { /** * Regular expression pattern for matching environment variables. * Default: `/\$\{([^}:]+)(?::([^}]+))?\}/g` (matches `${VAR}` or `${VAR:default}`) */ pattern?: RegExp; } /** * Parsed module reference. * @since 2.0.0 */ /** * Error thrown when configuration is invalid. * @since 2.0.0 */ declare class ConfigError extends Error { constructor(message: string); } //# sourceMappingURL=types.d.ts.map //#endregion export { ConfigError, ConfigureOptions, EnvExpansionOptions, FilterConfig, FormatterConfig, LogTapeConfig, LoggerConfig, ShorthandRegistry, SinkConfig }; //# sourceMappingURL=types.d.ts.map