Skip to content

Commit

Permalink
feat: use tauri path resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
benolt authored and paulclindo committed Dec 18, 2024
1 parent d28be9d commit 360b07f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
32 changes: 9 additions & 23 deletions apps/shinkai-desktop/src-tauri/src/commands/logs.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
use std::env;
use tauri::Manager;

#[tauri::command]
pub async fn retrieve_logs() -> Result<String, String> {
let log_dir = {
#[cfg(target_os = "windows")]
{
let local_app_data = env::var("LOCALAPPDATA").map_err(|e| e.to_string())?;
format!("{}/com.shinkai.desktop/logs", local_app_data)
}

#[cfg(target_os = "linux")]
{
let home = env::var("HOME").map_err(|e| e.to_string())?;
format!("{}/.config/com.shinkai.desktop/logs", home)
}

#[cfg(target_os = "macos")]
{
let home = env::var("HOME").map_err(|e| e.to_string())?;
format!("{}/Library/Logs/com.shinkai.desktop", home)
}
};

let log_file = format!("{}/Shinkai Desktop.log", log_dir);
pub async fn retrieve_logs(app_handle: tauri::AppHandle) -> Result<String, String> {
let log_dir = app_handle.path().app_log_dir().map_err(|e| e.to_string())?;
let product_name = app_handle
.config()
.product_name
.clone()
.unwrap_or("Shinkai Desktop".to_string());
let log_file = format!("{}/{}.log", log_dir.display(), product_name);

let log_contents = match std::fs::read_to_string(log_file) {
Ok(contents) => contents,
Expand Down
6 changes: 5 additions & 1 deletion apps/shinkai-desktop/src/lib/shinkai-logs/logs-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ export const useRetrieveLogsQuery = (
...options,
});
return { ...query } as UseQueryResult<string, Error>;
};
};

export const retrieveLogs = async (): Promise<string> => {
return invoke('retrieve_logs');
};

0 comments on commit 360b07f

Please sign in to comment.