mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-11-23 11:10:22 +00:00
Added debug logging
This commit is contained in:
parent
a6a52989b8
commit
ce302e7b98
@ -1,6 +1,6 @@
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use log::{error, info, trace, warn};
|
use log::{debug, error, info, trace, warn};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use rocket::{get, post};
|
use rocket::{get, post};
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
@ -46,84 +46,87 @@ pub fn start_tauri() {
|
|||||||
.build(tauri::generate_context!())
|
.build(tauri::generate_context!())
|
||||||
.expect("Error while running Tauri application");
|
.expect("Error while running Tauri application");
|
||||||
|
|
||||||
app.run(|app_handle, event| match event {
|
app.run(|app_handle, event| {
|
||||||
|
if !matches!(event, tauri::RunEvent::MainEventsCleared) {
|
||||||
tauri::RunEvent::WindowEvent { event, label, .. } => {
|
debug!(Source = "Tauri"; "Event received: {event:?}");
|
||||||
match event {
|
|
||||||
tauri::WindowEvent::CloseRequested { .. } => {
|
|
||||||
warn!(Source = "Tauri"; "Window '{label}': close was requested.");
|
|
||||||
}
|
|
||||||
|
|
||||||
tauri::WindowEvent::Destroyed => {
|
|
||||||
warn!(Source = "Tauri"; "Window '{label}': was destroyed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
tauri::WindowEvent::FileDrop(files) => {
|
|
||||||
info!(Source = "Tauri"; "Window '{label}': files were dropped: {files:?}");
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tauri::RunEvent::Updater(updater_event) => {
|
match event {
|
||||||
match updater_event {
|
tauri::RunEvent::WindowEvent { event, label, .. } => {
|
||||||
|
match event {
|
||||||
tauri::UpdaterEvent::UpdateAvailable { body, date, version } => {
|
tauri::WindowEvent::CloseRequested { .. } => {
|
||||||
let body_len = body.len();
|
warn!(Source = "Tauri"; "Window '{label}': close was requested.");
|
||||||
info!(Source = "Tauri"; "Updater: update available: body size={body_len} time={date:?} version={version}");
|
|
||||||
}
|
|
||||||
|
|
||||||
tauri::UpdaterEvent::Pending => {
|
|
||||||
info!(Source = "Tauri"; "Updater: update is pending!");
|
|
||||||
}
|
|
||||||
|
|
||||||
tauri::UpdaterEvent::DownloadProgress { chunk_length, content_length: _ } => {
|
|
||||||
trace!(Source = "Tauri"; "Updater: downloading chunk of {chunk_length} bytes");
|
|
||||||
}
|
|
||||||
|
|
||||||
tauri::UpdaterEvent::Downloaded => {
|
|
||||||
info!(Source = "Tauri"; "Updater: update has been downloaded!");
|
|
||||||
warn!(Source = "Tauri"; "Try to stop the .NET server now...");
|
|
||||||
|
|
||||||
if is_prod() {
|
|
||||||
stop_dotnet_server();
|
|
||||||
} else {
|
|
||||||
warn!(Source = "Tauri"; "Development environment detected; do not stop the .NET server.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tauri::UpdaterEvent::Updated => {
|
|
||||||
info!(Source = "Tauri"; "Updater: app has been updated");
|
|
||||||
warn!(Source = "Tauri"; "Try to restart the app now...");
|
|
||||||
|
|
||||||
if is_prod() {
|
|
||||||
app_handle.restart();
|
|
||||||
} else {
|
|
||||||
warn!(Source = "Tauri"; "Development environment detected; do not restart the app.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
tauri::WindowEvent::Destroyed => {
|
||||||
|
warn!(Source = "Tauri"; "Window '{label}': was destroyed.");
|
||||||
|
}
|
||||||
|
|
||||||
tauri::UpdaterEvent::AlreadyUpToDate => {
|
tauri::WindowEvent::FileDrop(files) => {
|
||||||
info!(Source = "Tauri"; "Updater: app is already up to date");
|
info!(Source = "Tauri"; "Window '{label}': files were dropped: {files:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
tauri::UpdaterEvent::Error(error) => {
|
_ => (),
|
||||||
warn!(Source = "Tauri"; "Updater: failed to update: {error}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tauri::RunEvent::ExitRequested { .. } => {
|
tauri::RunEvent::Updater(updater_event) => {
|
||||||
warn!(Source = "Tauri"; "Run event: exit was requested.");
|
match updater_event {
|
||||||
}
|
tauri::UpdaterEvent::UpdateAvailable { body, date, version } => {
|
||||||
|
let body_len = body.len();
|
||||||
|
info!(Source = "Tauri"; "Updater: update available: body size={body_len} time={date:?} version={version}");
|
||||||
|
}
|
||||||
|
|
||||||
tauri::RunEvent::Ready => {
|
tauri::UpdaterEvent::Pending => {
|
||||||
info!(Source = "Tauri"; "Run event: Tauri app is ready.");
|
info!(Source = "Tauri"; "Updater: update is pending!");
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {}
|
tauri::UpdaterEvent::DownloadProgress { chunk_length, content_length: _ } => {
|
||||||
|
trace!(Source = "Tauri"; "Updater: downloading chunk of {chunk_length} bytes");
|
||||||
|
}
|
||||||
|
|
||||||
|
tauri::UpdaterEvent::Downloaded => {
|
||||||
|
info!(Source = "Tauri"; "Updater: update has been downloaded!");
|
||||||
|
warn!(Source = "Tauri"; "Try to stop the .NET server now...");
|
||||||
|
|
||||||
|
if is_prod() {
|
||||||
|
stop_dotnet_server();
|
||||||
|
} else {
|
||||||
|
warn!(Source = "Tauri"; "Development environment detected; do not stop the .NET server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tauri::UpdaterEvent::Updated => {
|
||||||
|
info!(Source = "Tauri"; "Updater: app has been updated");
|
||||||
|
warn!(Source = "Tauri"; "Try to restart the app now...");
|
||||||
|
|
||||||
|
if is_prod() {
|
||||||
|
app_handle.restart();
|
||||||
|
} else {
|
||||||
|
warn!(Source = "Tauri"; "Development environment detected; do not restart the app.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tauri::UpdaterEvent::AlreadyUpToDate => {
|
||||||
|
info!(Source = "Tauri"; "Updater: app is already up to date");
|
||||||
|
}
|
||||||
|
|
||||||
|
tauri::UpdaterEvent::Error(error) => {
|
||||||
|
warn!(Source = "Tauri"; "Updater: failed to update: {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tauri::RunEvent::ExitRequested { .. } => {
|
||||||
|
warn!(Source = "Tauri"; "Run event: exit was requested.");
|
||||||
|
}
|
||||||
|
|
||||||
|
tauri::RunEvent::Ready => {
|
||||||
|
info!(Source = "Tauri"; "Run event: Tauri app is ready.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
warn!(Source = "Tauri"; "Tauri app was stopped.");
|
warn!(Source = "Tauri"; "Tauri app was stopped.");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user