convey
convey copied to clipboard
Provide a replacement for println
Add a cargo feature that allows people to optionally pipe all println! (and similar) calls through convey, to make sure that all output is captured by us (to e.g. assert that only valid JSON documents can printed to stdout).
I'm not entirely sure how to best do this. Naively thinking I assume we can overwrite the macro exports from std and supply our own definitions that write to a globally registered convey::Output instance.
So, I'd try to do the following:
- [ ] Add a cargo feature "println"
- [ ] Add a
.use_for_println()flag to theOutputbuilder - [ ] Provide a macro definition for
println!that usesformat_args!and passes the string to either the globally setOutput, or write to stdout directly (so it works like the original macro if you accidentally import our macro but don't have an associatedOutput) - [ ] Fill in the other relevant macros (
print!,eprintln!,eprint!) - [ ] Test that common uses of the original macros work seamlessly
- [ ] Test that JSON output works when using our
println!