static void MBMatchServerLog(unsigned int LogLevel, const char* Msg, bool Newline) { static std::mutex LogMutex; std::lock_guard<std::mutex> Lock(LogMutex); char Str[1024 * 16]; ArrayView<char> Remaining = Str; auto Consumed = strftime(Str, sizeof(Str), "%FT%T%z", localtime(&unmove(time(0)))); if (!Consumed) { assert(false); return; } Remaining.remove_prefix(Consumed); auto Append = [&](const char* a) { auto Zero = strcpy_safe(Remaining, a); Remaining.remove_prefix(Zero - Remaining.data()); }; Append(" | "); Append(Msg); Append(Newline ? "\n" : ""); fputs(Str, stdout); if (LogLevel & MMatchServer::LOG_FILE) MLogFile(Str); #ifdef _DEBUG if (LogLevel & MMatchServer::LOG_DEBUG) { OutputDebugString(Msg); if (Newline) OutputDebugString("\n"); } #endif }