Clean up debug impls

This commit is contained in:
Aode (Lion)
2021-09-21 14:32:25 -05:00
parent 4b4aaaa0b4
commit 3384ca9064
17 changed files with 182 additions and 31 deletions
+2 -2
View File
@@ -40,7 +40,7 @@ impl ActorCache {
ActorCache { db }
}
#[tracing::instrument(name = "Get Actor")]
#[tracing::instrument(name = "Get Actor", fields(id = id.to_string().as_str(), requests))]
pub(crate) async fn get(
&self,
id: &Url,
@@ -68,7 +68,7 @@ impl ActorCache {
self.db.remove_connection(actor.id.clone()).await
}
#[tracing::instrument(name = "Fetch remote actor")]
#[tracing::instrument(name = "Fetch remote actor", fields(id = id.to_string().as_str(), requests))]
pub(crate) async fn get_no_cache(&self, id: &Url, requests: &Requests) -> Result<Actor, Error> {
let accepted_actor = requests.fetch::<AcceptedActors>(id.as_str()).await?;
+2 -2
View File
@@ -19,7 +19,7 @@ impl MediaCache {
MediaCache { db }
}
#[tracing::instrument(name = "Get media uuid")]
#[tracing::instrument(name = "Get media uuid", fields(url = url.to_string().as_str()))]
pub(crate) async fn get_uuid(&self, url: Url) -> Result<Option<Uuid>, Error> {
self.db.media_id(url).await
}
@@ -55,7 +55,7 @@ impl MediaCache {
Ok(None)
}
#[tracing::instrument(name = "Store media url")]
#[tracing::instrument(name = "Store media url", fields(url = url.to_string().as_str()))]
pub(crate) async fn store_url(&self, url: Url) -> Result<Uuid, Error> {
let uuid = Uuid::new_v4();
+37 -7
View File
@@ -10,7 +10,7 @@ pub struct NodeCache {
db: Db,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[derive(Clone, serde::Deserialize, serde::Serialize)]
pub struct Node {
pub(crate) base: Url,
pub(crate) info: Option<Info>,
@@ -18,6 +18,17 @@ pub struct Node {
pub(crate) contact: Option<Contact>,
}
impl std::fmt::Debug for Node {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Node")
.field("base", &self.base.to_string())
.field("info", &self.info)
.field("instance", &self.instance)
.field("contact", &self.contact)
.finish()
}
}
impl NodeCache {
pub(crate) fn new(db: Db) -> Self {
NodeCache { db }
@@ -49,7 +60,7 @@ impl NodeCache {
Ok(vec)
}
#[tracing::instrument(name = "Is NodeInfo Outdated")]
#[tracing::instrument(name = "Is NodeInfo Outdated", fields(actor_id = actor_id.to_string().as_str()))]
pub(crate) async fn is_nodeinfo_outdated(&self, actor_id: Url) -> bool {
self.db
.info(actor_id)
@@ -58,7 +69,7 @@ impl NodeCache {
.unwrap_or(true)
}
#[tracing::instrument(name = "Is Contact Outdated")]
#[tracing::instrument(name = "Is Contact Outdated", fields(actor_id = actor_id.to_string().as_str()))]
pub(crate) async fn is_contact_outdated(&self, actor_id: Url) -> bool {
self.db
.contact(actor_id)
@@ -67,7 +78,7 @@ impl NodeCache {
.unwrap_or(true)
}
#[tracing::instrument(name = "Is Instance Outdated")]
#[tracing::instrument(name = "Is Instance Outdated", fields(actor_id = actor_id.to_string().as_str()))]
pub(crate) async fn is_instance_outdated(&self, actor_id: Url) -> bool {
self.db
.instance(actor_id)
@@ -76,7 +87,7 @@ impl NodeCache {
.unwrap_or(true)
}
#[tracing::instrument(name = "Save node info")]
#[tracing::instrument(name = "Save node info", fields(actor_id = actor_id.to_string().as_str(), software, version, reg))]
pub(crate) async fn set_info(
&self,
actor_id: Url,
@@ -97,7 +108,17 @@ impl NodeCache {
.await
}
#[tracing::instrument(name = "Save instance info")]
#[tracing::instrument(
name = "Save instance info",
fields(
actor_id = actor_id.to_string().as_str(),
title,
description,
version,
reg,
requires_approval
)
)]
pub(crate) async fn set_instance(
&self,
actor_id: Url,
@@ -122,7 +143,16 @@ impl NodeCache {
.await
}
#[tracing::instrument(name = "Save contact info")]
#[tracing::instrument(
name = "Save contact info",
fields(
actor_id = actor_id.to_string().as_str(),
username,
display_name,
url = url.to_string().as_str(),
avatar = avatar.to_string().as_str()
)
)]
pub(crate) async fn set_contact(
&self,
actor_id: Url,
+7 -4
View File
@@ -27,9 +27,6 @@ pub struct State {
impl std::fmt::Debug for State {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("State")
.field("public_key", &"PublicKey")
.field("private_key", &"[redacted]")
.field("object_cache", &"Object Cache")
.field("node_cache", &self.node_cache)
.field("breakers", &self.breakers)
.field("db", &self.db)
@@ -51,7 +48,13 @@ impl State {
)
}
#[tracing::instrument(name = "Get inboxes for other domains")]
#[tracing::instrument(
name = "Get inboxes for other domains",
fields(
existing_inbox = existing_inbox.to_string().as_str(),
domain
)
)]
pub(crate) async fn inboxes_without(
&self,
existing_inbox: &Url,