Skip to content

Provide a replacement for println #27

Description

@killercup

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    design decision requiredIt's not yet decided how best to implement this.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions