#pragma once #include #include #include namespace sva { class Logging { std::unordered_map m_Level_Names; size_t m_Active_Level; std::ostream& m_Stream; public: Logging(std::ostream& stream); template requires std::is_enum_v std::string& levelName(const T lvl) { return m_Level_Names[static_cast(lvl)]; } template Logging& logln(Args&& ...args) { m_Stream << " [" << m_Level_Names[m_Active_Level] << "] " << (std::forward(args) << ...) << std::endl; return *this; } template requires std::is_enum_v Logging& operator()(const T lvl) { try { std::string& lvn = m_Level_Names.at(static_cast(lvl)); } catch (...) { return *this; } m_Active_Level = static_cast(lvl); return *this; } }; } #ifdef SVA_LOGGING_IMPLEMENTATION #undef SVA_LOGGING_IMPLEMENTATION sva::Logging::Logging(std::ostream& stream) : m_Active_Level(0), m_Stream(stream) { m_Level_Names[0] = "General"; } #endif