aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Queseth <eskilq@kth.se>2020-10-14 14:49:56 +0200
committerEskil Queseth <eskilq@kth.se>2020-10-14 14:49:56 +0200
commitdcb71982eab550535298b2d879a3a83820a0798a (patch)
tree26ece7c95a0f244617721627510b516efaffcf80
parent289a6d79e5a117d225885e649ee7d20f46aad6a2 (diff)
downloadmum-dcb71982eab550535298b2d879a3a83820a0798a.tar.gz
add newline when logging if logged message contains a newline
-rw-r--r--mumd/src/main.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/mumd/src/main.rs b/mumd/src/main.rs
index 24c2567..a2665ba 100644
--- a/mumd/src/main.rs
+++ b/mumd/src/main.rs
@@ -23,11 +23,11 @@ use tokio::sync::{mpsc, watch};
#[tokio::main]
async fn main() {
// setup logger
- //TODO? add newline before message if it contains newlines
fern::Dispatch::new()
.format(|out, message, record| {
+ let message = message.to_string();
out.finish(format_args!(
- "{} {}:{} {}",
+ "{} {}:{}{}{}",
//TODO runtime flag that disables color
match record.level() {
Level::Error => "ERROR".red(),
@@ -38,6 +38,7 @@ async fn main() {
},
record.file().unwrap(),
record.line().unwrap(),
+ if message.chars().any(|e| e == '\n') { "\n" } else { " " },
message
))
})