color-eyre icon indicating copy to clipboard operation
color-eyre copied to clipboard

Implement one line error printing for logging errors

Open yaahc opened this issue 4 years ago • 2 comments

Currently color_eyre only supports either printing the entire error report including all custom sections, the backtrace, and the span trace. This is a multiple line representation and it doesn't fit well in logs for long running applications. We should try to create an alternate format that fits into one line. Ideally we should print the spantrace first using the existing spantrace formatting logic used to format spans in log messages. The error messages will then be printed using the standard colon separated format error message: cause's error message: cause's cause's error message: ...

This however doesn't handle custom sections, I think it may be sufficient to escape newlines when printing the custom sections but this should be approached with caution.

yaahc avatar Jul 22 '20 18:07 yaahc

I would simply not print the custom sections (or provide an option to enable), and use the one-line mode as a minimal variant.

Stupremee avatar Aug 24 '20 20:08 Stupremee

I would simply not print the custom sections (or provide an option to enable), and use the one-line mode as a minimal variant.

I agree that we should skip the custom sections, the main goal of this change is to include the spantrace in the same style used when logging events in tracing. I've already done some work on this where I write a custom formatter for SpanTrace though it's iteration order is backwards due to restrictions in the SpanTrace interface and I ended up taking a break there because I couldn't come up with a format I liked well enough. Ideally we'd have some super slick tracing integration where when we're logged tracing is able to access the SpanID inside of our spantrace and do the appropriate formatting accordingly but I have no idea how to even start working towards that kinda support...

yaahc avatar Aug 24 '20 20:08 yaahc