Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default color of console output #3046

Open
draptik opened this issue Sep 26, 2024 · 3 comments
Open

Change default color of console output #3046

draptik opened this issue Sep 26, 2024 · 3 comments
Labels
🚀 Feature request New feature or request good first issue hacktoberfest https://hacktoberfest.digitalocean.com

Comments

@draptik
Copy link
Contributor

draptik commented Sep 26, 2024

The default color of the console output is difficult to read when using a console with light background.
A similar issue was raised in the past: #1602

Describe the solution you'd like
The above ticket mentions that Stryker uses Serilog.Sinks.Console for generating the output.
Serilog provides an easy way to change the color theme:
https://github.com/serilog/serilog-sinks-console?tab=readme-ov-file#themes

Describe alternatives you've considered

  • Option 1: change the default theme to AnsiConsoleTheme.Sixteen. It's readable on dark and light backgroud (see screenshots below).
  • Option 2: make the color theme configurable.

This seems to be the relevant part in the current code, if I'm not mistaking:

LoggerFactory.AddSerilog(new LoggerConfiguration().MinimumLevel.Is(logLevel).Enrich.FromLogContext().WriteTo.Console().CreateLogger());

Additional context
20240926-113216-swappy
20240926-113329-swappy
20240926-113501-swappy
20240926-113537-swappy

using Serilog;
using Serilog.Sinks.SystemConsole.Themes;

namespace ConsoleApp1;

public static class Program
{
    public static void Main(string[] _)
    {
        // For details see https://github.com/serilog/serilog-sinks-console?tab=readme-ov-file#themes
        //var defaultTheme = AnsiConsoleTheme.Literate;
        //var selectedTheme = defaultTheme;
        var selectedTheme = AnsiConsoleTheme.Sixteen;
        
        Log.Logger = new LoggerConfiguration()
            .WriteTo.Console(theme: selectedTheme)
            .CreateLogger();
        
        Log.Information("Hello World!");
    }
}

What do you think?

@draptik draptik added the 🚀 Feature request New feature or request label Sep 26, 2024
@rouke-broersma rouke-broersma added hacktoberfest https://hacktoberfest.digitalocean.com good first issue labels Sep 26, 2024
@rouke-broersma
Copy link
Member

Sounds good to me

draptik added a commit to draptik/stryker-net that referenced this issue Sep 26, 2024
Using Serilog's AniConsoleTheme.Sixteen improves readability of the console log output on dark and light background consoles.
See stryker-mutator#3046 for details.
@bhargava-raju
Copy link

I want to work on this ticket, can you assign this to me

@rouke-broersma
Copy link
Member

@bhargava-raju please check the concerns on the existing PR here: #3047

If you feel you can address these issues, I will assign you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature request New feature or request good first issue hacktoberfest https://hacktoberfest.digitalocean.com
Projects
Status: No status
Development

No branches or pull requests

3 participants