log panics to a file
This commit is contained in:
Generated
+45
@@ -156,6 +156,12 @@ version = "0.2.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
|
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android-tzdata"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "android_system_properties"
|
name = "android_system_properties"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
@@ -596,6 +602,20 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c"
|
||||||
|
dependencies = [
|
||||||
|
"android-tzdata",
|
||||||
|
"iana-time-zone",
|
||||||
|
"js-sys",
|
||||||
|
"num-traits",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clipboard-win"
|
name = "clipboard-win"
|
||||||
version = "5.4.0"
|
version = "5.4.0"
|
||||||
@@ -1369,6 +1389,7 @@ name = "gta-tools"
|
|||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"catppuccin-egui",
|
"catppuccin-egui",
|
||||||
|
"chrono",
|
||||||
"dirs",
|
"dirs",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
@@ -1426,6 +1447,30 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone"
|
||||||
|
version = "0.1.63"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8"
|
||||||
|
dependencies = [
|
||||||
|
"android_system_properties",
|
||||||
|
"core-foundation-sys",
|
||||||
|
"iana-time-zone-haiku",
|
||||||
|
"js-sys",
|
||||||
|
"log",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-core 0.61.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone-haiku"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icu_collections"
|
name = "icu_collections"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ edition = "2024"
|
|||||||
catppuccin-egui = { version = "5.5.0", default-features = false, features = [
|
catppuccin-egui = { version = "5.5.0", default-features = false, features = [
|
||||||
"egui31",
|
"egui31",
|
||||||
] }
|
] }
|
||||||
|
chrono = "0.4.40"
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
eframe = "0.31.1"
|
eframe = "0.31.1"
|
||||||
egui_extras = { version = "0.31.1", features = ["image"] }
|
egui_extras = { version = "0.31.1", features = ["image"] }
|
||||||
|
|||||||
+20
-2
@@ -9,11 +9,15 @@ use crate::{
|
|||||||
gui::{persistent_state::PersistentState, settings::Settings},
|
gui::{persistent_state::PersistentState, settings::Settings},
|
||||||
util::{
|
util::{
|
||||||
self,
|
self,
|
||||||
consts::{ENHANCED, GTA_WINDOW_TITLE, LEGACY},
|
consts::{APP_STORAGE_PATH, ENHANCED, GTA_WINDOW_TITLE, LEGACY},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use std::time::{Duration, Instant};
|
use std::{
|
||||||
|
fs,
|
||||||
|
io::Write,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
const WINDOW_SIZE: [f32; 2] = [240.0, 245.0];
|
const WINDOW_SIZE: [f32; 2] = [240.0, 245.0];
|
||||||
|
|
||||||
@@ -370,10 +374,24 @@ fn load_icon() -> egui::IconData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn panic_hook(panic_info: &std::panic::PanicHookInfo<'_>) {
|
||||||
|
let log_path = APP_STORAGE_PATH.join("panic.log");
|
||||||
|
let mut file = fs::File::options()
|
||||||
|
.create(true)
|
||||||
|
.append(true)
|
||||||
|
.open(log_path)
|
||||||
|
.unwrap();
|
||||||
|
let timestamp = chrono::Local::now().to_rfc3339();
|
||||||
|
let backtrace = std::backtrace::Backtrace::force_capture();
|
||||||
|
let message = format!("[{timestamp}]\n{panic_info}\n\n{backtrace}\n\n");
|
||||||
|
file.write_all(message.as_bytes()).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::unnecessary_wraps)]
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
fn app_creator(
|
fn app_creator(
|
||||||
cc: &eframe::CreationContext<'_>,
|
cc: &eframe::CreationContext<'_>,
|
||||||
) -> Result<Box<dyn eframe::App>, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<Box<dyn eframe::App>, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
|
std::panic::set_hook(Box::new(panic_hook));
|
||||||
let mut app = Box::<App>::default();
|
let mut app = Box::<App>::default();
|
||||||
if let Some(persistent_state) = PersistentState::get() {
|
if let Some(persistent_state) = PersistentState::get() {
|
||||||
app.launch.selected = persistent_state.launcher;
|
app.launch.selected = persistent_state.launcher;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{features::launch::Platform, gui::settings::Settings};
|
use crate::{features::launch::Platform, gui::settings::Settings, util::consts::APP_STORAGE_PATH};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
@@ -7,12 +7,7 @@ use std::{
|
|||||||
sync::LazyLock,
|
sync::LazyLock,
|
||||||
};
|
};
|
||||||
|
|
||||||
static CONFIG_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
|
static CONFIG_PATH: LazyLock<PathBuf> = LazyLock::new(|| APP_STORAGE_PATH.join("config.json"));
|
||||||
dirs::config_local_dir()
|
|
||||||
.unwrap()
|
|
||||||
.join("GTA Tools")
|
|
||||||
.join("config.json")
|
|
||||||
});
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct PersistentState {
|
pub struct PersistentState {
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
|
use std::{path::PathBuf, sync::LazyLock};
|
||||||
|
|
||||||
pub const ENHANCED: &str = "GTA5_Enhanced.exe";
|
pub const ENHANCED: &str = "GTA5_Enhanced.exe";
|
||||||
pub const LEGACY: &str = "GTA5.exe";
|
pub const LEGACY: &str = "GTA5.exe";
|
||||||
|
|
||||||
pub const GTA_WINDOW_TITLE: &str = "Grand Theft Auto V";
|
pub const GTA_WINDOW_TITLE: &str = "Grand Theft Auto V";
|
||||||
|
|
||||||
|
pub static APP_STORAGE_PATH: LazyLock<PathBuf> =
|
||||||
|
LazyLock::new(|| dirs::config_local_dir().unwrap().join("GTA Tools"));
|
||||||
|
|||||||
Reference in New Issue
Block a user