Add debug logging to file and fix blank startup screen
All checks were successful
Release / Bump version and tag (push) Successful in 5s
All checks were successful
Release / Bump version and tag (push) Successful in 5s
- Added write_log Tauri command that writes to frontend.log in app data dir - App.svelte now logs each startup step (Tauri import, sidecar check, launch) - Startup overlays use inline styles as fallback so they're visible even if CSS variables fail to load - Debug status shown on the checking/connecting screens - Rust side logs startup info to app.log (resource dir, data dir) Log files location: %APPDATA%/net.anhonesthost.local-transcription/ (Windows) or ~/Library/Application Support/net.anhonesthost.local-transcription/ (macOS) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,26 @@ mod sidecar;
|
||||
use std::sync::Mutex;
|
||||
use tauri::Manager;
|
||||
|
||||
/// App log directory, set during setup.
|
||||
static LOG_DIR: std::sync::OnceLock<std::path::PathBuf> = std::sync::OnceLock::new();
|
||||
|
||||
/// Write a log message to the app's log file (for debugging).
|
||||
#[tauri::command]
|
||||
fn write_log(message: String) {
|
||||
if let Some(log_dir) = LOG_DIR.get() {
|
||||
let log_path = log_dir.join("frontend.log");
|
||||
use std::io::Write;
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(&log_path)
|
||||
{
|
||||
let _ = writeln!(f, "[{}] {}", chrono::Local::now().format("%H:%M:%S%.3f"), message);
|
||||
}
|
||||
}
|
||||
eprintln!("[frontend] {}", message);
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
@@ -22,9 +42,22 @@ pub fn run() {
|
||||
.app_data_dir()
|
||||
.expect("failed to resolve app data dir");
|
||||
|
||||
// Ensure the data directory exists
|
||||
std::fs::create_dir_all(&data_dir).expect("failed to create app data dir");
|
||||
|
||||
// Set up logging
|
||||
LOG_DIR.set(data_dir.clone()).ok();
|
||||
let log_path = data_dir.join("app.log");
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(&log_path)
|
||||
{
|
||||
use std::io::Write;
|
||||
let _ = writeln!(f, "\n=== App started at {} ===", chrono::Local::now());
|
||||
let _ = writeln!(f, "Resource dir: {}", resource_dir.display());
|
||||
let _ = writeln!(f, "Data dir: {}", data_dir.display());
|
||||
}
|
||||
|
||||
sidecar::init_dirs(resource_dir, data_dir);
|
||||
Ok(())
|
||||
})
|
||||
@@ -35,6 +68,7 @@ pub fn run() {
|
||||
sidecar::get_sidecar_port,
|
||||
sidecar::start_sidecar,
|
||||
sidecar::stop_sidecar,
|
||||
write_log,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
Reference in New Issue
Block a user