1
Fork 0

database: Add debug logging

This commit is contained in:
Steffo 2024-11-19 00:13:24 +01:00
parent 0c86515def
commit 86cdf48106
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -355,10 +355,13 @@ impl<DB> FromSql<diesel::sql_types::Text, DB> for Mime
String: FromSql<diesel::sql_types::Text, DB>,
{
fn from_sql(bytes: <DB as diesel::backend::Backend>::RawValue<'_>) -> diesel::deserialize::Result<Self> {
log::trace!("Reading TEXT from the database...");
let s = <String as FromSql<diesel::sql_types::Text, DB>>::from_sql(bytes)?;
log::trace!("Attempting to parse as a media type: {s:?}");
let mime = mime::Mime::from_str(&s)?;
log::trace!("Successfully parsed media type: {mime:?}");
Ok(Self(mime))
}
}
@ -370,8 +373,10 @@ impl<DB> ToSql<diesel::sql_types::Text, DB> for Mime
str: ToSql<diesel::sql_types::Text, DB>,
{
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> diesel::serialize::Result {
log::trace!("Getting the essence of a media type to prepare for serialization...");
let mime = self.0.essence_str();
log::trace!("Serializing media type as TEXT: {mime:?}");
<str as ToSql<diesel::sql_types::Text, DB>>::to_sql(mime, out)
}
}