From 094b39a0004d0163b5c37fdb3708b799a66cb643 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 9 May 2022 12:52:32 -0700 Subject: [PATCH 1/2] Add docs for logging of queries. --- src/tracing.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tracing.md b/src/tracing.md index 63d68e541..7e4d0cb25 100644 --- a/src/tracing.md +++ b/src/tracing.md @@ -60,6 +60,25 @@ 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 key is included as a tracing field which means that you can filter +on the debug display of the key. For example, the `typeck` query has a `DefId` +of what is being checked. You can use a regex to match on that `DefId` to log +type checking for a specific function: + +``` +RUSTC_LOG=[typeck{key=.*name_of_item.*}] +``` + ## Broad module level filters You can also use filters similar to the `log` crate's filters, which will enable From 97da13df03388ae719ced68325816b603fa9918d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 10 May 2022 10:34:23 -0700 Subject: [PATCH 2/2] Make it clearer that queries have different arguments and where to find them. --- src/tracing.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tracing.md b/src/tracing.md index 7e4d0cb25..0bba73f74 100644 --- a/src/tracing.md +++ b/src/tracing.md @@ -70,15 +70,20 @@ example, if you want to log everything during type checking: RUSTC_LOG=[typeck] ``` -The query key is included as a tracing field which means that you can filter -on the debug display of the key. For example, the `typeck` query has a `DefId` -of what is being checked. You can use a regex to match on that `DefId` to log -type checking for a specific function: +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