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
|
|
@ -135,6 +135,29 @@ pub async fn window_screenshot(
|
|||
}
|
||||
}
|
||||
|
||||
/// GET /sessions/:id/logs?lines=100
|
||||
pub async fn logs(
|
||||
Path(session_id): Path<String>,
|
||||
Query(params): Query<std::collections::HashMap<String, String>>,
|
||||
State(state): State<AppState>,
|
||||
) -> impl IntoResponse {
|
||||
let lines: u32 = params.get("lines").and_then(|v| v.parse().ok()).unwrap_or(100);
|
||||
match dispatch(&state, &session_id, "logs", |rid| {
|
||||
ServerMessage::LogsRequest { request_id: rid, lines }
|
||||
}).await {
|
||||
Ok(ClientMessage::LogsResponse { content, log_path, .. }) => (
|
||||
StatusCode::OK,
|
||||
Json(serde_json::json!({ "content": content, "log_path": log_path, "lines": lines })),
|
||||
).into_response(),
|
||||
Ok(ClientMessage::Error { message, .. }) => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(serde_json::json!({ "error": message })),
|
||||
).into_response(),
|
||||
Ok(_) => (StatusCode::BAD_GATEWAY, Json(serde_json::json!({ "error": "Unexpected response" }))).into_response(),
|
||||
Err(e) => e.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
/// POST /sessions/:id/screenshot
|
||||
pub async fn request_screenshot(
|
||||
Path(session_id): Path<String>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue