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

Add a dbg! macro like std::dbg! for quick-and-dirty debugging #185

Merged
merged 4 commits into from
Jan 7, 2025

Conversation

KodrAus
Copy link
Contributor

@KodrAus KodrAus commented Jan 7, 2025

Closes #168

This PR introduces emit::dbg!, a macro like std::dbg! for quick-and-dirty debugging:

let id = 42;
let user = "Rust";

emit::dbg!(user, id);

Instead of capturing values with Display + 'static by default, it captures using Debug. The macro produces a template for you, so the resulting event looks like:

Screenshot from 2025-01-07 11-41-04

You can also specify your own template if you like, just like you can with emit::debug!:

emit::dbg!("got {user} with {id}", user, id);

The motivations for this macro are the same as std::dbg!; you're actively working on some complex code and just want to see what it's doing. It's not intended for long-lived diagnostics, so should be considered a smell to see it hanging around.


Still to do:

  • UI tests
  • Update book
  • Update readme

@KodrAus KodrAus marked this pull request as ready for review January 7, 2025 05:08
@KodrAus KodrAus merged commit ac59e6d into main Jan 7, 2025
48 checks passed
@KodrAus KodrAus deleted the feat/dbg branch January 7, 2025 05:14
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

Successfully merging this pull request may close these issues.

Support shorthand for #[emit::as_debug]
1 participant