#pragma once // Timestamped console log lines for the dedicated server. #include #include #include namespace bs { #if defined(__GNUC__) __attribute__((format(printf, 1, 2))) #endif inline void logf(const char* fmt, ...) { std::time_t t = std::time(nullptr); std::tm tm{}; #if defined(_WIN32) localtime_s(&tm, &t); #else localtime_r(&t, &tm); #endif std::printf("[%02d:%02d:%02d] ", tm.tm_hour, tm.tm_min, tm.tm_sec); va_list ap; va_start(ap, fmt); std::vprintf(fmt, ap); va_end(ap); std::printf("\n"); std::fflush(stdout); } } // namespace bs