#pragma once

// third party library
#include "fmt/format.h"

#include "spdlog/pattern_formatter.h"
#include "spdlog/stopwatch.h"

// mitech library
// #include "utility.h"

class CTimingFormatterFlag : public spdlog::custom_flag_formatter
{
public:
    void format(const spdlog::details::log_msg&, const std::tm&, spdlog::memory_buf_t& dest) override
    {

        // auto myTime = m_HighResCounter.GetCurrentTimeSpanInMsec();

        // std::string strTime2 = fmt::format("{} | {:d}.{:03d}", strTime, (myTime / 1000), (myTime % 1000));

        std::string strTime = fmt::format("{:.3f}", m_stopWatch);
        dest.append(strTime.data(), strTime.data() + strTime.size());
    }

    std::unique_ptr<custom_flag_formatter> clone() const override
    {
        return spdlog::details::make_unique<CTimingFormatterFlag>();
    }

private:
    spdlog::stopwatch m_stopWatch;
    // CHighResPerformanceCounter m_HighResCounter;
};