feat: file logging on client, logs command to fetch last N lines
This commit is contained in:
parent
23bbb5b603
commit
db3fa9f416
6 changed files with 130 additions and 9 deletions
|
|
@ -13,6 +13,7 @@ use base64::Engine;
|
|||
use helios_common::{ClientMessage, ServerMessage};
|
||||
use uuid::Uuid;
|
||||
|
||||
mod logger;
|
||||
mod shell;
|
||||
mod screenshot;
|
||||
mod input;
|
||||
|
|
@ -76,21 +77,27 @@ macro_rules! log_status {
|
|||
}
|
||||
|
||||
macro_rules! log_ok {
|
||||
($($arg:tt)*) => {
|
||||
println!(" {}\t{}", "✅", format!($($arg)*));
|
||||
};
|
||||
($($arg:tt)*) => {{
|
||||
let msg = format!($($arg)*);
|
||||
println!(" {}\t{}", "✅", msg);
|
||||
logger::write_line("OK", &msg);
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! log_err {
|
||||
($($arg:tt)*) => {
|
||||
println!(" {}\t{}", "❌", format!($($arg)*));
|
||||
};
|
||||
($($arg:tt)*) => {{
|
||||
let msg = format!($($arg)*);
|
||||
println!(" {}\t{}", "❌", msg);
|
||||
logger::write_line("ERROR", &msg);
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! log_cmd {
|
||||
($emoji:expr, $($arg:tt)*) => {
|
||||
println!(" {}\t{}", $emoji, format!($($arg)*));
|
||||
};
|
||||
($emoji:expr, $($arg:tt)*) => {{
|
||||
let msg = format!($($arg)*);
|
||||
println!(" {}\t{}", $emoji, msg);
|
||||
logger::write_line("CMD", &msg);
|
||||
}};
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────
|
||||
|
|
@ -173,6 +180,7 @@ async fn main() {
|
|||
// Enable ANSI color codes on Windows (required when running as admin)
|
||||
#[cfg(windows)]
|
||||
enable_ansi();
|
||||
logger::init();
|
||||
|
||||
// Suppress tracing output by default
|
||||
if std::env::var("RUST_LOG").is_err() {
|
||||
|
|
@ -558,6 +566,13 @@ async fn handle_message(
|
|||
}
|
||||
}
|
||||
|
||||
ServerMessage::LogsRequest { request_id, lines } => {
|
||||
log_cmd!("📜", "logs (last {lines} lines)");
|
||||
let content = logger::tail(lines);
|
||||
let log_path = logger::get_log_path();
|
||||
ClientMessage::LogsResponse { request_id, content, log_path }
|
||||
}
|
||||
|
||||
ServerMessage::UploadRequest { request_id, path, content_base64 } => {
|
||||
log_cmd!("⬆ ", "upload → {}", path);
|
||||
match (|| -> Result<(), String> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue