<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace BenchmarkDotNet.Loggers
{
    public sealed class ConsoleLogger : ILogger
    {
        private const ConsoleColor DefaultColor = ConsoleColor.Gray;

        public static readonly ILogger Default = new ConsoleLogger();

        private readonly Dictionary<LogKind, ConsoleColor> colorScheme;

        public ConsoleLogger(Dictionary<LogKind, ConsoleColor> colorScheme = null)
        {
            this.colorScheme = colorScheme ?? CreateColorfulScheme();
        }

        public void Write(LogKind logKind, string text) => Write(logKind, Console.Write, text);

        public void WriteLine() => Console.WriteLine();

        public void WriteLine(LogKind logKind, string text) => Write(logKind, Console.WriteLine, text);

        private void Write(LogKind logKind, Action<string> write, string text)
        {
            var colorBefore = Console.ForegroundColor;

            try
            {
                Console.ForegroundColor = GetColor(logKind);
                write(text);
            }
            finally
            {
                Console.ForegroundColor = colorBefore;
            }
        }

        private ConsoleColor GetColor(LogKind logKind) =>
            colorScheme.ContainsKey(logKind) ? colorScheme[logKind] : DefaultColor;

        private static Dictionary<LogKind, ConsoleColor> CreateColorfulScheme() =>
            new Dictionary<LogKind, ConsoleColor>
            {
                { LogKind.Default, ConsoleColor.Gray },
                { LogKind.Help, ConsoleColor.DarkGreen },
                { LogKind.Header, ConsoleColor.Magenta },
                { LogKind.Result, ConsoleColor.DarkCyan },
                { LogKind.Statistic, ConsoleColor.Cyan },
                { LogKind.Info, ConsoleColor.DarkYellow },
                { LogKind.Error, ConsoleColor.Red },
                { LogKind.Hint, ConsoleColor.DarkBlue }
            };

        public static Dictionary<LogKind, ConsoleColor> CreateGrayScheme()
        {<commit_msg>Change Hint color to DarkCyan #376<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace BenchmarkDotNet.Loggers
{
    public sealed class ConsoleLogger : ILogger
    {
        private const ConsoleColor DefaultColor = ConsoleColor.Gray;

        public static readonly ILogger Default = new ConsoleLogger();

        private readonly Dictionary<LogKind, ConsoleColor> colorScheme;

        public ConsoleLogger(Dictionary<LogKind, ConsoleColor> colorScheme = null)
        {
            this.colorScheme = colorScheme ?? CreateColorfulScheme();
        }

        public void Write(LogKind logKind, string text) => Write(logKind, Console.Write, text);

        public void WriteLine() => Console.WriteLine();

        public void WriteLine(LogKind logKind, string text) => Write(logKind, Console.WriteLine, text);

        private void Write(LogKind logKind, Action<string> write, string text)
        {
            var colorBefore = Console.ForegroundColor;

            try
            {
                Console.ForegroundColor = GetColor(logKind);
                write(text);
            }
            finally
            {
                Console.ForegroundColor = colorBefore;
            }
        }

        private ConsoleColor GetColor(LogKind logKind) =>
            colorScheme.ContainsKey(logKind) ? colorScheme[logKind] : DefaultColor;

        private static Dictionary<LogKind, ConsoleColor> CreateColorfulScheme() =>
            new Dictionary<LogKind, ConsoleColor>
            {
                { LogKind.Default, ConsoleColor.Gray },
                { LogKind.Help, ConsoleColor.DarkGreen },
                { LogKind.Header, ConsoleColor.Magenta },
                { LogKind.Result, ConsoleColor.DarkCyan },
                { LogKind.Statistic, ConsoleColor.Cyan },
                { LogKind.Info, ConsoleColor.DarkYellow },
                { LogKind.Error, ConsoleColor.Red },
                { LogKind.Hint, ConsoleColor.DarkCyan }
            };

        public static Dictionary<LogKind, ConsoleColor> CreateGrayScheme()
        {
{'fraction_non_alphanumeric': 0.08375329973602112, 'fraction_numerical': 0.0007199424046076314, 'mean_word_length': 2.1671732522796354, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3219822', 'n_tokens_mistral': 1041, 'n_tokens_neox': 996, 'n_words': 233}