Skip to content

Add docs for logging of queries. #1350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.*}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument name (key) is not the same in all queries, maybe point to https://github.com/rust-lang/rust/blob/87fd70c107b23fe08336a12a20a0f5e85561d499/compiler/rustc_middle/src/query/mod.rs#L18 so that people can browse the list of queries and see their arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point! I pushed an update to try to make that clearer.

```

## Broad module level filters

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