#pragma once #include "spdlog/spdlog.h" #include "source_location.h" #include #include namespace zlog { using level_enum = spdlog::level::level_enum; class zloger { private: std::shared_ptr m_logger; public: zloger(); ~zloger(); template void log(level_enum level, format_with_location& fmt, Args &&...args) { m_logger->log(fmt.loc, level, fmt::runtime(fmt.value), std::forward(args)...); } void flush() { m_logger->flush(); } }; ZLIB_API inline zloger zlog; template void info(format_with_location fmt, Args &&...args) { zlog.log(level_enum::info, fmt, std::forward(args)...); }; template void debug(format_with_location fmt, Args &&...args) { zlog.log(level_enum::debug, fmt, std::forward(args)...); }; template void warn(format_with_location fmt, Args &&...args) { zlog.log(level_enum::warn, fmt, std::forward(args)...); }; template void error(format_with_location fmt, Args &&...args) { zlog.log(level_enum::err, fmt, std::forward(args)...); }; template void fatal(format_with_location fmt, Args &&...args) { zlog.log(level_enum::critical, fmt, std::forward(args)...); const std::string format_str = fmt::format(std::forward(args)...); throw std::runtime_error(format_str); }; void flush(); };