Skip to content

Commit

Permalink
Smaller instrumentation log on Envelope
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Jan 7, 2024
1 parent 731e2d2 commit 3fb20a0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions libsignal-service/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ impl<S, R> fmt::Debug for ServiceCipher<S, R> {
}
}

fn debug_envelope(envelope: &Envelope) -> String {
format!(
"Envelope {{ \
source_address: {:?}, \
source_device: {:?}, \
server_guid: {:?}, \
timestamp: {:?}, \
content: {} bytes, \
}}",
envelope.source_address(),
envelope.source_device(),
envelope.server_guid(),
envelope.timestamp(),
envelope.content().len(),
)
}

impl<S, R> ServiceCipher<S, R>
where
S: ProtocolStore + KyberPreKeyStore + SenderKeyStore + Clone,
Expand All @@ -70,7 +87,7 @@ where
/// Opens ("decrypts") an envelope.
///
/// Envelopes may be empty, in which case this method returns `Ok(None)`
#[tracing::instrument]
#[tracing::instrument(skip(envelope), fields(envelope = debug_envelope(&envelope)))]
pub async fn open_envelope(
&mut self,
envelope: Envelope,
Expand Down Expand Up @@ -102,7 +119,7 @@ where
/// Triage of legacy messages happens inside this method, as opposed to the
/// Java implementation, because it makes the borrow checker and the
/// author happier.
#[tracing::instrument]
#[tracing::instrument(skip(envelope), fields(envelope = debug_envelope(envelope)))]
async fn decrypt(
&mut self,
envelope: &Envelope,
Expand Down

0 comments on commit 3fb20a0

Please sign in to comment.