diff --git a/conduit-example.toml b/conduit-example.toml index 3aca538d..fea84bd8 100644 --- a/conduit-example.toml +++ b/conduit-example.toml @@ -35,6 +35,7 @@ max_request_size = 20_000_000 # in bytes #cache_capacity = 1073741824 # in bytes, 1024 * 1024 * 1024 #max_concurrent_requests = 4 # How many requests Conduit sends to other servers at the same time +#log = "info,rocket=off,_=off,sled=off" #workers = 4 # default: cpu core count * 2 address = "127.0.0.1" # This makes sure Conduit can only be reached using the reverse proxy diff --git a/src/client_server/thirdparty.rs b/src/client_server/thirdparty.rs index 3c076994..fe5b7846 100644 --- a/src/client_server/thirdparty.rs +++ b/src/client_server/thirdparty.rs @@ -12,7 +12,7 @@ use std::collections::BTreeMap; )] #[tracing::instrument] pub async fn get_protocols_route() -> ConduitResult { - warn!("TODO: get_protocols_route"); + // TODO Ok(get_protocols::Response { protocols: BTreeMap::new(), } diff --git a/src/database.rs b/src/database.rs index 47cee0db..b14a9120 100644 --- a/src/database.rs +++ b/src/database.rs @@ -46,6 +46,8 @@ pub struct Config { jwt_secret: Option, #[serde(default = "Vec::new")] trusted_servers: Vec>, + #[serde(default = "default_log")] + pub log: String, } fn false_fn() -> bool { @@ -68,6 +70,10 @@ fn default_max_concurrent_requests() -> u16 { 4 } +fn default_log() -> String { + "info,rocket=off,_=off,sled=off".to_owned() +} + #[derive(Clone)] pub struct Database { pub globals: globals::Globals, diff --git a/src/main.rs b/src/main.rs index 2ec3a425..327aefab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -205,7 +205,8 @@ async fn main() { rocket.launch().await.unwrap(); } else { - pretty_env_logger::init(); + std::env::set_var("CONDUIT_LOG", config.log); + pretty_env_logger::init_custom_env("CONDUIT_LOG"); let root = span!(tracing::Level::INFO, "app_start", work_units = 2); let _enter = root.enter(); diff --git a/src/server_server.rs b/src/server_server.rs index fa5706da..49128781 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -1339,11 +1339,14 @@ pub(crate) async fn build_forward_extremity_snapshots( // The current server state and incoming event state are built to be // the state after. // This would be the incoming state from the server. - Some(leave_pdu) => { + Some(leaf_pdu) => { let pdu_shortstatehash = db .rooms - .pdu_shortstatehash(&leave_pdu.event_id)? - .ok_or_else(|| Error::bad_database("Found pdu with no statehash in db."))?; + .pdu_shortstatehash(&leaf_pdu.event_id)? + .ok_or_else(|| { + warn!("Leaf pdu: {:?}", leaf_pdu); + Error::bad_database("Found pdu with no statehash in db.") + })?; if current_shortstatehash.as_ref() == Some(&pdu_shortstatehash) { includes_current_state = true; @@ -1357,8 +1360,8 @@ pub(crate) async fn build_forward_extremity_snapshots( .collect::>(); // Now it's the state after - let key = (leave_pdu.kind.clone(), leave_pdu.state_key.clone()); - state_before.insert(key, Arc::new(leave_pdu)); + let key = (leaf_pdu.kind.clone(), leaf_pdu.state_key.clone()); + state_before.insert(key, Arc::new(leaf_pdu)); fork_states.insert(state_before); }