Improve logging

This commit is contained in:
Andras Schmelczer 2025-11-29 14:22:05 +00:00
parent 4456767ec4
commit 84f077f36b
16 changed files with 90 additions and 34 deletions

View file

@ -50,7 +50,7 @@ impl Database {
.await
.with_context(|| {
format!(
"Failed to create databases directory: {}",
"Failed to create databases directory at `{}`",
config.databases_directory_path.to_string_lossy()
)
})?;
@ -110,7 +110,7 @@ impl Database {
.test_before_acquire(true)
.connect_with(connection_options)
.await
.with_context(|| format!("Cannot open database at {}", file_name.display()))?;
.with_context(|| format!("Cannot open database at `{}`", file_name.display()))?;
Self::run_migrations(&pool).await?;
@ -254,7 +254,7 @@ impl Database {
.await
}
.with_context(|| {
format!("Cannot fetch latest documents since vault_update_id {vault_update_id}")
format!("Cannot fetch latest documents since vault_update_id `{vault_update_id}`")
})
.map(|rows| {
rows.into_iter()
@ -489,10 +489,7 @@ impl Database {
// Close and remove idle pools
for vault_id in &vaults_to_remove {
if let Some(pool_with_timestamp) = pools.remove(vault_id) {
info!(
"Closing idle database connection pool for vault {}",
vault_id
);
info!("Closing idle database connection pool for vault `{vault_id}`");
pool_with_timestamp.pool.close().await;
}
}

View file

@ -1,6 +1,7 @@
use std::{collections::HashMap, sync::Arc};
use anyhow::Context;
use log::warn;
use tokio::sync::{Mutex, broadcast};
use super::models::WebSocketServerMessageWithOrigin;
@ -32,7 +33,7 @@ impl Broadcasts {
}
/// Notify all clients (who are subscribed to the vault) about an update.
/// We only log failures.
/// We only log failures and don't propagate them.
pub async fn send_document_update(
&self,
vault: VaultId,
@ -46,7 +47,7 @@ impl Broadcasts {
.map_err(server_error);
if result.is_err() {
log::debug!("Failed to send message: {result:?}");
warn!("Failed to send message: {result:?}");
}
}