Skip to content

Commit 1447ab8

Browse files
committed
refactor: clean up the logs and reduce noise
- Remove "Detected Autocrypt-mime message" logs printed for every incoming Autocrypt message. - Print only a single line at the beginning of receive_imf with both the Message-ID and seen flag. - Print Securejoin step only once, inside handle_securejoin_handshake or observe_securejoin_on_other_device. - Do not log "Not creating ad-hoc group" every time ad-hoc group is not created, log when it is created instead. - Log ID of the chat where Autocrypt-Gossip for all members is received. - Do not print "Secure-join requested." for {vg,vc}-request, we already log the step. - Remove ">>>>>>>>>>>>>>>>>>>>>>>>>" noise from securejoin logs.
1 parent d574ee4 commit 1447ab8

File tree

8 files changed

+25
-58
lines changed

8 files changed

+25
-58
lines changed

src/contact.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ impl Contact {
772772

773773
sth_modified = Modifier::Created;
774774
row_id = u32::try_from(transaction.last_insert_rowid())?;
775-
info!(context, "added contact id={} addr={}", row_id, &addr);
775+
info!(context, "Added contact id={row_id} addr={addr}.");
776776
}
777777
Ok(row_id)
778778
}).await?;

src/decrypt.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,14 @@ use crate::pgp;
2323
///
2424
/// If the message is wrongly signed, HashSet will be empty.
2525
pub fn try_decrypt(
26-
context: &Context,
2726
mail: &ParsedMail<'_>,
2827
private_keyring: &[SignedSecretKey],
2928
public_keyring_for_validate: &[SignedPublicKey],
3029
) -> Result<Option<(Vec<u8>, HashSet<Fingerprint>)>> {
31-
let encrypted_data_part = match {
32-
let mime = get_autocrypt_mime(mail);
33-
if mime.is_some() {
34-
info!(context, "Detected Autocrypt-mime message.");
35-
}
36-
mime
37-
}
38-
.or_else(|| {
39-
let mime = get_mixed_up_mime(mail);
40-
if mime.is_some() {
41-
info!(context, "Detected mixed-up mime message.");
42-
}
43-
mime
44-
})
45-
.or_else(|| {
46-
let mime = get_attachment_mime(mail);
47-
if mime.is_some() {
48-
info!(context, "Detected attached Autocrypt-mime message.");
49-
}
50-
mime
51-
}) {
30+
let encrypted_data_part = match get_autocrypt_mime(mail)
31+
.or_else(|| get_mixed_up_mime(mail))
32+
.or_else(|| get_attachment_mime(mail))
33+
{
5234
None => return Ok(None),
5335
Some(res) => res,
5436
};

src/e2ee.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,19 @@ impl EncryptHelper {
6262
for (peerstate, addr) in peerstates {
6363
match peerstate {
6464
Some(peerstate) => {
65-
info!(
66-
context,
67-
"peerstate for {:?} is {}", addr, peerstate.prefer_encrypt
68-
);
65+
let prefer_encrypt = peerstate.prefer_encrypt;
66+
info!(context, "Peerstate for {addr:?} is {prefer_encrypt}.");
6967
match peerstate.prefer_encrypt {
7068
EncryptPreference::NoPreference | EncryptPreference::Reset => {}
7169
EncryptPreference::Mutual => prefer_encrypt_count += 1,
7270
};
7371
}
7472
None => {
75-
let msg = format!("peerstate for {addr:?} missing, cannot encrypt");
73+
let msg = format!("Peerstate for {addr:?} missing, cannot encrypt");
7674
if e2ee_guaranteed {
77-
return Err(format_err!("{}", msg));
75+
return Err(format_err!("{msg}"));
7876
} else {
79-
info!(context, "{}", msg);
77+
info!(context, "{msg}.");
8078
return Ok(false);
8179
}
8280
}

src/mimefactory.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,7 @@ impl<'a> MimeFactory<'a> {
988988
{
989989
info!(
990990
context,
991-
"sending secure-join message \'{}\' >>>>>>>>>>>>>>>>>>>>>>>>>",
992-
"vg-member-added",
991+
"Sending secure-join message {:?}.", "vg-member-added",
993992
);
994993
headers.protected.push(Header::new(
995994
"Secure-Join".to_string(),
@@ -1071,10 +1070,7 @@ impl<'a> MimeFactory<'a> {
10711070
let msg = &self.msg;
10721071
let step = msg.param.get(Param::Arg).unwrap_or_default();
10731072
if !step.is_empty() {
1074-
info!(
1075-
context,
1076-
"sending secure-join message \'{}\' >>>>>>>>>>>>>>>>>>>>>>>>>", step,
1077-
);
1073+
info!(context, "Sending secure-join message {step:?}.");
10781074
headers
10791075
.protected
10801076
.push(Header::new("Secure-Join".into(), step.into()));

src/mimeparser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl MimeMessage {
278278

279279
let public_keyring = keyring_from_peerstate(decryption_info.peerstate.as_ref());
280280
let (mail, mut signatures, encrypted) = match tokio::task::block_in_place(|| {
281-
try_decrypt(context, &mail, &private_keyring, &public_keyring)
281+
try_decrypt(&mail, &private_keyring, &public_keyring)
282282
}) {
283283
Ok(Some((raw, signatures))) => {
284284
mail_raw = raw;

src/receive_imf.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ pub(crate) async fn receive_imf_inner(
139139
is_partial_download: Option<u32>,
140140
fetching_existing_messages: bool,
141141
) -> Result<Option<ReceivedMsg>> {
142-
info!(context, "Receiving message, seen={seen}...");
143-
144142
if std::env::var(crate::DCC_MIME_DEBUG).is_ok() {
145143
info!(
146144
context,
@@ -173,7 +171,7 @@ pub(crate) async fn receive_imf_inner(
173171
Ok(mime_parser) => mime_parser,
174172
};
175173

176-
info!(context, "Received message has Message-Id: {rfc724_mid}");
174+
info!(context, "Receiving message {rfc724_mid:?}, seen={seen}...");
177175

178176
// check, if the mail is already in our database.
179177
// make sure, this check is done eg. before securejoin-processing.
@@ -246,9 +244,7 @@ pub(crate) async fn receive_imf_inner(
246244
update_verified_keys(context, &mut mime_parser, from_id).await?;
247245

248246
let received_msg;
249-
if let Some(securejoin_step) = mime_parser.get_header(HeaderDef::SecureJoin) {
250-
info!(context, "Received securejoin step {securejoin_step}.");
251-
247+
if mime_parser.get_header(HeaderDef::SecureJoin).is_some() {
252248
let res;
253249
if incoming {
254250
res = handle_securejoin_handshake(context, &mime_parser, from_id)
@@ -332,7 +328,7 @@ pub(crate) async fn receive_imf_inner(
332328
{
333329
info!(
334330
context,
335-
"Received message contains Autocrypt-Gossip for all members, updating timestamp."
331+
"Received message contains Autocrypt-Gossip for all members of {chat_id}, updating timestamp."
336332
);
337333
if chat_id.get_gossiped_timestamp(context).await? < sent_timestamp {
338334
chat_id
@@ -2275,11 +2271,6 @@ async fn create_adhoc_group(
22752271
timestamp: i64,
22762272
) -> Result<Option<ChatId>> {
22772273
if mime_parser.is_mailinglist_message() {
2278-
info!(
2279-
context,
2280-
"Not creating ad-hoc group for mailing list message."
2281-
);
2282-
22832274
return Ok(None);
22842275
}
22852276

@@ -2300,7 +2291,6 @@ async fn create_adhoc_group(
23002291
}
23012292

23022293
if member_ids.len() < 3 {
2303-
info!(context, "Not creating ad-hoc group: too few contacts.");
23042294
return Ok(None);
23052295
}
23062296

@@ -2320,6 +2310,11 @@ async fn create_adhoc_group(
23202310
timestamp,
23212311
)
23222312
.await?;
2313+
2314+
info!(
2315+
context,
2316+
"Created ad-hoc group id={new_chat_id}, name={grpname:?}."
2317+
);
23232318
chat::add_to_chat_contacts_table(context, new_chat_id, member_ids).await?;
23242319

23252320
context.emit_event(EventType::ChatModified(new_chat_id));

src/securejoin.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,7 @@ pub(crate) async fn handle_securejoin_handshake(
287287
.get_header(HeaderDef::SecureJoin)
288288
.context("Not a Secure-Join message")?;
289289

290-
info!(
291-
context,
292-
">>>>>>>>>>>>>>>>>>>>>>>>> secure-join message \'{}\' received", step,
293-
);
290+
info!(context, "Received secure-join message {step:?}.");
294291

295292
let join_vg = step.starts_with("vg-");
296293

@@ -316,7 +313,6 @@ pub(crate) async fn handle_securejoin_handshake(
316313
warn!(context, "Secure-join denied (bad invitenumber).");
317314
return Ok(HandshakeMessage::Ignore);
318315
}
319-
info!(context, "Secure-join requested.",);
320316

321317
inviter_progress(context, contact_id, 300);
322318

@@ -554,7 +550,7 @@ pub(crate) async fn observe_securejoin_on_other_device(
554550
let step = mime_message
555551
.get_header(HeaderDef::SecureJoin)
556552
.context("Not a Secure-Join message")?;
557-
info!(context, "observing secure-join message \'{}\'", step);
553+
info!(context, "Observing secure-join message {step:?}.");
558554

559555
match step.as_str() {
560556
"vg-request-with-auth"

src/securejoin/bobstate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl BobState {
291291
) -> Result<Option<BobHandshakeStage>> {
292292
info!(
293293
context,
294-
"Bob Step 4 - handling vc-auth-require/vg-auth-required message"
294+
"Bob Step 4 - handling {{vc,vg}}-auth-required message."
295295
);
296296
if !encrypted_and_signed(context, mime_message, Some(self.invite.fingerprint())) {
297297
let reason = if mime_message.was_encrypted() {
@@ -333,7 +333,7 @@ impl BobState {
333333
) -> Result<Option<BobHandshakeStage>> {
334334
info!(
335335
context,
336-
"Bob Step 7 - handling vc-contact-confirm/vg-member-added message"
336+
"Bob Step 7 - handling vc-contact-confirm/vg-member-added message."
337337
);
338338
mark_peer_as_verified(
339339
context,

0 commit comments

Comments
 (0)