improvement: better logging
Use CONDUIT_LOG or the log setting in the config
This commit is contained in:
parent
46d8f36a2c
commit
1d00a8c41f
5 changed files with 18 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::collections::BTreeMap;
|
|||
)]
|
||||
#[tracing::instrument]
|
||||
pub async fn get_protocols_route() -> ConduitResult<get_protocols::Response> {
|
||||
warn!("TODO: get_protocols_route");
|
||||
// TODO
|
||||
Ok(get_protocols::Response {
|
||||
protocols: BTreeMap::new(),
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ pub struct Config {
|
|||
jwt_secret: Option<String>,
|
||||
#[serde(default = "Vec::new")]
|
||||
trusted_servers: Vec<Box<ServerName>>,
|
||||
#[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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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::<StateMap<_>>();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue