#pragma once

#include <array>
#include <map>

#include "DllDefines.h"

#include "LogSettings.h"
#include "Logger.h"

namespace mitech::utils::logging
{
    enum class eLOGGER
    {
        DEBUG_LOG,
        DEBUG_TIMING_LOG,
        GUI_EVENT_LOG,
        SG_DEBUG_LOG,
        MAX_LOGGER
    };

    class CLogManager
    {
    public:
        CLogManager();
        virtual ~CLogManager();

        void Initialize();
        void Shutdown() const;

        CLogger& GetLogger(eLOGGER eLog) { return *m_mapLogger[eLog]; }

    private:
        const std::map<eLOGGER, std::string> m_mapLoggerSettingFile{
            { eLOGGER::DEBUG_LOG, R"(d:\machine\config\debugLogSetting.json)" },
            { eLOGGER::DEBUG_TIMING_LOG, R"(d:\machine\config\debugLogTimingSetting.json)" },
            { eLOGGER::GUI_EVENT_LOG, R"(d:\machine\config\guiEventLogSetting.json)" },
            { eLOGGER::SG_DEBUG_LOG, R"(d:\machine\config\SGDebugLogSetting.json)" }
        };

        const std::string m_LoggerGlobalSettingFile{ R"(d:\machine\config\GlobalLogSetting.json)" };

        stLogGlobal                                 m_LoggerGlobalSetting;
        std::map<eLOGGER, stLogOption>              m_mapLoggerOption;
        std::map<eLOGGER, std::unique_ptr<CLogger>> m_mapLogger;
    };

    //
    class UTILITYDLL CLoggerManagerSingleton
    {
    public:
        /*
         * Disable copy constructor and assignment operators
         */
        class CLoggerManagerSingleton(const CLoggerManagerSingleton&)            = delete;
        class CLoggerManagerSingleton& operator=(const CLoggerManagerSingleton&) = delete;

        // accessor
        static CLoggerManagerSingleton& Instance();

        CLogManager& LoggerManager()
        {
            return m_loggerManager;
        }

    private:
        // private ctor
        CLoggerManagerSingleton()  = default;
        ~CLoggerManagerSingleton() = default;

        CLogManager m_loggerManager;
    };
}
