UNPKG

syntropylog

Version:

An instance manager with observability for Node.js applications

43 lines (42 loc) 1.81 kB
import { LoggerOptions } from '../types'; /** * Defines the options for customizing the logger configuration loading behavior. */ export interface LoggerConfigLoaderOptions { /** * The name of the environment variable that can hold the full path to the config file. * If this variable is set, its value is used directly, taking highest precedence. * @default 'LOGGER_CONFIG' */ configPathEnvVar?: string; /** * The name of the environment variable used to determine the environment-specific * suffix for the config file name (e.g., 'NODE_ENV' with a value of 'production'). * @default 'NODE_ENV' */ fallbackEnvVar?: string; /** * The directory where the configuration files are located. * @default './config' */ configDir?: string; /** * The base name for the configuration file (e.g., 'logger' results in 'logger.yaml' * or 'logger-production.yaml'). * @default 'logger' */ defaultBase?: string; } /** * Loads logger configuration from a YAML file. * The function determines the file path with the following priority: * 1. The path from the environment variable specified by `configPathEnvVar` (e.g., `LOGGER_CONFIG`). * 2. The environment-specific path (e.g., `{configDir}/{defaultBase}-production.yaml`). * 3. The default base path (e.g., `{configDir}/{defaultBase}.yaml`). * * If no file is found, it returns an empty object, making the config file optional. * @param opts - Options to customize the loading behavior. * @returns A partial `LoggerOptions` object, or an empty object if no file is found. * @throws An error if a config file is found but fails to be read or parsed. */ export declare function loadLoggerConfig(opts?: LoggerConfigLoaderOptions): Partial<LoggerOptions>;