Open CosminPerRam opened 4 months ago
Is this for just debug logging as we could just add a cfg assertion and print it.
eg
fn debug_print<T: std::fmt::Debug>(msg: T) {
if cfg!(debug_assertions) {
println!("{:?}", msg);
}
}
fn main() {
debug_print("This will only be printed in debug mode");
}
the log crate would be perfect for this
There's also tracing but that is a lot more complex.
eg
I wouldn't use something like this as the user couldn't control this with their log facade. Many libraries already use the log create for debug and stuff.
What is this feature about? Debug logs are very useful in examining behavior in all kinds of possible use cases. This helps in eventual user-encountered bugs.
Additional context/references Add debug logging like in the Node version:
(just a simple example of logging something)
The log crate would be perfect for this, I don't know any better alternatives.