Parameters
- options: { configPath?: string; required?: boolean } = {}
OptionalconfigPath?: string
Optionalrequired?: boolean
Returns ConfigResult<
{
service: { name: string; version: string; environment: string };
logger: {
enabled: boolean;
level: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent";
redact: string[];
transports: (
| {
type: "console";
level?: "fatal"
| "error"
| "warn"
| "info"
| "debug"
| "trace";
variant?: "pretty" | "json" | "minimal" | "aligned";
prettyOptions?: {
colorize?: boolean;
translateTime?: string;
ignore?: string;
singleLine?: boolean;
hideObject?: boolean;
};
minimalOptions?: { colorize?: boolean };
alignedOptions?: {
colorize?: boolean;
showTimestamp?: boolean;
timestampFormat?: "iso" | "epoch";
dataFormat?: "json" | "inline" | "hidden";
excludeFields?: string[];
};
pretty?: boolean;
}
| {
type: "file";
dir: string;
fileName: string;
level?: "fatal"
| "error"
| "warn"
| "info"
| "debug"
| "trace";
sync: boolean;
mkdir: boolean;
}
| {
type: "otel";
endpoint: string;
level?: "fatal"
| "error"
| "warn"
| "info"
| "debug"
| "trace";
exportIntervalMillis: number;
}
| {
type: "memory";
name?: string;
maxSize: number;
level?: "fatal"
| "error"
| "warn"
| "info"
| "debug"
| "trace";
}
)[];
plugins: { traceContext: boolean; morganStream: boolean };
};
otel: {
enabled: boolean;
tracing: {
enabled: boolean;
exporter: "console"
| "otlp"
| "jaeger"
| "none";
endpoint?: string;
sampleRate: number;
};
metrics: {
enabled: boolean;
exporters: (
| { type: "prometheus"; port: number }
| { type: "otlp"; endpoint: string; exportIntervalMillis: number }
)[];
exportIntervalMillis: number;
};
instrumentation: { auto: boolean; http: boolean };
};
_configDir?: string;
},
>
Result containing validated configuration object, or error
Loads config from default location or provided path