Skip to content
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

Turning on specific log statements #144

Open
matklad opened this issue Oct 10, 2019 · 1 comment
Open

Turning on specific log statements #144

matklad opened this issue Oct 10, 2019 · 1 comment

Comments

@matklad
Copy link

matklad commented Oct 10, 2019

That's going on to be a crazy dream rather than specific issue, but nonetheless ...

I personally use eprintln rather than log::debug for debugging. log::debug seems like a better thing in theory (because you can reuse the same high-quality logs between different debugging sessions, and you don't need to recompile), but in practice launching code with logging enabled can be hard, and you typically get way more logging output than you need, even if you use filters.

Ideally, you'd just narrow-down logging to a single log statement, but that makes it even harder to set the relevant RUST_LOG env var.

I think this is a case where an IDE can be of great help! I imagine a feature, similar to debugger breakpoints in a graphical debugger, where you can enabled and disable log statements in the IDE on a case by case basis.

Specifically, an IDE maintains a list of active log statements, and, when the cursor is on the log::debug! call, the IDE offers an action to add/remove this particular statement from the set. When a user launches a test or a binary from withing IDE, IDE, known all active log statements, their positions and paths, construct an RUST_LOG env var, which enables only those selected log statements.

However, I think it's currently not possible to use such fine-grained filtering on the env_logger side. Specifically, I can only filter by module prefix, and by regex for all modules. What I need is either:

  • ability to filter by line number for each module
  • ability to filter by regex for each module

Additionally, matching on precis module path, and not prefix, would help as well.

I am not sure if it's worth pursuing this, and if I really have time right now to implement this on the rust-analyzer's side, but I thought that it might be good to log the issue anyway :)

@acowley
Copy link

acowley commented May 25, 2021

I'd like to be able to use precise module paths rather than prefixes, too. Might that be a smaller carve-out from the broader ideas here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants