#pragma once #include #include enum eFormatType : int8_t { NONE, TRACE, LOG, WARN, ERR, SYS, CHAT, }; namespace NFormatter { inline std::string fmt(eFormatType type, std::string str) { std::string prefix; switch (type) { case LOG: prefix = "[LOG] "; break; case WARN: prefix = "[WARN] "; break; case ERR: prefix = "[ERROR] "; break; case SYS: prefix = "[SYSTEM] "; break; case CHAT: prefix = "[CHAT] "; break; default: prefix = ""; break; } if (!str.empty() && str.back() != '\n' && !prefix.empty()) str += '\n'; return prefix + str; } template std::string fmt(eFormatType type, std::format_string fmt, Args &&...args) { return NFormatter::fmt(type, std::format(fmt, std::forward(args)...)); } } // namespace NFormatter