#pragma once

#include "fmt/format.h"

#include "DllDefines.h"

#ifdef LEGACY_LOGGER
#include "LegacyDebugLog.h"
#include "LegacyDebugLogTiming.h"
#include "LegacyGuiEventLog.h"

extern UTILITYDLL CLegacyDebugLog       mitechDebug;
extern UTILITYDLL CLegacyDebugLogTiming mitechDebugLogTiming;
extern UTILITYDLL CLegacyGuiEventLog    mitechGuiEventLog;
#else

#include "spdlog/spdlog.h"

#include "LogManager.h"

using namespace mitech::utils::logging;
extern UTILITYDLL CLogManager logManager;
#endif

//
template <typename... Args>
void TraceLog(fmt::format_string<Args...> _fmt, Args&&... args)
{
    logManager.GetLogger(eLOGGER::DEBUG_LOG).Trace(_fmt, args...);
}

template <typename... Args>
void InfoLog(fmt::format_string<Args...> _fmt, Args&&... args)
{
    logManager.GetLogger(eLOGGER::DEBUG_LOG).Info(_fmt, args...);
}

template <typename... Args>
void DebugLog(fmt::format_string<Args...> _fmt, Args&&... args)
{
    logManager.GetLogger(eLOGGER::DEBUG_LOG).Log(_fmt, args...);
}

template <typename... Args>
void DebugLogTrace(bool bTraceData, fmt::format_string<Args...> _fmt, Args&&... args)
{
    if (bTraceData)
    {
        logManager.GetLogger(eLOGGER::DEBUG_LOG).Log(_fmt, args...);
    }
}

template <typename... Args>
void DebugLogError(bool bTraceData, fmt::format_string<Args...> _fmt, Args&&... args)
{
    if (bTraceData)
    {
        logManager.GetLogger(eLOGGER::DEBUG_LOG).Error(_fmt, args...);
    }
}

template <typename... Args>
void DebugLogTiming(fmt::format_string<Args...> _fmt, Args&&... args)
{
    logManager.GetLogger(eLOGGER::DEBUG_TIMING_LOG).Log(_fmt, args...);
}

template <typename... Args>
void DebugLogTimingTrace(bool bTraceData, fmt::format_string<Args...> _fmt, Args&&... args)
{
    if (bTraceData)
    {
        logManager.GetLogger(eLOGGER::DEBUG_TIMING_LOG).Log(_fmt, args...);
    }
}

template <typename... Args>
void GUIEventLog(fmt::format_string<Args...> _fmt, Args&&... args)
{
    logManager.GetLogger(eLOGGER::GUI_EVENT_LOG).Log(_fmt, args...);
}

std::shared_ptr<spdlog::logger> UTILITYDLL GetLogger(const std::string& strName);

void UTILITYDLL ShutdownLogging();

void UTILITYDLL StartDebugLog();
void UTILITYDLL StopDebugLog();

void UTILITYDLL StartDebugTimingLog();
void UTILITYDLL StopDebugTimingLog();

bool UTILITYDLL IsDebugLogStarted();
bool UTILITYDLL IsDebugLogTimingStarted();

// All GUI Activities Events Log
void UTILITYDLL StartGUIEventLog();
void UTILITYDLL StopGUIEventLog();