Hacker News new | ask | show | jobs
by nu11ptr 1159 days ago
I personally have never used a debugger in Rust. Logging and printing has typically been enough.

For those use cases where it is tough to see the output (tests, windows services, etc.) I wrote the `rdbg` set of crates. It is essentially identical to `dbg!` and `println!` macros, but delivers messages via a TCP socket to a simple command-line viewer (which can be on the same machine or remote). The design is such that it can be enabled and used the first time within a minute or two for "quick and dirty debugging". It can just as quickly be removed or turned into a no-op with a Rust feature.

Dependency: https://crates.io/crates/rdbg

Viewer: https://crates.io/crates/rdbg-view

EDIT: Apparently I need to update the README as I added the 'msgf' and 'valsf' macros that include auto-flush which is handy for short running programs where explicit flush doesn't work due to failing program/etc.

1 comments

Looks handy. When you're writing certain types of programs going the opposite way can be useful.

For ex I recently added a /debug/:map_id endpoint to a server I'm writing that just returns format! ("{:#?}", state.maps.get(id)).

Obviously that'd be completely inappropriate in many cases, but for this one polling the current state via curl was quite handy.