| Crates.io | verbose-macros |
| lib.rs | verbose-macros |
| version | 0.1.1 |
| created_at | 2025-05-11 08:11:00.828853+00 |
| updated_at | 2025-05-11 09:30:37.044095+00 |
| description | A dependency-free macro library for **verbose!** and **debug!** printing in Rust. |
| homepage | |
| repository | https://github.com/veeso/verbose-macros |
| max_upload_size | |
| id | 1669199 |
| size | 16,722 |
A dependency-free macro library for verbose! and debug! printing in Rust.
I usually use log with all log levels for printing, but some people prefer to use just the --verbose and --debug flags.
For this reason, I created this library to provide a simple way to print verbose and debug messages without the need for any dependencies or setup to the log crate.
The library just provides the verbose! and debug! macros, which have the same syntax as println! and prints only if the flags for them are set.
Add the following to your Cargo.toml:
[dependencies]
verbose-macros = "0.1"
Then, you can use the macros in your code:
use verbose_macros::{debug, verbose};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let verbose = std::env::args().any(|arg| arg == "--verbose" || arg == "-v");
let debug = std::env::args().any(|arg| arg == "--debug" || arg == "-d");
// Set the debug and verbose flags
verbose_macros::set_debug(verbose);
verbose_macros::set_verbose(debug);
// Use the debug macro
debug!("This is a debug message.");
debug!("This is a debug message with a value: {}", 42);
// Use the verbose macro
verbose!("This is a verbose message.");
verbose!("This is a verbose message with a value: {}", 42);
Ok(())
}
This project is licensed under the MIT License.