7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | mod overview; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | mod sync; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | mod timer; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | use std::path::PathBuf; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | use clap::{Args, Subcommand}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | use crate::{Result, sh, workspace}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | #[derive(Args)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | pub struct LogArgs { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | #[clap(subcommand)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | cmd: LogCommand, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | /// Analysis around logs (formatted by `matrix-sdk-ffi`). |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | #[derive(Subcommand)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | enum LogCommand { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | /// Overview the logs as a tree where each node is a target and each leaf is |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | /// a log location with occurrences, spans and fields. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | Overview { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | /// The file containing the logs to analyse. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | #[clap(long)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | log_file: PathBuf, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | /// The output file that will receive the HTML report. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | #[clap(long)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | html_output_file: PathBuf, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | /// Visualise the sync requests and responses with a table and a duration |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | /// graph. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | Sync { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 35 | /// The file containing the logs to analyse. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 36 | #[clap(long)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 37 | log_file: PathBuf, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 38 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 39 | /// The output file that will receive the HTML report. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 40 | #[clap(long)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 41 | html_output_file: PathBuf, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 42 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 43 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 44 | /// Visualise the timers to detect bottlenecks. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 45 | Timer { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 46 | /// The file containing the logs to analyse. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 47 | #[clap(long)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 48 | log_file: PathBuf, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 49 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 50 | /// The output file that will receive the HTML report. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 51 | #[clap(long)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 52 | html_output_file: PathBuf, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 53 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 54 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 55 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 56 | impl LogArgs { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 57 | pub fn run(self) -> Result<()> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 58 | let sh = sh(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 59 | let _p = sh.push_dir(workspace::root_path()?); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 60 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 61 | match self.cmd { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 62 | LogCommand::Overview { log_file, html_output_file } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 63 | overview::run(log_file, html_output_file)? |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 64 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 65 | LogCommand::Sync { log_file, html_output_file } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 66 | sync::run(log_file, html_output_file)? |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 67 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 68 | LogCommand::Timer { log_file, html_output_file } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 69 | timer::run(log_file, html_output_file)? |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 70 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 71 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 72 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 73 | Ok(()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 74 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 75 | } |