mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-01 05:58:12 -06:00
Desktop: no eprintln! on the log and panic paths (#246)
eprintln! panics when standard error is a broken pipe (a GUI launch on Windows), and a panic inside the panic hook aborts. The "no log file" message goes through log::warn! (standard error only by then); the panic hook's fallback writes to standard error with write_fmt and ignores the error. Follow-up to #239, same fix as storytold/vectorcraft#465. Co-authored-by: Brandon Thomas <echelon@gmail.com>
This commit is contained in:
co-authored by
Brandon Thomas
parent
bfd60787eb
commit
7b1c015d06
@@ -86,7 +86,8 @@ fn main() -> eframe::Result {
|
||||
if log::log_enabled!(log::Level::Error) {
|
||||
log::error!("{report}");
|
||||
} else {
|
||||
eprintln!("pdfcraft: {report}");
|
||||
// `eprintln!` panics on a broken stderr pipe, and a panic inside the panic hook aborts.
|
||||
let _ = std::io::Write::write_fmt(&mut std::io::stderr(), format_args!("pdfcraft: {report}\n"));
|
||||
}
|
||||
}));
|
||||
let mut files = Vec::new();
|
||||
@@ -132,7 +133,8 @@ fn main() -> eframe::Result {
|
||||
if let (Some(logger), Some(dir)) = (logger, settings_dir()) {
|
||||
match logger.attach_dir(&dir.join("logs")) {
|
||||
Ok(path) => log::info!("PdfCraft {}, log file {}", env!("CARGO_PKG_VERSION"), path.display()),
|
||||
Err(e) => eprintln!("pdfcraft: no log file: {e}"),
|
||||
// Standard error only by now (`attach_dir` gave up on the file); unlike `eprintln!`, never panics.
|
||||
Err(e) => log::warn!("no log file: {e}"),
|
||||
}
|
||||
}
|
||||
let persistence_path = settings_dir().map(|d| d.join("app.ron"));
|
||||
|
||||
Reference in New Issue
Block a user