This commit is contained in:
Daniel Flanagan 2024-04-13 10:59:47 -05:00
parent d7fefa7a7f
commit e6c080fb58

View file

@ -27,6 +27,10 @@ pub struct Config {
pub open_ai: Option<OpenAI>, pub open_ai: Option<OpenAI>,
} }
pub struct ConfigLoadResult {
pub config: Config,
}
const CONFIG_FILE_PATH: &str = "./conf.toml"; const CONFIG_FILE_PATH: &str = "./conf.toml";
impl Config { impl Config {
@ -38,6 +42,11 @@ impl Config {
pub fn builder() -> Result<ConfigBuilder<DefaultState>> { pub fn builder() -> Result<ConfigBuilder<DefaultState>> {
let p = std::path::PathBuf::from(CONFIG_FILE_PATH); let p = std::path::PathBuf::from(CONFIG_FILE_PATH);
if !p.exists() { if !p.exists() {
// TODO: this won't output since tracing is not setup before we load
// config, so we need something like
// https://docs.rs/tracing-capture/latest/tracing_capture/
// to capture trace events to be output _after_ configuration has
// loaded and the "actual" subscriber is setup
warn!( warn!(
"Config file '{}' doesn't exist, so defaults will likely be loaded!", "Config file '{}' doesn't exist, so defaults will likely be loaded!",
p.display(), p.display(),