zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.74k stars 76 forks source link

Add concolor integration feature #58

Closed rumpuslabs closed 1 year ago

rumpuslabs commented 1 year ago

I started writing my own trait to wrap ariadne::Fmt to turn coloring on and off using concolor and then thought, why not push it upstream? I've made it an optional feature for backwards compatibility.

For the purposes of concolor's interactive terminal detection I've assumed that existing projects are writing to stderr but if they're not, they can switch to stdout by doing use ariadne::StdoutFmt instead of use ariadne::Fmt.

zesterer commented 1 year ago

Thanks! Does this mean that colour escape codes in the output won't be present if Write-ing to something like String?

rumpuslabs commented 1 year ago

No, they will be present if Write-ing to a String, the same as they are now. If feature = "concolor", then ariadne::Fmt will assume (for the purposes of concolor's interactive terminal detection) that the String will eventually be written to stderr. If that assumption is incorrect, the user can use ariadne::StdoutFmt instead to get the opposite assumption. If both stdout and stderr are interactive terminals (or concolor has not(feature = "interactive")), then it makes no difference.

zesterer commented 1 year ago

Thanks!