<commit_before>﻿using Cysharp.Text;
using Microsoft.Extensions.Logging;
using System;
using System.Buffers;
using System.Collections.Generic;
using ZLogger;

namespace LiteNetLibManager
{
    public static partial class LogManager
    {
        static ILogger noTagLogger;
        static ILoggerFactory loggerFactory;
        public static ILoggerFactory LoggerFactory
        {
            get => loggerFactory;
            set
            {
                if (loggerFactory != null)
                    loggerFactory.Dispose();
                LoggerByTypes.Clear();
                LoggerByTags.Clear();
                loggerFactory = value;
                noTagLogger = loggerFactory.CreateLogger("No Tag");
            }
        }
        static readonly Dictionary<string, ILogger> LoggerByTypes = new Dictionary<string, ILogger>();
        static readonly Dictionary<string, ILogger> LoggerByTags = new Dictionary<string, ILogger>();

        public static bool IsLoggerFactoryDisposed { get; private set; } = false;

        // Setup on first called GetLogger<T>.
        static LogManager()
        {
            // Standard LoggerFactory does not work on IL2CPP,
            // But you can use ZLogger's UnityLoggerFactory instead,
            // it works on IL2CPP, all platforms(includes mobile).
            LoggerFactory = UnityLoggerFactory.Create(builder =>
            {
                // or more configuration, you can use builder.AddFilter
                builder.SetMinimumLevel(LogLevel.Trace);

                // AddZLoggerUnityDebug is only available for Unity, it send log to UnityEngine.Debug.Log.
                // LogLevels are translate to
                // * Trace/Debug/Information -> LogType.Log
                // * Warning/Critical -> LogType.Warning
                // * Error without Exception -> LogType.Error
                // * Error with Exception -> LogException
                builder.AddZLoggerUnityDebug();
            });<commit_msg>Improve initialize codes<commit_after>﻿using Cysharp.Text;
using Microsoft.Extensions.Logging;
using System;
using System.Buffers;
using System.Collections.Generic;
using ZLogger;

namespace LiteNetLibManager
{
    public static partial class LogManager
    {
        static ILogger noTagLogger;
        static ILoggerFactory loggerFactory;
        public static ILoggerFactory LoggerFactory
        {
            get => loggerFactory;
            set
            {
                if (loggerFactory != null)
                    loggerFactory.Dispose();
                LoggerByTypes.Clear();
                LoggerByTags.Clear();
                loggerFactory = value;
                noTagLogger = loggerFactory.CreateLogger("No Tag");
            }
        }
        static readonly Dictionary<string, ILogger> LoggerByTypes = new Dictionary<string, ILogger>();
        static readonly Dictionary<string, ILogger> LoggerByTags = new Dictionary<string, ILogger>();

        public static bool IsLoggerFactoryDisposed { get; private set; } = false;

        [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)]
        public static void Initialize()
        {
            // Standard LoggerFactory does not work on IL2CPP,
            // But you can use ZLogger's UnityLoggerFactory instead,
            // it works on IL2CPP, all platforms(includes mobile).
            LoggerFactory = UnityLoggerFactory.Create(builder =>
            {
                // or more configuration, you can use builder.AddFilter
                builder.SetMinimumLevel(LogLevel.Trace);

                // AddZLoggerUnityDebug is only available for Unity, it send log to UnityEngine.Debug.Log.
                // LogLevels are translate to
                // * Trace/Debug/Information -> LogType.Log
                // * Warning/Critical -> LogType.Warning
                // * Error without Exception -> LogType.Error
                // * Error with Exception -> LogException
                builder.AddZLoggerUnityDebug();
            });
{'fraction_non_alphanumeric': 0.07694204685573366, 'fraction_numerical': 0.0009864364981504315, 'mean_word_length': 1.9519650655021834, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 24, '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': '2445874', 'n_tokens_mistral': 960, 'n_tokens_neox': 920, 'n_words': 266}