From 94788bee18fd7ba5eb000d2c223763308c2464e7 Mon Sep 17 00:00:00 2001 From: Erdem Yerebasmaz Date: Sat, 23 Mar 2024 19:42:12 +0300 Subject: [PATCH] Refactor "Log node-logs according to their level" --- libs/sdk-core/src/breez_services.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/sdk-core/src/breez_services.rs b/libs/sdk-core/src/breez_services.rs index cfc260cb9..124ffb142 100644 --- a/libs/sdk-core/src/breez_services.rs +++ b/libs/sdk-core/src/breez_services.rs @@ -1533,10 +1533,12 @@ impl BreezServices { log_message_res = log_stream.message() => { match log_message_res { Ok(Some(l)) => { - match l.line.to_ascii_lowercase() { - s if s.starts_with("unusual") => error!("node-logs: {}", l.line.split_at(7).1.trim_start()), - s if s.starts_with("info") => info!("node-logs: {}", l.line.split_at(4).1.trim_start()), - s if s.starts_with("debug") => debug!("node-logs: {}", l.line.split_at(5).1.trim_start()), + let prefix_len = l.line.find(':').map_or(0, |len| len + 2); + let log_message = l.line.split_at(prefix_len).1.trim_start(); + match l.line.to_ascii_lowercase().as_str() { + s if s.starts_with("unusual") => error!("node-logs: {}", log_message), + s if s.starts_with("info") => info!("node-logs: {}", log_message), + s if s.starts_with("debug") => debug!("node-logs: {}", log_message), _ => trace!("node-logs: {}", l.line) } },