serilog-sinks-console
serilog-sinks-console copied to clipboard
Support for all line colouring
What issue does this PR address? #35
Does this PR introduce a breaking change? Not expected. But please check.
Please check if the PR fulfills these requirements
- [x] The commit follows our guidelines
- [x] Unit Tests for the changes have been added (for bug fixes / features) Just changes. No extra tests.
Other information:
An example of a possible (if not somewhat ugly) output:

I'm unsure of line 26 in ThemedValueFormatterState.cs.
Also, there might be a cleaner way to keep the Events.LogEventLevel.Information statements out of the tests?
Finally I only implemented SystemConsoleThemes.Literate as an example as I have no clue what colouring defaults are appropriate.
Thanks!
I think all of the threading of the level through the various pieces is solid. I don't think we need to bake the idea of a "line style" into ConsoleTheme directly, though: if we overload Set() to optionally accept a level, then subclass themes could opt in to level-specific line colouring.
E.g. if, in ConsoleTheme we have:
public abstract int Set(TextWriter output, ConsoleThemeStyle style);
public virtual int Set(TextWriter output, ConsoleThemeStyle style, LogEventLevel level)
{
return Set(output, style);
}
This also avoids changing the signature of the public Set method, since it'd be a breaking change for subclasses.
(It might be one step too far, but with some tricky substitution, we could introduce a new Level member to ConsoleThemeStyle, and only trigger using the level-specific LevelDebug etc. members when falling back to the two-argument Set method.)
Here's what the old theme looked like, just for historical interest :-)

When can we expect a merge?
It would be great to see this PR live
Closing this one as stale, but if the OP or anyone following along is keen to follow up - I left some comments originally above; I think in order to merge this we'd also need at least one usable/aesthetically-pleasing example we could point folks to.