Feature Suggestions

Support colored console output in Tests window

Started by yanglee on 11,533 views

Hi,

I use Serilog as logging framework in my apps. It can generate colored console output. It would be great if the colors can be displayed in Tests window output.

External image

Edited

Hi Yang,

How are you controlling the colour of your logged output? Is this done using ANSI colours?

NCrunch uses a rich text editor for the test window output, which should respond to RTF notation. You might find that if you convert the colour codes into this format that the rich text editor may pick it up. RTF is a bit of a hairy specification but in many cases a simple find and replace could give you quick and easy results.
Hi Remco,

Serilog uses ConsoleColor to control console output color, similar to the code below:

Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Black;
Console.WriteLine("Serilog output");


I will take a look at RTF and see if I can create a custom sink for Serilog that supports colored output for NCrunch.

Reference: Serilog's ColoredConsoleSink
Hi Remco,

Could you give me an example how to change the following code so that the colored output can be displayed in NCrunch's Tests window? Thanks!

Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Black;
Console.Write("Hello");
Hi Yang,

Sorry I gave this a try, although it looks as though the component is escaping the RTF sequences, preventing colours from showing. It looks as though a functional change will be needed to make this work.

At the moment, the rich text box used to show the trace output has a number of problems including poor performance and unicode display issues. It's highly likely that it will be replaced. I'll note your request down to try and consider custom colours in whatever it is replaced with.


Cheers,

Remco

Post a reply

Log in to reply.