serilog-sinks-console icon indicating copy to clipboard operation
serilog-sinks-console copied to clipboard

Support for all line colouring

Open SixFive7 opened this issue 6 years ago • 3 comments

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: image

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.

SixFive7 avatar Nov 07 '19 19:11 SixFive7

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 :-)

image

nblumhardt avatar Nov 08 '19 04:11 nblumhardt

When can we expect a merge?

jwillmer avatar Nov 24 '20 13:11 jwillmer

It would be great to see this PR live

kyrylomyr avatar Oct 19 '21 07:10 kyrylomyr

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.

nblumhardt avatar Sep 05 '22 06:09 nblumhardt