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