improvement: more logging

next
Timo Kösters 2020-11-15 12:17:21 +01:00
parent 9439f2c183
commit 6e36081573
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
7 changed files with 26 additions and 11 deletions

View File

@ -2,6 +2,7 @@ use std::{collections::BTreeMap, convert::TryInto};
use super::{State, DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH}; use super::{State, DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
use crate::{pdu::PduBuilder, utils, ConduitResult, Database, Error, Ruma}; use crate::{pdu::PduBuilder, utils, ConduitResult, Database, Error, Ruma};
use log::info;
use ruma::{ use ruma::{
api::client::{ api::client::{
error::ErrorKind, error::ErrorKind,
@ -510,6 +511,8 @@ pub async fn register_route(
)?; )?;
} }
info!("{} registered on this server", user_id);
db.flush().await?; db.flush().await?;
Ok(register::Response { Ok(register::Response {
@ -686,6 +689,8 @@ pub async fn deactivate_route(
// Remove devices and mark account as deactivated // Remove devices and mark account as deactivated
db.users.deactivate_account(&sender_user)?; db.users.deactivate_account(&sender_user)?;
info!("{} deactivated their account", sender_user);
db.flush().await?; db.flush().await?;
Ok(deactivate::Response { Ok(deactivate::Response {

View File

@ -1,5 +1,6 @@
use super::State; use super::State;
use crate::{server_server, ConduitResult, Database, Error, Result, Ruma}; use crate::{server_server, ConduitResult, Database, Error, Result, Ruma};
use log::info;
use ruma::{ use ruma::{
api::{ api::{
client::{ client::{
@ -82,8 +83,13 @@ pub async fn set_room_visibility_route(
db: State<'_, Database>, db: State<'_, Database>,
body: Ruma<set_room_visibility::Request<'_>>, body: Ruma<set_room_visibility::Request<'_>>,
) -> ConduitResult<set_room_visibility::Response> { ) -> ConduitResult<set_room_visibility::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
match body.visibility { match body.visibility {
room::Visibility::Public => db.rooms.set_public(&body.room_id, true)?, room::Visibility::Public => {
db.rooms.set_public(&body.room_id, true)?;
info!("{} made {} public", sender_user, body.room_id);
}
room::Visibility::Private => db.rooms.set_public(&body.room_id, false)?, room::Visibility::Private => db.rooms.set_public(&body.room_id, false)?,
} }

View File

@ -1,5 +1,6 @@
use super::State; use super::State;
use crate::{pdu::PduBuilder, ConduitResult, Database, Error, Ruma}; use crate::{pdu::PduBuilder, ConduitResult, Database, Error, Ruma};
use log::info;
use ruma::{ use ruma::{
api::client::{ api::client::{
error::ErrorKind, error::ErrorKind,
@ -323,6 +324,8 @@ pub async fn create_room_route(
db.rooms.set_public(&room_id, true)?; db.rooms.set_public(&room_id, true)?;
} }
info!("{} created a room", sender_user);
db.flush().await?; db.flush().await?;
Ok(create_room::Response::new(room_id).into()) Ok(create_room::Response::new(room_id).into())

View File

@ -1,5 +1,6 @@
use super::{State, DEVICE_ID_LENGTH, TOKEN_LENGTH}; use super::{State, DEVICE_ID_LENGTH, TOKEN_LENGTH};
use crate::{utils, ConduitResult, Database, Error, Ruma}; use crate::{utils, ConduitResult, Database, Error, Ruma};
use log::info;
use ruma::{ use ruma::{
api::client::{ api::client::{
error::ErrorKind, error::ErrorKind,
@ -93,6 +94,8 @@ pub async fn login_route(
body.initial_device_display_name.clone(), body.initial_device_display_name.clone(),
)?; )?;
info!("{} logged in", user_id);
db.flush().await?; db.flush().await?;
Ok(login::Response { Ok(login::Response {

View File

@ -39,9 +39,7 @@ impl Database {
/// Tries to remove the old database but ignores all errors. /// Tries to remove the old database but ignores all errors.
pub fn try_remove(server_name: &str) -> Result<()> { pub fn try_remove(server_name: &str) -> Result<()> {
let mut path = ProjectDirs::from("xyz", "koesters", "conduit") let mut path = ProjectDirs::from("xyz", "koesters", "conduit")
.ok_or_else(|| Error::bad_config( .ok_or_else(|| Error::bad_config("The OS didn't return a valid home directory path."))?
"The OS didn't return a valid home directory path.",
))?
.data_dir() .data_dir()
.to_path_buf(); .to_path_buf();
path.push(server_name); path.push(server_name);
@ -59,9 +57,9 @@ impl Database {
.map(|x| Ok::<_, Error>(x.to_owned())) .map(|x| Ok::<_, Error>(x.to_owned()))
.unwrap_or_else(|_| { .unwrap_or_else(|_| {
let path = ProjectDirs::from("xyz", "koesters", "conduit") let path = ProjectDirs::from("xyz", "koesters", "conduit")
.ok_or_else(|| Error::bad_config( .ok_or_else(|| {
"The OS didn't return a valid home directory path.", Error::bad_config("The OS didn't return a valid home directory path.")
))? })?
.data_dir() .data_dir()
.join(server_name); .join(server_name);

View File

@ -1,4 +1,4 @@
use std::{time::Duration, collections::HashMap, sync::RwLock, time::Instant}; use std::{collections::HashMap, sync::RwLock, time::Duration, time::Instant};
use log::error; use log::error;
use ruma::{ use ruma::{

View File

@ -61,9 +61,9 @@ where
return Err(Error::bad_config("Federation is disabled.")); return Err(Error::bad_config("Federation is disabled."));
} }
let resolver = AsyncResolver::tokio_from_system_conf() let resolver = AsyncResolver::tokio_from_system_conf().await.map_err(|_| {
.await Error::bad_config("Failed to set up trust dns resolver with system config.")
.map_err(|_| Error::bad_config("Failed to set up trust dns resolver with system config."))?; })?;
let mut host = None; let mut host = None;