killercup / killercup/convey

Provide a replacement for println

Open
#27 0 comments 0 reactions 0 assignees View on GitHub
design decision required
Dominant language
Rust
Stars
38
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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 the `Output` builder
- [ ] Provide a macro definition for `println!` that uses `format_args!` and passes the string to either the globally set `Output`, or write to stdout directly (so it works like the original macro if you accidentally import our macro but don't have an associated `Output`)
- [ ] 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!`

Contributor guide

Open the contributing guide

Research direction

Start by locating the Output builder and existing output-capture implementation, then inspect the crate's Cargo feature definitions and macro exports. Define the "println" feature, the Output.use_for_println() option, and replacements for println!, print!, eprintln!, and eprint!. Done means common macro usage is covered and JSON output remains valid when output is routed through convey.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.