Skip to content

Commit b24d550

Browse files
authored
Add docs for logging of queries. (#1350)
1 parent 77f7fa2 commit b24d550

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/tracing.md

+24
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,30 @@ still get a short message per ignored `do_mir_borrowck`, but none of the things
6060
calls. This helps you in looking through the calls that are happening and helps you adjust
6161
your regex if you mistyped it.
6262

63+
## Query level filters
64+
65+
Every [query](query.md) is automatically tagged with a logging span so that
66+
you can display all log messages during the execution of the query. For
67+
example, if you want to log everything during type checking:
68+
69+
```
70+
RUSTC_LOG=[typeck]
71+
```
72+
73+
The query arguments are included as a tracing field which means that you can
74+
filter on the debug display of the arguments. For example, the `typeck` query
75+
has an argument `key: LocalDefId` of what is being checked. You can use a
76+
regex to match on that `LocalDefId` to log type checking for a specific
77+
function:
78+
79+
```
80+
RUSTC_LOG=[typeck{key=.*name_of_item.*}]
81+
```
82+
83+
Different queries have different arguments. You can find a list of queries and
84+
their arguments in
85+
[`rustc_middle/src/query/mod.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/query/mod.rs#L18).
86+
6387
## Broad module level filters
6488

6589
You can also use filters similar to the `log` crate's filters, which will enable

0 commit comments

Comments
 (0)