<commit_before>﻿using LionFire.Structures;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;


namespace LionFire.Extensions.Logging
{

    public static class LogInitializer
    {
        public static ILogger GetLogger(this object obj, string name = null, bool isEnabled = true)
        {
            if (name == null) name = obj.GetType().FullName;

            ILogger l;

            var fac = ManualSingleton<IServiceProvider>.Instance?.GetService<ILoggerFactory>();
            if (isEnabled && fac != null)
            {
                l = fac.CreateLogger(name);
            }
            else
            {
                l = Singleton<NullLogger>.Instance;
            }

            return l;<commit_msg>micro DI for log initializer<commit_after>﻿using LionFire.Structures;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;


namespace LionFire.Extensions.Logging
{

    public static class LogInitializer
    {
        public static Func<string, ILogger> GetLoggerMethod;

        public static ILogger GetLogger(this object obj, string name = null, bool isEnabled = true)
        {
            if (!isEnabled) return Singleton<NullLogger>.Instance; ;

            if (name == null) name = obj.GetType().FullName;

            if (GetLoggerMethod != null)
            {
                return GetLoggerMethod(name);
            }

            var fac = ManualSingleton<IServiceProvider>.Instance?.GetService<ILoggerFactory>();
            if (fac != null)
            {
                return fac.CreateLogger(name);
            }

            return Singleton<NullLogger>.Instance;
{'fraction_non_alphanumeric': 0.08768154922001076, 'fraction_numerical': 0.0, 'mean_word_length': 2.32737030411449, 'pattern_counts': {'":': 0, '<': 11, '<?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': '6534309', 'n_tokens_mistral': 482, 'n_tokens_neox': 469, 'n_words': 117}