log_macro 0.1.1

Macro to print variable name and value only (stripped from release builds)
Documentation

log_macro

Macro to print variable name and value only (stripped from release builds)

Install

cargo add log_macro

Use

Add this to top of file:

#[macro_use]
extern crate log_macro;

Then use like so:

let animals = vec!["cat", "dog", "horse", "zebra"];
let set: std::collections::HashSet<_> = animals.into_iter().collect();
log!(set);

Will print:

set: {"horse", "dog", "zebra", "cat"}

Implementation

Exported macro code is simply this:

#[macro_export]
macro_rules! log {
    ($var:expr) => {
        #[cfg(debug_assertions)]
        {
            println!("{}: {:?}", stringify!($var), $var);
        }
    };
}

Contribute

The tasks to do are outlined in existing issues and in tasks below (sorted by priority).

If issue/idea you have is not there, open new issue or start discussion.

Any PR with code/doc improvements is welcome. ✨

Join Discord for more indepth discussions on this repo and others.

Tasks

♥️

Support on GitHub or look into other projects.

MIT Twitter