<commit_before>﻿using System;
using System.IO;
using log4net;
using log4net.Appender;
using log4net.Core;
using log4net.Layout;
using log4net.Repository.Hierarchy;

namespace HostMe
{
    public static class Logger
    {
        public static ILog GetLogger()
        {
            return LogManager.GetLogger("logger");
        }

        static Logger()
        {
            var patternLayout = new PatternLayout { ConversionPattern = "%d [%t] %-5p %m%n" };
            patternLayout.ActivateOptions();

            var hierarchy = (Hierarchy)LogManager.GetRepository();
            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;

            var consoleAppender = CreateColoredConsoleAppender(patternLayout);
            hierarchy.Root.AddAppender(consoleAppender);

            var rollingFileAppender = CreateRollingFileAppender(patternLayout);
            hierarchy.Root.AddAppender(rollingFileAppender);
        }

        private static IAppender CreateColoredConsoleAppender(ILayout layout)
        {
            var consoleAppender = new ColoredConsoleAppender { Layout = layout };

            consoleAppender.AddMapping(
                new ColoredConsoleAppender.LevelColors
                { Level = Level.Warn, ForeColor = ColoredConsoleAppender.Colors.Yellow });
<commit_msg>If User Interactive is false don't use console appender<commit_after>﻿using System;
using System.IO;
using log4net;
using log4net.Appender;
using log4net.Core;
using log4net.Layout;
using log4net.Repository.Hierarchy;

namespace HostMe
{
    public static class Logger
    {
        public static ILog GetLogger()
        {
            return LogManager.GetLogger("logger");
        }

        static Logger()
        {
            var patternLayout = new PatternLayout { ConversionPattern = "%d [%t] %-5p %m%n" };
            patternLayout.ActivateOptions();

            var hierarchy = (Hierarchy)LogManager.GetRepository();
            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;

            var rollingFileAppender = CreateRollingFileAppender(patternLayout);
            hierarchy.Root.AddAppender(rollingFileAppender);

            if (!Environment.UserInteractive)
                return;

            var consoleAppender = CreateColoredConsoleAppender(patternLayout);
            hierarchy.Root.AddAppender(consoleAppender);
        }

        private static IAppender CreateColoredConsoleAppender(ILayout layout)
        {
            var consoleAppender = new ColoredConsoleAppender { Layout = layout };

            consoleAppender.AddMapping(
                new ColoredConsoleAppender.LevelColors
                { Level = Level.Warn, ForeColor = ColoredConsoleAppender.Colors.Yellow });

{'fraction_non_alphanumeric': 0.07918634217217581, 'fraction_numerical': 0.004358881220486742, 'mean_word_length': 2.49492385786802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7101390', 'n_tokens_mistral': 719, 'n_tokens_neox': 720, 'n_words': 153}