diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2020-11-19 18:45:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 15:45:13 +0000 |
commit | 768f9e22854231a95b96fea58c9e1a56bbc5ec89 (patch) | |
tree | 1950343daeed2173510dd5cb9c37a5bfc6eb7d63 | |
parent | c1f0e83cbbe03599f5828d421694399163f16076 (diff) | |
download | alacritty-768f9e22854231a95b96fea58c9e1a56bbc5ec89.tar.gz alacritty-768f9e22854231a95b96fea58c9e1a56bbc5ec89.zip |
Fix stdout log message order
This patch makes sure that the message for the creation of a log file is
always the first entry, before any other log file messages.
Since we initialize our log file dynamically, the message is printed as
soon as something is written to it. By making sure that we always write
to a file first and then try stdout, we can ensure that the log file is
always initialized before ever writing log messages to stdout.
-rw-r--r-- | alacritty/src/logging.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/alacritty/src/logging.rs b/alacritty/src/logging.rs index e2636b81..a7ca3ac7 100644 --- a/alacritty/src/logging.rs +++ b/alacritty/src/logging.rs @@ -110,11 +110,6 @@ impl log::Log for Logger { let now = time::strftime("%F %T.%f", &time::now()).unwrap(); let msg = format!("[{}] [{:<5}] [{}] {}\n", now, record.level(), target, record.args()); - // Write to stdout. - if let Ok(mut stdout) = self.stdout.lock() { - let _ = stdout.write_all(msg.as_ref()); - } - if let Ok(mut logfile) = self.logfile.lock() { // Write to logfile. let _ = logfile.write_all(msg.as_ref()); @@ -124,6 +119,11 @@ impl log::Log for Logger { self.message_bar_log(record, &logfile.path.to_string_lossy()); } } + + // Write to stdout. + if let Ok(mut stdout) = self.stdout.lock() { + let _ = stdout.write_all(msg.as_ref()); + } } fn flush(&self) {} |