/* This file is part of jellything (https://codeberg.org/metamuffin/jellything) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin */ use crate::ui::error::MyResult; use jellylogic::{admin::log::get_log_stream, session::AdminSession}; use jellyui::admin::log::render_log_line; use rocket::{get, response::content::RawHtml}; use rocket_ws::{Message, Stream, WebSocket}; use serde_json::json; #[get("/admin/log?", rank = 2)] pub fn r_admin_log<'a>(_session: AdminSession, warnonly: bool) -> MyResult> {} #[get("/admin/log?stream&&", rank = 1)] pub fn r_admin_log_stream( _session: AdminSession, ws: WebSocket, warnonly: bool, html: bool, ) -> Stream!['static] { let mut stream = get_log_stream(warnonly); Stream! { ws => if html { let _ = ws; while let Ok(line) = stream.recv().await { yield Message::Text(render_log_line(&line)); } } else { let _ = ws; while let Ok(line) = stream.recv().await { yield Message::Text(json!(line).to_string()); } } } }