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:
extern crate log_macro;
Possible uses and outputs:
// print string only
log!; // -> hello
// print variable
let animals = vec!;
log!; // -> animals: ["cat", "dog"]
// print multiple variables
let animals = vec!;
let fish = vec!;
log!;
// each variable logged on new line
// -> animals: ["cat", "dog"]
// -> fish: ["salmon", "tuna"]
Implementation
Exported macro code is this:
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
- add ability to log multiple variables at once as mentioned
- add support for multiple values or different ways of formatting
- get the same level of utilities that Python’s formatted string literals have
> print(f”operation: {2+1=}”)->operation: 2+1=3
♥️
Support on GitHub or look into other projects.