2023-05-03 09:02:34 -07:00
|
|
|
/**
|
|
|
|
|
* All theseus API calls return serialized values (both return values and errors);
|
|
|
|
|
* So, for example, addDefaultInstance creates a blank Profile object, where the Rust struct is serialized,
|
|
|
|
|
* and deserialized into a usable JS object.
|
|
|
|
|
*/
|
2024-08-27 21:49:36 +02:00
|
|
|
import { invoke } from '@tauri-apps/api/core'
|
2023-05-03 09:02:34 -07:00
|
|
|
|
|
|
|
|
/*
|
2023-09-12 09:27:03 -07:00
|
|
|
A log is a struct containing the filename string, stdout, and stderr, as follows:
|
2023-05-03 09:02:34 -07:00
|
|
|
|
|
|
|
|
pub struct Logs {
|
2023-09-12 09:27:03 -07:00
|
|
|
pub filename: String,
|
2023-05-03 09:02:34 -07:00
|
|
|
pub stdout: String,
|
|
|
|
|
pub stderr: String,
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/// Get all logs that exist for a given profile
|
2023-09-12 09:27:03 -07:00
|
|
|
/// This is returned as an array of Log objects, sorted by filename (the folder name, when the log was created)
|
2023-07-26 20:33:03 -07:00
|
|
|
export async function get_logs(profilePath, clearContents) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:logs|logs_get_logs', { profilePath, clearContents })
|
2023-05-03 09:02:34 -07:00
|
|
|
}
|
|
|
|
|
|
2023-09-12 09:27:03 -07:00
|
|
|
/// Get a profile's log by filename
|
2024-05-09 13:29:19 -04:00
|
|
|
export async function get_logs_by_filename(profilePath, logType, filename) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:logs|logs_get_logs_by_filename', { profilePath, logType, filename })
|
2023-05-03 09:02:34 -07:00
|
|
|
}
|
|
|
|
|
|
2023-09-12 09:27:03 -07:00
|
|
|
/// Get a profile's log text only by filename
|
2024-05-09 13:29:19 -04:00
|
|
|
export async function get_output_by_filename(profilePath, logType, filename) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:logs|logs_get_output_by_filename', {
|
|
|
|
|
profilePath,
|
|
|
|
|
logType,
|
|
|
|
|
filename,
|
|
|
|
|
})
|
2023-05-03 09:02:34 -07:00
|
|
|
}
|
|
|
|
|
|
2023-09-12 09:27:03 -07:00
|
|
|
/// Delete a profile's log by filename
|
2024-05-09 13:29:19 -04:00
|
|
|
export async function delete_logs_by_filename(profilePath, logType, filename) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:logs|logs_delete_logs_by_filename', {
|
|
|
|
|
profilePath,
|
|
|
|
|
logType,
|
|
|
|
|
filename,
|
|
|
|
|
})
|
2023-05-03 09:02:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Delete all logs for a given profile
|
2023-07-26 20:33:03 -07:00
|
|
|
export async function delete_logs(profilePath) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:logs|logs_delete_logs', { profilePath })
|
2023-05-03 09:02:34 -07:00
|
|
|
}
|
2023-09-12 09:27:03 -07:00
|
|
|
|
|
|
|
|
/// Get the latest log for a given profile and cursor (startpoint to read withi nthe file)
|
|
|
|
|
/// Returns:
|
|
|
|
|
/*
|
|
|
|
|
{
|
|
|
|
|
cursor: u64
|
|
|
|
|
output: String
|
|
|
|
|
new_file: bool <- the cursor was too far, meaning that the file was likely rotated/reset. This signals to the frontend to clear the log and start over with this struct.
|
|
|
|
|
}
|
|
|
|
|
*/
|
2024-05-09 13:29:19 -04:00
|
|
|
|
2023-11-17 20:49:32 -08:00
|
|
|
// From latest.log directly
|
2023-09-12 09:27:03 -07:00
|
|
|
export async function get_latest_log_cursor(profilePath, cursor) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:logs|logs_get_latest_log_cursor', { profilePath, cursor })
|
2023-09-12 09:27:03 -07:00
|
|
|
}
|