Log messages in info!() if DCC_MIME_DEBUG is set

Using println!() leads to reordered output on terminal. Moreover, println!() prints to stdout which
is not for logging.
This commit is contained in:
iequidoo
2023-01-02 13:09:44 -03:00
committed by iequidoo
parent 3b9a48ff5f
commit 27c6cfc958
3 changed files with 24 additions and 8 deletions

View File

@@ -94,9 +94,12 @@ pub(crate) async fn receive_imf_inner(
) -> Result<Option<ReceivedMsg>> {
info!(context, "Receiving message, seen={}...", seen);
if std::env::var(crate::DCC_MIME_DEBUG).unwrap_or_default() == "2" {
info!(context, "receive_imf: incoming message mime-body:");
println!("{}", String::from_utf8_lossy(imf_raw));
if std::env::var(crate::DCC_MIME_DEBUG).is_ok() {
info!(
context,
"receive_imf: incoming message mime-body:\n{}",
String::from_utf8_lossy(imf_raw),
);
}
let mut mime_parser =