summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Kösters <timo@koesters.xyz>2021-03-23 22:01:14 +0100
committerTimo Kösters <timo@koesters.xyz>2021-03-23 22:06:09 +0100
commit1d00a8c41f92c0df5dac40299bf53134bcfa31b3 (patch)
tree32698815c2c84e6f365fa69f1b06eeebd2fe0ba7
parent46d8f36a2ca6181b8cc8643dee3a19fc32877681 (diff)
downloadconduit-1d00a8c41f92c0df5dac40299bf53134bcfa31b3.zip
improvement: better logging
Use CONDUIT_LOG or the log setting in the config
-rw-r--r--conduit-example.toml1
-rw-r--r--src/client_server/thirdparty.rs2
-rw-r--r--src/database.rs6
-rw-r--r--src/main.rs3
-rw-r--r--src/server_server.rs13
5 files changed, 18 insertions, 7 deletions
diff --git a/conduit-example.toml b/conduit-example.toml
index 3aca538..fea84bd 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 3c07699..fe5b784 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<get_protocols::Response> {
- warn!("TODO: get_protocols_route");
+ // TODO
Ok(get_protocols::Response {
protocols: BTreeMap::new(),
}
diff --git a/src/database.rs b/src/database.rs
index 47cee0d..b14a912 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -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,
diff --git a/src/main.rs b/src/main.rs
index 2ec3a42..327aefa 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 fa5706d..4912878 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::<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);
}