#include #include #include #include #include #include #include #include Logger logger; static std::mutex mtx; Logger::Logger(const std::string ilabel) { label = ilabel; } Logger::Logger(void) { label = "global"; } void Logger::Log(const std::string& message) { auto now = std::chrono::system_clock::now(); std::chrono::zoned_time localnow{std::chrono::current_zone(), now}; std::string timenow = std::format("{:%Y-%m-%dT%H:%M:%OS%Z}", localnow); std::lock_guard lock(mtx); std::cout << std::format("{} {} {}\n", timenow, label, message); } void Logger::Logf(const std::string& format, ...) { auto now = std::chrono::system_clock::now(); std::chrono::zoned_time localnow{std::chrono::current_zone(), now}; std::string timenow = std::format("{:%Y-%m-%dT%H:%M:%OS%Z}", localnow); std::lock_guard lock(mtx); std::printf("%s %s ", timenow.c_str(), label.c_str()); va_list args; va_start(args, format); std::vprintf(format.data(), args); va_end(args); std::printf("\n"); }