diff --git a/README.md b/README.md new file mode 100644 index 0000000..9de675d --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ + +# Rustc Log Viewer + +This is a log viewer for rustc's tracing output (in JSON form). +It is made for when you don't yet know in advance how you want to filter your logs, +and to analyze a large amount of ouput and filter it down to what you want to see. +It's a TUI, and when you apply filters they get saved to disk. + +Filters rarely talk about the "nth log entry". +That way they are reproducible. +If you change something, rerun rustc, and gather logs again, the same set of filters will create a similar trace in the UI. +That way you can compare logs. + +The UI shows a kind of tree view, which you can navigate with arrow keys etc. +Only top-level logs are shown. With `Enter` you can step into a span and see the nested logs. +Press `?` for all possible keyboard shortcuts. +You can transform the tree in three ways: + +- Delete items (`alt+d`): delete all matching items. If no predicate is given, match only the current item. +- Inline items (`alt+r`): inlining means taking items that are otherwise nested (which you normally need to navigate into) and display them at the top level. +- Edit the printing of items (`alt+e`): WIP + +An explanation of how to target groups of logs can be found by typing `?`. + +## Gatherling logs + +To make it easy to gather logs, `lv` can be used as a wraper for `rustc` or `cargo` commands. +It has built-in presets for sets of rustc crates you might care about, and to ensure logs don't get too large. + +For example + +``` +lv types x test tests/ui/sometest.rs +lv types rustc +stage1 example.rs +lv show +``` + +Use `--compiler-root` to make sure links in the tui point to the right directory. And pick a nice theme! + +## Integration with `t` + +I built a tool to manage temporary directories: . +If you use that tool, you'll have a folder at `~/tempdirs`. +Logviewer follows that convention: if it finds that directory, logs go there. diff --git a/src/main.rs b/src/main.rs index 536bb1d..432f20f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,6 +50,12 @@ impl ValueEnum for Theme { } } +macro_rules! types_crates { + () => { + "rustc_hir_typeck,rustc_infer,rustc_next_trait_solver,rustc_middle,rustc_traits,rustc_trait_selection,rustc_type_ir,rustc_ty_utils" + } +} + #[derive(Subcommand, Debug)] enum Preset { /// Explore logs @@ -64,10 +70,11 @@ enum Preset { theme: Theme, }, - /// Get all the typesystem related logs + #[command(about = concat!("Get all the typesystem related logs: ", types_crates!()))] Types, /// Get all logs All, + /// Specific, comma-separated crates to gather logs from Crates { #[arg(short, long)] crates: Vec, @@ -87,7 +94,7 @@ fn default_tempdir() -> PathBuf { } #[derive(Parser, Debug)] -#[command(version, about, long_about = None)] +#[command(version, about, long_about)] struct Args { #[command(subcommand)] preset: Preset, @@ -113,14 +120,12 @@ fn main() { let rustc_log = match preset { Preset::Show { compiler_root, - theme: Theme(theme) - }=> { + theme: Theme(theme), + } => { tui::run(logs_dir, compiler_root, theme); exit(0); } - Preset::Types => { - "rustc_hir_typeck,rustc_infer,rustc_next_trait_solver,rustc_middle,rustc_traits,rustc_trait_selection,rustc_type_ir,rustc_ty_utils".to_string() - } + Preset::Types => types_crates!().to_string(), Preset::All => "debug".to_string(), Preset::Crates { crates } => crates.join(",").to_string(), }; diff --git a/src/tui/mod.rs b/src/tui/mod.rs index 8b7c8e1..984cdfd 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -68,7 +68,7 @@ targeting logs: either a field after `f` or the text of the current log: p ... with a prefix - r ... matching a regex + / ... matching a regex e ... equal to selected c ... containing