<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MetroLog.Internal;

namespace MetroLog
{
    public static class LogManagerFactory
    {
        private static readonly ILogConfigurator _configurator = PlatformAdapter.Resolve<ILogConfigurator>();

        private static LoggingConfiguration _defaultConfig = _configurator.CreateDefaultSettings();

        private static readonly Lazy<ILogManager> _lazyLogManager;

        static LogManagerFactory()
        {
            _lazyLogManager = new Lazy<ILogManager>(() =>
                {
                    var config = DefaultConfiguration;
                    config.Freeze();

                    var manager = new LogManager(config);
                    _configurator.OnLogManagerCreated(manager);
                    return manager;
                },
                LazyThreadSafetyMode.ExecutionAndPublication);
        }
      
        public static LoggingConfiguration DefaultConfiguration
        {
            get
            {
                return _defaultConfig;
            }
            set
            {
                if (value == null)
                    throw new ArgumentNullException("value");
                if (_lazyLogManager.IsValueCreated)
                    throw new InvalidOperationException("Must set DefaultConfiguration before any calls to DefaultLogManager");

                _defaultConfig = value;
            }
        }

        public static ILogManager DefaultLogManager
        {
            get { return _lazyLogManager.Value; }
        }

    }
}<commit_msg>Expose factory method for advanced use<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MetroLog.Internal;

namespace MetroLog
{
    public static class LogManagerFactory
    {
        private static readonly ILogConfigurator _configurator = PlatformAdapter.Resolve<ILogConfigurator>();

        private static LoggingConfiguration _defaultConfig = _configurator.CreateDefaultSettings();

        private static readonly Lazy<ILogManager> _lazyLogManager;

        static LogManagerFactory()
        {
            _lazyLogManager = new Lazy<ILogManager>(() =>
                {
                    var config = DefaultConfiguration;
                    config.Freeze();

                    var manager = new LogManager(config);
                    _configurator.OnLogManagerCreated(manager);
                    return manager;
                },
                LazyThreadSafetyMode.ExecutionAndPublication);
        }
      
        public static ILogManager CreateLogManager(LoggingConfiguration config = null)
        {
            var cfg = config ?? DefaultConfiguration;
            cfg.Freeze();

            return new LogManager(cfg);
        }

        public static LoggingConfiguration DefaultConfiguration
        {
            get
            {
                return _defaultConfig;
            }
            set
            {
                if (value == null)
                    throw new ArgumentNullException("value");
                if (_lazyLogManager.IsValueCreated)
                    throw new InvalidOperationException("Must set DefaultConfiguration before any calls to DefaultLogManager");

                _defaultConfig = value;
            }
        }

        public static ILogManager DefaultLogManager
        {
            get { return _lazyLogManager.Value; }
        }

    }
}
{'fraction_non_alphanumeric': 0.061632426429761245, 'fraction_numerical': 0.0, 'mean_word_length': 1.8017107309486782, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '5082374', 'n_tokens_mistral': 837, 'n_tokens_neox': 797, 'n_words': 195}