BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

Improve contrast in console (dark text on black console)

Open TysonMN opened this issue 5 years ago • 8 comments
trafficstars

When I run BenchmarkDotNet.Samples.FSharp, here is what the console looks like. 2019-12-19_10-59-11_10_BenchmarkDotNet Samples FSharp

The text is a dark color on a black background. I am having difficulty seeing the text.

Can this contrast be improved?

TysonMN avatar Dec 19 '19 17:12 TysonMN

Hello @bender2k14

Can this contrast be improved?

Yes, but it would require your contribution.

The colors are defined here Please feel free to experiment with them and send a PR.

Thanks, Adam

adamsitnik avatar Mar 24 '20 11:03 adamsitnik

Hello @adamsitnik, thanks for your response.

If you would prefer to reinvent logging (instead taking on dependency for logging), then I recommend copying how Serilog.Sinks.Console does it. Specifically, the coloring that you are currently using is fine but only apply it to the log type (which implies that it is also displayed). The primary text would be white (or off-white if someone wants to optimize it) on a black background, which is a high contract for easy reading.

What do you think?

TysonMN avatar Mar 24 '20 13:03 TysonMN

Do you mean using the same colors as Serilog?

obraz

I am fine with that. @AndreyAkinshin what do you think?

adamsitnik avatar Mar 24 '20 14:03 adamsitnik

@adamsitnik so, do I understand correctly that we are going to replace

{ LogKind.Help, ConsoleColor.DarkGreen },

with

{ LogKind.Help, ConsoleColor.White },

?

AndreyAkinshin avatar Mar 24 '20 15:03 AndreyAkinshin

@AndreyAkinshin yes, but we might also want to set bg color to red for error and yellow text color for warning

adamsitnik avatar Mar 24 '20 15:03 adamsitnik

Do you mean using the same colors as Serilog?

I don't care about the exact colors used. I am suggesting that the text to be logged should be white regardless of the log kind so that the contrast with the black background is high. That will make it easier to read. Instead of coloring the text to be logged, I am suggesting that an abbreviation of the log kind could be colored using your existing color scheme.

do I understand correctly that we are going to replace...

No. Sorry that I have been unclear. I created PR #1404 that makes the kind of change that I am talking about. It also includes a screenshot of the new behavior.

TysonMN avatar Mar 24 '20 15:03 TysonMN

I've marked the issue as up-for-grabs. Whoever is willing to work on this, please experiment with the color scheme that is defined here; https://github.com/dotnet/BenchmarkDotNet/blob/3223c94a92050147a02482a3810860703f0c5171/src/BenchmarkDotNet/Loggers/ConsoleLogger.cs#L64-L75

and find a better one ;)

adamsitnik avatar Oct 23 '20 18:10 adamsitnik

It seems that creating a palette based on the 16 terminal colors that look nice in all possible color themes in all possible terminals is an unsolvable task. Each terminal overrides the standard colors; and for the majority of colors, there is a terminal color theme in which the selected color is not so readable.

If we want to create a palette that is readable in all the terminals, we should go beyond the standard 16 colors and use at least 256 colors if it's an available option. Here are some of my thoughts about the implementation:

  1. 16-color mode should still be supported since not all the terminals support 256 colors. Only if 256 colors are supported, we should switch to the extended color palette.
  2. In the main BenchmarkDotNet package, we try to avoid any non-essential NuGet dependencies. Therefore, we don't want to reference any packages with advanced terminal color support.
  3. It seems that it's not so hard to implement 256-color support from scratch. As a source of inspiration, existing projects like Colorful.Console or Tamar.ANSITerm can be used. We are not interested in any advanced features; only extended color support is needed.

AndreyAkinshin avatar Oct 16 '23 16:10 AndreyAkinshin