Rust-for-Malware-Development

Debug only printing macros for testing

This module provides macros for conditional debug printing. These macros only output content during debug builds (e.g., when running cargo build or cargo run). In release builds (e.g., cargo build --release or cargo run --release), the print statements are completely omitted by the compiler, ensuring no performance overhead or unnecessary output in production.

This is useful for debugging purposes, such as logging intermediate values or states during development, without affecting the final release binary.

Usage

These macros support the same formatting syntax as Rust’s built-in print!, println!, eprint!, and eprintln! macros.

Example

dprintln!("This will only print in debug mode: {}", some_value);
deprint!("Error-like message to stderr in debug: {}", error_code);

Note: These macros rely on the #[cfg(debug_assertions)] attribute, which is enabled by default in debug builds and disabled in release builds.