1pub mod config;
8pub mod context;
9pub mod dispatcher;
10pub mod env;
11pub mod error;
12pub mod events;
13pub mod json;
14pub mod log;
15
16pub use config::Config;
17pub use context::{Context, ContextBuilder};
18pub use dispatcher::{AppEvent, Dispatcher};
19pub use error::{Error, Result};
20pub use events::Event;
21pub use json::Json;
22
23pub fn boot(root: impl AsRef<std::path::Path>) -> Result<Config> {
27 let root = root.as_ref();
28 env::load(root.join(".env"))?;
29
30 let config = Config::with_defaults();
31 config.load_dir(root.join("config"))?;
32
33 if let Some(level) = std::env::var("LOG_LEVEL").ok().and_then(|v| log::Level::parse(&v)) {
34 log::set_level(level);
35 } else if config.is_production() {
36 log::set_level(log::Level::Info);
37 } else {
38 log::set_level(log::Level::Debug);
39 }
40
41 log::set_json(config.is_production());
43
44 Ok(config)
45}