Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Support colored console output in Tests window
yanglee
#1 Posted : Wednesday, June 5, 2013 7:18:48 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2012(UTC)
Posts: 89
Location: China

Thanks: 23 times
Was thanked: 19 time(s) in 18 post(s)
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.

Remco
#2 Posted : Wednesday, June 5, 2013 11:21:28 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,135

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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.
yanglee
#3 Posted : Thursday, June 6, 2013 12:08:37 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2012(UTC)
Posts: 89
Location: China

Thanks: 23 times
Was thanked: 19 time(s) in 18 post(s)
Hi Remco,

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

Code:
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
yanglee
#4 Posted : Thursday, June 6, 2013 12:53:40 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2012(UTC)
Posts: 89
Location: China

Thanks: 23 times
Was thanked: 19 time(s) in 18 post(s)
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!

Code:
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Black;
Console.Write("Hello");
Remco
#5 Posted : Thursday, June 6, 2013 3:45:08 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,135

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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
1 user thanked Remco for this useful post.
yanglee on 6/6/2013(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.034 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download