From cb69a95adec4c6a92cde9001e899e639363d85d0 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 11 May 2022 21:56:26 -0700 Subject: [PATCH] Add docs for logging of queries. (#1350) --- src/tracing.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tracing.md b/src/tracing.md index 63d68e54..0bba73f7 100644 --- a/src/tracing.md +++ b/src/tracing.md @@ -60,6 +60,30 @@ still get a short message per ignored `do_mir_borrowck`, but none of the things calls. This helps you in looking through the calls that are happening and helps you adjust your regex if you mistyped it. +## Query level filters + +Every [query](query.md) is automatically tagged with a logging span so that +you can display all log messages during the execution of the query. For +example, if you want to log everything during type checking: + +``` +RUSTC_LOG=[typeck] +``` + +The query arguments are included as a tracing field which means that you can +filter on the debug display of the arguments. For example, the `typeck` query +has an argument `key: LocalDefId` of what is being checked. You can use a +regex to match on that `LocalDefId` to log type checking for a specific +function: + +``` +RUSTC_LOG=[typeck{key=.*name_of_item.*}] +``` + +Different queries have different arguments. You can find a list of queries and +their arguments in +[`rustc_middle/src/query/mod.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/query/mod.rs#L18). + ## Broad module level filters You can also use filters similar to the `log` crate's filters, which will enable