1
0
Files
AstralRinth/theseus_gui/src/helpers/logs.js
Wyatt Verchere edd9f28081 Logs api (#103)
* not compiling; just to commit

* working logs commit

* prettier; clippy

* delete logs functions

* Reverted change

* mislabeled doc tag
2023-05-03 09:02:34 -07:00

48 lines
1.9 KiB
JavaScript

/**
* 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.
*/
import { invoke } from '@tauri-apps/api/tauri'
/*
A log is a struct containing the datetime string, stdout, and stderr, as follows:
pub struct Logs {
pub datetime_string: String,
pub stdout: String,
pub stderr: String,
}
*/
/// Get all logs that exist for a given profile
/// This is returned as an array of Log objects, sorted by datetime_string (the folder name, when the log was created)
export async function get_logs(profileUuid) {
return await invoke('logs_get_logs', { profileUuid })
}
/// Get a profile's log by datetime_string (the folder name, when the log was created)
export async function get_logs_by_datetime(profileUuid, datetimeString) {
return await invoke('logs_get_logs_by_datetime', { profileUuid, datetimeString })
}
/// Get a profile's stdout only by datetime_string (the folder name, when the log was created)
export async function get_stdout_by_datetime(profileUuid, datetimeString) {
return await invoke('logs_get_stdout_by_datetime', { profileUuid, datetimeString })
}
/// Get a profile's stderr only by datetime_string (the folder name, when the log was created)
export async function get_stderr_by_datetime(profileUuid, datetimeString) {
return await invoke('logs_get_stderr_by_datetime', { profileUuid, datetimeString })
}
/// Delete a profile's log by datetime_string (the folder name, when the log was created)
export async function delete_logs_by_datetime(profileUuid, datetimeString) {
return await invoke('logs_delete_logs_by_datetime', { profileUuid, datetimeString })
}
/// Delete all logs for a given profile
export async function delete_logs(profileUuid) {
return await invoke('logs_delete_logs', { profileUuid })
}