]> git.lizzy.rs Git - rust.git/commitdiff
make the logs line buffered
authormahdi-frms <mahdif1380@outlook.com>
Mon, 5 Jul 2021 15:16:09 +0000 (19:46 +0430)
committermahdi-frms <mahdif1380@outlook.com>
Mon, 5 Jul 2021 15:19:21 +0000 (19:49 +0430)
crates/rust-analyzer/src/bin/logger.rs

index 14887c5ccfefb10132fe2a8ce4a50e667c3edf44..35b3a9d696c7ad12073008db4c8c3cd56610e04a 100644 (file)
@@ -48,7 +48,7 @@ fn log(&self, record: &Record) {
             return;
         }
 
-        let should_flush = match &self.file {
+        match &self.file {
             Some(w) => {
                 let _ = writeln!(
                     w.lock(),
@@ -57,22 +57,21 @@ fn log(&self, record: &Record) {
                     record.module_path().unwrap_or_default(),
                     record.args(),
                 );
-                self.no_buffering
+
+                if self.no_buffering {
+                    self.flush();
+                }
             }
             None => {
-                eprintln!(
-                    "[{} {}] {}",
+                let message = format!(
+                    "[{} {}] {}\n",
                     record.level(),
                     record.module_path().unwrap_or_default(),
                     record.args(),
                 );
-                true // flush stderr unconditionally
+                eprint!("{}", message);
             }
         };
-
-        if should_flush {
-            self.flush();
-        }
     }
 
     fn flush(&self) {