mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 05:12:40 +03:00
ignore errors when writing to logs
For errors like eg: ENOSPC we shouldn't terminate the program when logging output. refs: https://github.com/wez/wezterm/issues/1839
This commit is contained in:
parent
5914a91490
commit
10dacf3d3b
@ -182,17 +182,26 @@ impl log::Log for Logger {
|
||||
let reset = if self.is_tty { "\u{1b}[0m" } else { "" };
|
||||
let target_color = if self.is_tty { "\u{1b}[1m" } else { "" };
|
||||
|
||||
eprintln!(
|
||||
"{} {level_color}{:6}{reset} {target_color}{:padding$}{reset} > {}",
|
||||
ts,
|
||||
level,
|
||||
target,
|
||||
msg,
|
||||
padding = padding,
|
||||
level_color = level_color,
|
||||
reset = reset,
|
||||
target_color = target_color
|
||||
);
|
||||
{
|
||||
// We use writeln! here rather than eprintln! so that we can ignore
|
||||
// a failed log write in the case that stderr has been redirected
|
||||
// to a device that is out of disk space.
|
||||
// <https://github.com/wez/wezterm/issues/1839>
|
||||
let mut stderr = std::io::stderr();
|
||||
let _ = writeln!(
|
||||
stderr,
|
||||
"{} {level_color}{:6}{reset} {target_color}{:padding$}{reset} > {}",
|
||||
ts,
|
||||
level,
|
||||
target,
|
||||
msg,
|
||||
padding = padding,
|
||||
level_color = level_color,
|
||||
reset = reset,
|
||||
target_color = target_color
|
||||
);
|
||||
let _ = stderr.flush();
|
||||
}
|
||||
|
||||
let mut file = self.file.lock().unwrap();
|
||||
if file.is_none() {
|
||||
|
Loading…
Reference in New Issue
Block a user