Desktop: start.log line before Tauri starts (version, args, working folder, pid), so a logon start that dies early leaves a trace
This commit is contained in:
parent
03ef999dac
commit
4fe26326cc
1 changed files with 18 additions and 0 deletions
|
|
@ -198,7 +198,25 @@ fn dev_seed(data_dir: &std::path::Path) {
|
|||
}
|
||||
}
|
||||
|
||||
/// One line before Tauri starts: a start at logon that dies early (before the host log exists) still leaves a trace
|
||||
/// with its arguments and working folder (a logon start once left no line at all). Best effort, never fails.
|
||||
fn early_trace() {
|
||||
use std::io::Write;
|
||||
let base = std::env::var_os("APPDATA").or_else(|| std::env::var_os("XDG_DATA_HOME")).map(std::path::PathBuf::from)
|
||||
.or_else(|| std::env::var_os("HOME").map(|h| std::path::PathBuf::from(h).join(".local/share")));
|
||||
let Some(base) = base else { return };
|
||||
let dir = base.join("dev.storebound.desktop").join("logs");
|
||||
if std::fs::create_dir_all(&dir).is_err() { return }
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let cwd = std::env::current_dir().map(|d| d.display().to_string()).unwrap_or_default();
|
||||
let secs = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0);
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new().create(true).append(true).open(dir.join("start.log")) {
|
||||
let _ = writeln!(f, "{secs} start {} args={args:?} cwd={cwd} pid={}", env!("CARGO_PKG_VERSION"), std::process::id());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run() {
|
||||
early_trace();
|
||||
linux_webkit_env();
|
||||
let app = tauri::Builder::default()
|
||||
// single-instance first: a second start (or a storebound:// link) focuses the running app instead
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue