mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-20 00:57:22 -05:00
added debug text
This commit is contained in:
@@ -7,26 +7,19 @@ use tauri::{Emitter, Manager, State, WebviewUrl, WebviewWindowBuilder};
|
|||||||
|
|
||||||
fn debug_log(msg: &str) {
|
fn debug_log(msg: &str) {
|
||||||
let log_dir = if let Ok(app_data) = std::env::var("APPDATA") {
|
let log_dir = if let Ok(app_data) = std::env::var("APPDATA") {
|
||||||
std::path::PathBuf::from(app_data)
|
std::path::PathBuf::from(app_data).join("vyla-home").join("vyla-home-files").join("logs")
|
||||||
.join("vyla-home")
|
} else if let Ok(home) = std::env::var("HOME") {
|
||||||
.join("vyla-home-files")
|
std::path::PathBuf::from(home).join("Library").join("Logs").join("VylaHome")
|
||||||
.join("logs")
|
|
||||||
} else if let Ok(user_profile) = std::env::var("USERPROFILE") {
|
} else if let Ok(user_profile) = std::env::var("USERPROFILE") {
|
||||||
std::path::PathBuf::from(user_profile)
|
std::path::PathBuf::from(user_profile).join(".vyla-home").join("logs")
|
||||||
.join(".vyla-home")
|
|
||||||
.join("logs")
|
|
||||||
} else {
|
} else {
|
||||||
std::path::PathBuf::from("logs")
|
std::env::temp_dir().join("vyla-home-logs")
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = std::fs::create_dir_all(&log_dir);
|
let _ = std::fs::create_dir_all(&log_dir);
|
||||||
let log_path = log_dir.join("rust-debug.log");
|
let log_path = log_dir.join("rust-debug.log");
|
||||||
|
|
||||||
if let Ok(mut file) = std::fs::OpenOptions::new()
|
if let Ok(mut file) = std::fs::OpenOptions::new().create(true).append(true).open(&log_path) {
|
||||||
.create(true)
|
|
||||||
.append(true)
|
|
||||||
.open(&log_path)
|
|
||||||
{
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
let _ = writeln!(file, "[RUST] {}", msg);
|
let _ = writeln!(file, "[RUST] {}", msg);
|
||||||
}
|
}
|
||||||
@@ -652,11 +645,15 @@ fn main() {
|
|||||||
child.id()
|
child.id()
|
||||||
));
|
));
|
||||||
if let Some(stderr) = child.stderr.take() {
|
if let Some(stderr) = child.stderr.take() {
|
||||||
|
let w = window.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
let reader = BufReader::new(stderr);
|
let reader = BufReader::new(stderr);
|
||||||
for line in reader.lines().flatten() {
|
for line in reader.lines().flatten() {
|
||||||
debug_log(&format!("[NODE STDERR] {}", line));
|
debug_log(&format!("[NODE STDERR] {}", line));
|
||||||
|
if line.contains("Error") || line.contains("Exception") || line.contains("MODULE_NOT_FOUND") {
|
||||||
|
let _ = w.emit("error", serde_json::json!({ "message": format!("Backend failed: {}", line) }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,9 @@
|
|||||||
<div class="loader-container">
|
<div class="loader-container">
|
||||||
<div class="loader-card">
|
<div class="loader-card">
|
||||||
<div class="status-text" id="status-message">Starting runtime engine...</div>
|
<div class="status-text" id="status-message">Starting runtime engine...</div>
|
||||||
|
<div id="debug-log-box"
|
||||||
|
style="display: none; width: 100%; max-height: 180px; overflow-y: auto; background: rgba(255, 50, 50, 0.12); border: 1px solid rgba(255, 100, 100, 0.3); border-radius: 8px; padding: 12px; font-family: monospace; font-size: 12px; color: #fca5a5; text-align: left; white-space: pre-wrap; word-break: break-all; margin-bottom: 20px; user-select: text;">
|
||||||
|
</div>
|
||||||
<div class="progress-track" id="progress-track" style="display: none;">
|
<div class="progress-track" id="progress-track" style="display: none;">
|
||||||
<div class="progress-fill" id="progress-fill"></div>
|
<div class="progress-fill" id="progress-fill"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -257,7 +260,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -500,6 +503,7 @@ void main() {
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const statusEl = document.getElementById("status-message");
|
const statusEl = document.getElementById("status-message");
|
||||||
|
const debugBox = document.getElementById("debug-log-box");
|
||||||
const progressTrack = document.getElementById("progress-track");
|
const progressTrack = document.getElementById("progress-track");
|
||||||
const progressFill = document.getElementById("progress-fill");
|
const progressFill = document.getElementById("progress-fill");
|
||||||
const actionsEl = document.getElementById("update-actions");
|
const actionsEl = document.getElementById("update-actions");
|
||||||
@@ -524,6 +528,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showDebug(msg) {
|
||||||
|
if (!debugBox) return;
|
||||||
|
debugBox.style.display = "block";
|
||||||
|
debugBox.textContent = msg;
|
||||||
|
}
|
||||||
|
|
||||||
async function initTauriEvents() {
|
async function initTauriEvents() {
|
||||||
const eventApi = window.__TAURI__?.event || window.__TAURI_INTERNALS__;
|
const eventApi = window.__TAURI__?.event || window.__TAURI_INTERNALS__;
|
||||||
if (!eventApi || typeof eventApi.listen !== 'function') {
|
if (!eventApi || typeof eventApi.listen !== 'function') {
|
||||||
@@ -567,23 +577,15 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
eventApi.listen("error", (e) => {
|
eventApi.listen("error", (e) => {
|
||||||
setStatus("Cleaning up background processes...", "#fca5a5");
|
const data = e.payload || e;
|
||||||
try {
|
const msg = data && data.message ? data.message : JSON.stringify(data);
|
||||||
const core = window.__TAURI__?.core;
|
setStatus("Runtime Error", "#fca5a5");
|
||||||
if (core) {
|
showDebug(msg);
|
||||||
core.invoke("kill_orphans").finally(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
core.invoke("win_close").catch(() => {});
|
|
||||||
}, 500);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (err) { }
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
btnYes.addEventListener("click", () => {
|
btnYes.addEventListener("click", () => {
|
||||||
|
if (actionsEl) actionsEl.style.display = "none";
|
||||||
if (actionsEl) actionsEl.style.display = "none";
|
|
||||||
setStatus("Starting update installation...");
|
setStatus("Starting update installation...");
|
||||||
fetch("http://127.0.0.1:4891/update/yes", { method: "POST" }).catch(() => { });
|
fetch("http://127.0.0.1:4891/update/yes", { method: "POST" }).catch(() => { });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user