Skip to content

Commit 5f1eb54

Browse files
committed
Apply suggestions.
1 parent 0269071 commit 5f1eb54

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

crates/rust-analyzer/src/bin/args.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ FLAGS:
5050
-q, --quiet Set verbosity
5151
5252
--log-file <PATH> Log to the specified file instead of stderr
53-
--no-buffering Flush log records to the file immediately
53+
--no-log-buffering
54+
Flush log records to the file immediately
5455
5556
--wait-dbg Wait until a debugger is attached to.
5657
The flag is valid for debug builds only
@@ -139,7 +140,7 @@ impl Args {
139140
(false, true, true) => bail!("Invalid flags: -q conflicts with -v"),
140141
};
141142
let log_file = matches.opt_value_from_str("--log-file")?;
142-
let no_buffering = matches.contains("--no-buffering");
143+
let no_buffering = matches.contains("--no-log-buffering");
143144
let wait_dbg = matches.contains("--wait-dbg");
144145

145146
if matches.contains(["-h", "--help"]) {

crates/rust-analyzer/src/bin/logger.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ impl Log for Logger {
4747
if !self.filter.matches(record) {
4848
return;
4949
}
50-
match &self.file {
50+
51+
let should_flush = match &self.file {
5152
Some(w) => {
5253
let _ = writeln!(
5354
w.lock(),
@@ -56,16 +57,20 @@ impl Log for Logger {
5657
record.module_path().unwrap_or_default(),
5758
record.args(),
5859
);
60+
self.no_buffering
5961
}
60-
None => eprintln!(
61-
"[{} {}] {}",
62-
record.level(),
63-
record.module_path().unwrap_or_default(),
64-
record.args(),
65-
),
66-
}
62+
None => {
63+
eprintln!(
64+
"[{} {}] {}",
65+
record.level(),
66+
record.module_path().unwrap_or_default(),
67+
record.args(),
68+
);
69+
true // flush stderr unconditionally
70+
}
71+
};
6772

68-
if self.no_buffering {
73+
if should_flush {
6974
self.flush();
7075
}
7176
}

0 commit comments

Comments
 (0)