diff --git a/source/dapinterface/DapInterface.cpp b/source/dapinterface/DapInterface.cpp index 77a6cbf286..ce0baeadd3 100644 --- a/source/dapinterface/DapInterface.cpp +++ b/source/dapinterface/DapInterface.cpp @@ -160,7 +160,7 @@ namespace DAP continue; } - LOGMESSAGE("Accepted connection from %s", inet_ntoa(clientAddr.sin_addr)); + LOGMESSAGE("Accepted connection from {}", inet_ntoa(clientAddr.sin_addr)); std::lock_guard lock{m_ConnectionLock}; this->HandleClient(); LOGMESSAGE("Client Disconnected"); @@ -178,7 +178,7 @@ namespace DAP if (bytesRead <= 0) break; message.append(buffer, static_cast(bytesRead)); - LOGMESSAGE("Received message: %s", message.c_str()); + LOGMESSAGE("Received message: {}", message); while (!message.empty()) { @@ -215,7 +215,7 @@ namespace DAP // Return DAP message with protocol headers. const std::string dapResponse{"Content-Length: " + std::to_string(response.size()) + "\r\n\r\n" + response}; - LOGMESSAGE("Sending response to client: %s", dapResponse.c_str()); + LOGMESSAGE("Sending response to client: {}", dapResponse); send(m_ClientSocket, dapResponse.c_str(), dapResponse.size(), 0); // Validate if there more messages. @@ -406,7 +406,7 @@ namespace DAP // Send to socket client. const std::string dapResponse{"Content-Length: " + std::to_string(ret.size()) + "\r\n\r\n" + ret}; - LOGMESSAGE("Sending event to client: %s", ret.c_str()); + LOGMESSAGE("Sending event to client: {}", ret); m_SocketImpl->SendToClient(dapResponse); } } diff --git a/source/graphics/ColladaManager.cpp b/source/graphics/ColladaManager.cpp index 5f4b12b003..8df53e7916 100644 --- a/source/graphics/ColladaManager.cpp +++ b/source/graphics/ColladaManager.cpp @@ -50,7 +50,7 @@ namespace VfsPath* path = static_cast(cb_data); if (severity == LOG_INFO) - LOGMESSAGE("%s: %s", path->string8(), text); + LOGMESSAGE("{}: {}", path->string8(), text); else if (severity == LOG_WARNING) LOGWARNING("%s: %s", path->string8(), text); else @@ -107,7 +107,7 @@ public: if (!dll.IsLoaded() && !TryLoadDLL()) return ERR::FAIL; - LOGMESSAGE("Hotloading skeleton definitions from '%s'", path.string8()); + LOGMESSAGE("Hotloading skeleton definitions from '{}'", path.string8()); // Set the filename for the logger to report set_logger(ColladaLog, const_cast(static_cast(&path))); @@ -229,7 +229,7 @@ public: bool loaded = false; for (const VfsPath& path : pathnames) { - LOGMESSAGE("Loading skeleton definitions from '%s'", path.string8()); + LOGMESSAGE("Loading skeleton definitions from '{}'", path.string8()); // Set the filename for the logger to report set_logger(ColladaLog, const_cast(static_cast(&path))); diff --git a/source/graphics/MapGenerator.cpp b/source/graphics/MapGenerator.cpp index eb5ad41f54..cb41f92fbe 100644 --- a/source/graphics/MapGenerator.cpp +++ b/source/graphics/MapGenerator.cpp @@ -164,7 +164,7 @@ private: { for (const VfsPath& p : pathnames) { - LOGMESSAGE("Loading map generator script '%s'", p.string8()); + LOGMESSAGE("Loading map generator script '{}'", p.string8()); if (!m_ScriptInterface.LoadGlobalScriptFile(p)) { @@ -394,7 +394,7 @@ Script::StructuredClone RunMapGenerationScript(const StopToken stopToken, std::a } // Load RMS - LOGMESSAGE("Loading RMS '%s'", script.string8()); + LOGMESSAGE("Loading RMS '{}'", script.string8()); auto compileResult = scriptInterface.GetModuleLoader().LoadModule(rq, script); scriptInterface.GetContext().RunJobs(); auto& future = *compileResult.begin(); diff --git a/source/graphics/SkeletonAnimManager.cpp b/source/graphics/SkeletonAnimManager.cpp index 961220e6bc..a3f9fd3522 100644 --- a/source/graphics/SkeletonAnimManager.cpp +++ b/source/graphics/SkeletonAnimManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -77,7 +77,10 @@ CSkeletonAnimDef* CSkeletonAnimManager::GetAnimation(const VfsPath& pathname) } if (def) - LOGMESSAGE("CSkeletonAnimManager::GetAnimation(%s): Loaded successfully", pathname.string8()); + { + LOGMESSAGE("CSkeletonAnimManager::GetAnimation({}): Loaded successfully", + pathname.string8()); + } else LOGERROR("CSkeletonAnimManager::GetAnimation(%s): Failed loading, marked file as bad", pathname.string8()); diff --git a/source/graphics/TerrainTextureManager.cpp b/source/graphics/TerrainTextureManager.cpp index 183a969537..7a59134882 100644 --- a/source/graphics/TerrainTextureManager.cpp +++ b/source/graphics/TerrainTextureManager.cpp @@ -106,7 +106,7 @@ static Status AddTextureDirCallback(const VfsPath& pathname, const uintptr_t cbD AddTextureCallbackData& data = *(AddTextureCallbackData*)cbData; VfsPath path = pathname / L"terrains.xml"; if (!VfsFileExists(path)) - LOGMESSAGE("'%s' does not exist. Using previous properties.", path.string8()); + LOGMESSAGE("'{}' does not exist. Using previous properties.", path.string8()); else data.props = CTerrainProperties::FromXML(data.props, path); diff --git a/source/gui/GUIManager.cpp b/source/gui/GUIManager.cpp index 9dc2614672..f78301559e 100644 --- a/source/gui/GUIManager.cpp +++ b/source/gui/GUIManager.cpp @@ -349,7 +349,8 @@ Status CGUIManager::ReloadChangedFile(const VfsPath& path) for (SGUIPage& p : m_PageStack) if (p.inputs.find(path) != p.inputs.end()) { - LOGMESSAGE("GUI file '%s' changed - reloading page '%s'", path.string8(), utf8_from_wstring(p.m_Name)); + LOGMESSAGE("GUI file '{}' changed - reloading page '{}'", path.string8(), + utf8_from_wstring(p.m_Name)); p.LoadPage(m_ScriptContext); // TODO: this can crash if LoadPage runs an init script which modifies the page stack and breaks our iterators } diff --git a/source/i18n/L10n.cpp b/source/i18n/L10n.cpp index 3371d277de..656b83cc11 100644 --- a/source/i18n/L10n.cpp +++ b/source/i18n/L10n.cpp @@ -535,7 +535,7 @@ Status L10n::ReloadChangedFile(const VfsPath& path) if (path.string().rfind(dictName) == std::string::npos) return INFO::OK; - LOGMESSAGE("Hotloading translations from '%s'", path.string8()); + LOGMESSAGE("Hotloading translations from '{}'", path.string8()); CVFSFile file; if (file.Load(g_VFS, path) != PSRETURN_OK) diff --git a/source/lobby/XmppClient.cpp b/source/lobby/XmppClient.cpp index f40ccda53b..688f50a85a 100644 --- a/source/lobby/XmppClient.cpp +++ b/source/lobby/XmppClient.cpp @@ -993,7 +993,8 @@ bool XmppClient::Impl::handleIq(const gloox::IQ& iq) return true; if (!m_connectionDataJid.empty() && m_connectionDataJid.compare(iq.from().full()) != 0) { - LOGMESSAGE("XmppClient: Received connection data from invalid host: %s", iq.from().username()); + LOGMESSAGE("XmppClient: Received connection data from invalid host: {}", + iq.from().username()); return true; } @@ -1077,7 +1078,8 @@ bool XmppClient::Impl::handleIq(const gloox::IQ& iq) const LobbyAuth* lobbyAuth = iq.findExtension(EXTLOBBYAUTH); if (lobbyAuth) { - LOGMESSAGE("XmppClient: Received lobby auth: %s from %s", lobbyAuth->m_Token, iq.from().username()); + LOGMESSAGE("XmppClient: Received lobby auth: {} from {}", lobbyAuth->m_Token, + iq.from().username()); gloox::IQ response(gloox::IQ::Result, iq.from(), iq.id()); m_client.send(response); @@ -1093,7 +1095,8 @@ bool XmppClient::Impl::handleIq(const gloox::IQ& iq) const ConnectionData* cd = iq.findExtension(EXTCONNECTIONDATA); if (cd) { - LOGMESSAGE("XmppClient: Received request for connection data from %s", iq.from().username()); + LOGMESSAGE("XmppClient: Received request for connection data from {}", + iq.from().username()); if (!g_NetServer) { gloox::IQ response(gloox::IQ::Result, iq.from(), iq.id()); @@ -1161,7 +1164,7 @@ bool XmppClient::Impl::handleIq(const gloox::IQ& iq) else { CreateGUIMessage("system", "error", std::time(nullptr), "text", wstring_from_utf8(g_L10n.Translate("unknown subtype (see logs)"))); - LOGMESSAGE("unknown subtype '%s'", tag_name(iq).c_str()); + LOGMESSAGE("unknown subtype '{}'", tag_name(iq)); } return true; diff --git a/source/main.cpp b/source/main.cpp index 31d668b099..4c2d19a2c1 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -206,7 +206,7 @@ static Input::Reaction MainInputHandler(const SDL_Event& ev) LOGERROR("Failed to install mod %s", dropped_filedir); else { - LOGMESSAGE("Installed mod %s", installer.GetInstalledMods().front()); + LOGMESSAGE("Installed mod {}", installer.GetInstalledMods().front()); Script::Interface modInterface("Engine", "Mod", g_ScriptContext); g_Mods.UpdateAvailableMods(modInterface); RestartEngine(); diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index 3261563a04..edacf719ab 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -301,7 +301,7 @@ bool CNetClient::TryToConnectWithSTUN(std::string serverAddressOrHostname, std:: port = enetClient->address.port; } - LOGMESSAGE("NetClient: connecting to server at %s:%i", m_ServerAddressOrHostname, m_ServerPort); + LOGMESSAGE("NetClient: connecting to server at {}:{}", m_ServerAddressOrHostname, m_ServerPort); if (!ip.empty()) { @@ -674,7 +674,7 @@ void CNetClient::LoadFinished() stream.read((char*)&turn, sizeof(turn)); turn = to_le32(turn); - LOGMESSAGE("Rejoining client deserializing state at turn %u\n", turn); + LOGMESSAGE("Rejoining client deserializing state at turn {}\n", turn); bool ok = m_Game->GetSimulation2()->DeserializeState(stream); ENSURE(ok); @@ -784,7 +784,8 @@ bool CNetClient::OnAuthenticate(CNetClient* client, CFsmEvent* eve CAuthenticateResultMessage* message = static_cast(event->GetParamRef()); - LOGMESSAGE("Net: Authentication result: host=%u, %s", message->m_HostID, utf8_from_wstring(message->m_Message)); + LOGMESSAGE("Net: Authentication result: host={}, {}", message->m_HostID, + utf8_from_wstring(message->m_Message)); client->m_HostID = message->m_HostID; client->m_Rejoin = message->m_Code == ARC_OK_REJOINING; diff --git a/source/network/NetClientSession.cpp b/source/network/NetClientSession.cpp index a5af893e29..6475cb5626 100644 --- a/source/network/NetClientSession.cpp +++ b/source/network/NetClientSession.cpp @@ -120,7 +120,7 @@ void CNetClientSession::Poll() // Report the server address immediately. char hostname[256] = "(error)"; enet_address_get_host_ip(&event.peer->address, hostname, ARRAY_SIZE(hostname)); - LOGMESSAGE("Net client: Connected to %s:%u", hostname, (unsigned int)event.peer->address.port); + LOGMESSAGE("Net client: Connected to {}:{}", hostname, event.peer->address.port); m_Connected = true; m_WasConnected = true; @@ -177,7 +177,8 @@ void CNetClientSession::ProcessPolledMessages() CNetMessage* msg = CNetMessageFactory::CreateMessage(event.packet->data, event.packet->dataLength, m_Client.GetScriptInterface()); if (msg) { - LOGMESSAGE("Net client: Received message %s of size %lu from server", msg->ToString().c_str(), (unsigned long)msg->GetSerializedLength()); + LOGMESSAGE("Net client: Received message {} of size {} from server", + msg->ToString(), msg->GetSerializedLength()); m_Client.HandleMessage(msg); } diff --git a/source/network/NetHost.cpp b/source/network/NetHost.cpp index e8267b75c8..6669717f4c 100644 --- a/source/network/NetHost.cpp +++ b/source/network/NetHost.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -33,7 +33,8 @@ bool CNetHost::SendMessage(const CNetMessage* message, ENetPeer* peer, const cha if (!packet) return false; - LOGMESSAGE("Net: Sending message %s of size %lu to %s", message->ToString().c_str(), (unsigned long)packet->dataLength, peerName); + LOGMESSAGE("Net: Sending message {} of size {} to {}", message->ToString(), packet->dataLength, + peerName); // Let ENet send the message to peer if (enet_peer_send(peer, DEFAULT_CHANNEL, packet) < 0) diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index be3a23b250..b90acbdd0b 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -217,14 +217,14 @@ void CNetServerWorker::SetupUPnP(const std::uint16_t port) // Cached root descriptor URL. const std::string rootDescURL{g_ConfigDB.Get("network.upnprootdescurl", std::string{})}; if (!rootDescURL.empty()) - LOGMESSAGE("Net server: attempting to use cached root descriptor URL: %s", rootDescURL.c_str()); + LOGMESSAGE("Net server: attempting to use cached root descriptor URL: {}", rootDescURL); int ret = 0; // Try a cached URL first if (!rootDescURL.empty() && UPNP_GetIGDFromUrl(rootDescURL.c_str(), &urls, &data, internalIPAddress, sizeof(internalIPAddress)) && strlen(data.first.controlurl) != 0) { - LOGMESSAGE("Net server: using cached IGD = %s", urls.controlURL); + LOGMESSAGE("Net server: using cached IGD = {}", urls.controlURL); ret = 1; } // No cached URL, or it did not respond. Try discovering the UPnP IGD for 2 seconds. @@ -254,24 +254,27 @@ void CNetServerWorker::SetupUPnP(const std::uint16_t port) LOGMESSAGE("Net server: No IGD found"); break; case 1: - LOGMESSAGE("Net server: found valid IGD = %s", urls.controlURL); + LOGMESSAGE("Net server: found valid IGD = {}", urls.controlURL); break; #if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 18 case 2: - LOGMESSAGE("Net server: found IGD with reserved IP = %s, will try to continue anyway", urls.controlURL); + LOGMESSAGE("Net server: found IGD with reserved IP = {}, will try to continue anyway", + urls.controlURL); break; case 3: #else case 2: #endif - LOGMESSAGE("Net server: found a valid, not connected IGD = %s, will try to continue anyway", urls.controlURL); + LOGMESSAGE("Net server: found a valid, not connected IGD = {}, will try to continue anyway", + urls.controlURL); break; #if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 18 case 4: #else case 3: #endif - LOGMESSAGE("Net server: found a UPnP device unrecognized as IGD = %s, will try to continue anyway", urls.controlURL); + LOGMESSAGE("Net server: found a UPnP device unrecognized as IGD = {}, will try to continue " + "anyway", urls.controlURL); break; default: debug_warn(L"Unrecognized return value from UPNP_GetValidIGD"); @@ -281,19 +284,20 @@ void CNetServerWorker::SetupUPnP(const std::uint16_t port) ret = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); if (ret != UPNPCOMMAND_SUCCESS) { - LOGMESSAGE("Net server: GetExternalIPAddress failed with code %d (%s)", ret, strupnperror(ret)); + LOGMESSAGE("Net server: GetExternalIPAddress failed with code {} ({})", ret, + strupnperror(ret)); freeUPnP(); return; } - LOGMESSAGE("Net server: ExternalIPAddress = %s", externalIPAddress); + LOGMESSAGE("Net server: ExternalIPAddress = {}", externalIPAddress); // Try to setup port forwarding. ret = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, psPort, psPort, internalIPAddress, description, protocall, 0, leaseDuration); if (ret != UPNPCOMMAND_SUCCESS) { - LOGMESSAGE("Net server: AddPortMapping(%s, %s, %s) failed with code %d (%s)", - psPort, psPort, internalIPAddress, ret, strupnperror(ret)); + LOGMESSAGE("Net server: AddPortMapping({}, {}, {}) failed with code {} ({})", + psPort, psPort, internalIPAddress, ret, strupnperror(ret)); freeUPnP(); return; } @@ -310,18 +314,19 @@ void CNetServerWorker::SetupUPnP(const std::uint16_t port) if (ret != UPNPCOMMAND_SUCCESS) { - LOGMESSAGE("Net server: GetSpecificPortMappingEntry() failed with code %d (%s)", ret, strupnperror(ret)); + LOGMESSAGE("Net server: GetSpecificPortMappingEntry() failed with code {} ({})", ret, + strupnperror(ret)); freeUPnP(); return; } - LOGMESSAGE("Net server: External %s:%s %s is redirected to internal %s:%s (duration=%s)", - externalIPAddress, psPort, protocall, intClient, intPort, duration); + LOGMESSAGE("Net server: External {}:{} {} is redirected to internal {}:{} (duration={})", + externalIPAddress, psPort, protocall, intClient, intPort, duration); // Cache root descriptor URL to try to avoid discovery next time. g_ConfigDB.SetValueString(CFG_USER, "network.upnprootdescurl", urls.rootdescURL); g_ConfigDB.WriteValueToFile(CFG_USER, "network.upnprootdescurl", urls.rootdescURL); - LOGMESSAGE("Net server: cached UPnP root descriptor URL as %s", urls.rootdescURL); + LOGMESSAGE("Net server: cached UPnP root descriptor URL as {}", urls.rootdescURL); freeUPnP(); } @@ -473,7 +478,8 @@ bool CNetServerWorker::RunStep() // Report the client address char hostname[256] = "(error)"; enet_address_get_host_ip(&event.peer->address, hostname, ARRAY_SIZE(hostname)); - LOGMESSAGE("Net server: Received connection from %s:%u", hostname, (unsigned int)event.peer->address.port); + LOGMESSAGE("Net server: Received connection from {}:{}", hostname, + event.peer->address.port); // Set up a session object for this peer @@ -497,7 +503,7 @@ bool CNetServerWorker::RunStep() CNetServerSession* session = static_cast(event.peer->data); if (session) { - LOGMESSAGE("Net server: Disconnected %s", DebugName(session).c_str()); + LOGMESSAGE("Net server: Disconnected {}", DebugName(session)); // Remove the session first, so we won't send player-update messages to it // when updating the FSM @@ -528,7 +534,8 @@ bool CNetServerWorker::RunStep() CNetMessage* msg = CNetMessageFactory::CreateMessage(event.packet->data, event.packet->dataLength, GetScriptInterface()); if (msg) { - LOGMESSAGE("Net server: Received message %s of size %lu from %s", msg->ToString().c_str(), (unsigned long)msg->GetSerializedLength(), DebugName(session).c_str()); + LOGMESSAGE("Net server: Received message {} of size {} from {}", + msg->ToString(), msg->GetSerializedLength(), DebugName(session)); HandleMessageReceive(msg, session); @@ -892,7 +899,7 @@ void CNetServerWorker::SetTurnLength(std::uint32_t msecs) void CNetServerWorker::ProcessLobbyAuth(const CStr& name, const CStr& token) { - LOGMESSAGE("Net Server: Received lobby auth message from %s with %s", name, token); + LOGMESSAGE("Net Server: Received lobby auth message from {} with {}", name, token); // Find the user with that guid const auto it = std::find_if(m_Sessions.begin(), m_Sessions.end(), [&](const auto& session) { return session->GetGUID() == token; }); @@ -1087,7 +1094,8 @@ bool CNetServerWorker::OnAuthenticate(CNetServerSession* session, CFsmEventDisconnect(NDR_SERVER_ALREADY_IN_GAME); return true; } @@ -1585,10 +1593,8 @@ void CNetServerWorker::PreStartGame(const CStr& initAttribs) { // We only support clients joining before or after, not during the loading screen. // Therefore we have to disconnect clients who did not complete the authentication yet. - LOGMESSAGE("Dropping client (%s / %s / %d) not in NSS_PREGAME when starting the game", - session->GetUserName().ToUTF8().c_str(), - session->GetGUID().c_str(), - session->GetHostID()); + LOGMESSAGE("Dropping client ({} / {} / {}) not in NSS_PREGAME when starting the game", + session->GetUserName().ToUTF8(), session->GetGUID(), session->GetHostID()); session->Disconnect(NDR_SERVER_LOADING); continue; } diff --git a/source/network/StunClient.cpp b/source/network/StunClient.cpp index 8731599869..9414db5596 100644 --- a/source/network/StunClient.cpp +++ b/source/network/StunClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * Copyright (C) 2013-2016 SuperTuxKart-Team. * This file is part of 0 A.D. * @@ -154,7 +154,7 @@ bool CreateStunRequest(ENetHost& transactionHost) const std::string server_name{g_ConfigDB.Get("lobby.stun.server", std::string{})}; const int port{g_ConfigDB.Get("lobby.stun.port", 0)}; - LOGMESSAGE("StunClient: Using STUN server %s:%d\n", server_name.c_str(), port); + LOGMESSAGE("StunClient: Using STUN server {}:{}\n", server_name, port); ENetAddress addr; addr.port = port; @@ -348,7 +348,7 @@ bool FindPublicIP(ENetHost& transactionHost, CStr& ip, std::uint16_t& port) ip = ipStr; port = m_PublicAddress.port; - LOGMESSAGE("StunClient: external IP address is %s:%i", ip.c_str(), port); + LOGMESSAGE("StunClient: external IP address is {}:{}", ip, port); return true; } diff --git a/source/ps/CLogger.h b/source/ps/CLogger.h index d758989be7..4a73c359e2 100644 --- a/source/ps/CLogger.h +++ b/source/ps/CLogger.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include "lib/code_annotation.h" #include +#include #include #include #include @@ -33,7 +34,8 @@ class CLogger; extern CLogger* g_Logger; -#define LOGMESSAGE(...) g_Logger->WriteMessage(fmt::sprintf(__VA_ARGS__).c_str(), false) +#define LOGMESSAGE(fmtstring, ...) g_Logger->WriteMessage( \ + fmt::format(FMT_STRING(fmtstring), ## __VA_ARGS__).c_str(), false) #define LOGMESSAGERENDER(...) g_Logger->WriteMessage(fmt::sprintf(__VA_ARGS__).c_str(), true) #define LOGWARNING(...) g_Logger->WriteWarning(fmt::sprintf(__VA_ARGS__).c_str()) #define LOGERROR(...) g_Logger->WriteError (fmt::sprintf(__VA_ARGS__).c_str()) diff --git a/source/ps/ConfigDB.cpp b/source/ps/ConfigDB.cpp index e51f51ee0e..879715184f 100644 --- a/source/ps/ConfigDB.cpp +++ b/source/ps/ConfigDB.cpp @@ -317,11 +317,11 @@ bool CConfigDB::Reload(EConfigNamespace ns) // Handle missing files quietly if (g_VFS->GetFileInfo(m_ConfigFile[ns], NULL) < 0) { - LOGMESSAGE("Cannot find config file \"%s\" - ignoring", m_ConfigFile[ns].string8()); + LOGMESSAGE("Cannot find config file \"{}\" - ignoring", m_ConfigFile[ns].string8()); return false; } - LOGMESSAGE("Loading config file \"%s\"", m_ConfigFile[ns].string8()); + LOGMESSAGE("Loading config file \"{}\"", m_ConfigFile[ns].string8()); Status ret = g_VFS->LoadFile(m_ConfigFile[ns], buffer, buflen); if (ret != INFO::OK) { @@ -369,7 +369,7 @@ bool CConfigDB::Reload(EConfigNamespace ns) continue; } - LOGMESSAGE("Found config header '%s'", header.c_str()); + LOGMESSAGE("Found config header '{}'", header); header.push_back('.'); while (++pos < filebufend && *pos != '\n' && *pos != ';') if (*pos != ' ' && *pos != '\r') @@ -445,16 +445,16 @@ bool CConfigDB::Reload(EConfigNamespace ns) CStr key(header + name); newMap[key] = values; if (g_UnloggedEntries.find(key) != g_UnloggedEntries.end()) - LOGMESSAGE("Loaded config string \"%s\"", key); + LOGMESSAGE("Loaded config string \"{}\"", key); else if (values.empty()) - LOGMESSAGE("Loaded config string \"%s\" = (empty)", key); + LOGMESSAGE("Loaded config string \"{}\" = (empty)", key); else { std::string vals; for (size_t i = 0; i + 1 < newMap[key].size(); ++i) vals += "\"" + EscapeString(newMap[key][i]) + "\", "; vals += "\"" + EscapeString(newMap[key][values.size()-1]) + "\""; - LOGMESSAGE("Loaded config string \"%s\" = %s", key, vals); + LOGMESSAGE("Loaded config string \"{}\" = {}", key, vals); } } diff --git a/source/ps/DllLoader.cpp b/source/ps/DllLoader.cpp index e31add123b..7553f5f08f 100644 --- a/source/ps/DllLoader.cpp +++ b/source/ps/DllLoader.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -202,7 +202,7 @@ void DllLoader::LogLoadError(const char* errors) switch (m_LoadErrorLogMethod) { case CLogger::Normal: - LOGMESSAGE("DllLoader: %s", errors); + LOGMESSAGE("DllLoader: {}", errors); break; case CLogger::Warning: LOGWARNING("DllLoader: %s", errors); diff --git a/source/ps/Joystick.cpp b/source/ps/Joystick.cpp index 8757ba9087..dbb8b2b617 100644 --- a/source/ps/Joystick.cpp +++ b/source/ps/Joystick.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -50,7 +50,7 @@ void CJoystick::Initialise() int numJoysticks = SDL_NumJoysticks(); - LOGMESSAGE("Found %d joystick(s)", numJoysticks); + LOGMESSAGE("Found {} joystick(s)", numJoysticks); for (int i = 0; i < numJoysticks; ++i) { @@ -61,7 +61,7 @@ void CJoystick::Initialise() continue; } const char* name = SDL_JoystickName(stick); - LOGMESSAGE("Joystick %d: %s", i, name); + LOGMESSAGE("Joystick {}: {}", i, name); SDL_JoystickClose(stick); } diff --git a/source/ps/VideoMode.cpp b/source/ps/VideoMode.cpp index c04affb0c2..4a6757af7f 100644 --- a/source/ps/VideoMode.cpp +++ b/source/ps/VideoMode.cpp @@ -439,7 +439,7 @@ bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen) return SetVideoMode(w, h, bpp, fullscreen); } else - LOGMESSAGE("Loaded %s.", fullPathToVulkanLibrary.c_str()); + LOGMESSAGE("Loaded {}.", fullPathToVulkanLibrary); } #endif diff --git a/source/renderer/ShadowMap.cpp b/source/renderer/ShadowMap.cpp index e5eb4d61f1..97657a8a45 100644 --- a/source/renderer/ShadowMap.cpp +++ b/source/renderer/ShadowMap.cpp @@ -553,7 +553,7 @@ void ShadowMapInternals::CreateTexture(const uint32_t width, const uint32_t heig #endif ENSURE(formatName); - LOGMESSAGE("Creating shadow texture (size %dx%d) (format = %s)", + LOGMESSAGE("Creating shadow texture (size {}x{}) (format = {})", Width, Height, formatName); if (g_RenderingOptions.GetShadowAlphaFix()) diff --git a/source/renderer/backend/gl/Device.cpp b/source/renderer/backend/gl/Device.cpp index 7472e9473d..8feb808f11 100644 --- a/source/renderer/backend/gl/Device.cpp +++ b/source/renderer/backend/gl/Device.cpp @@ -312,8 +312,8 @@ std::unique_ptr CDevice::Create(SDL_Window* window) device->m_DriverInformation = GetDriverInformationImpl(); device->m_Extensions = GetExtensionsImpl(); - LOGMESSAGE("GL device name: %s", device->m_Name.c_str()); - LOGMESSAGE("GL version: %s", device->m_Version.c_str()); + LOGMESSAGE("GL device name: {}", device->m_Name); + LOGMESSAGE("GL version: {}", device->m_Version); #if CONFIG2_GLES const bool minimumRequiredGLVersionSupported{version >= GLAD_MAKE_VERSION(2, 1)}; diff --git a/source/renderer/backend/gl/ShaderProgram.cpp b/source/renderer/backend/gl/ShaderProgram.cpp index 3f50305e74..3ce0857a69 100644 --- a/source/renderer/backend/gl/ShaderProgram.cpp +++ b/source/renderer/backend/gl/ShaderProgram.cpp @@ -256,7 +256,7 @@ bool CompileGLSL(GLuint shader, const VfsPath& file, const CStr& code) glGetShaderInfoLog(shader, length, nullptr, infolog.get()); if (ok) - LOGMESSAGE("Info when compiling shader '%s':\n%s", file.string8(), infolog.get()); + LOGMESSAGE("Info when compiling shader '{}':\n{}", file.string8(), infolog.get()); else LOGERROR("Failed to compile shader '%s':\n%s", file.string8(), infolog.get()); } @@ -396,7 +396,7 @@ bool CShaderProgram::Link(const VfsPath& path) glGetProgramInfoLog(m_Program, length, NULL, infolog); if (ok) - LOGMESSAGE("Info when linking program '%s':\n%s", path.string8(), infolog); + LOGMESSAGE("Info when linking program '{}':\n{}", path.string8(), infolog); else LOGERROR("Failed to link program '%s':\n%s", path.string8(), infolog); diff --git a/source/renderer/backend/vulkan/Device.cpp b/source/renderer/backend/vulkan/Device.cpp index 26046908ea..3375377b7a 100644 --- a/source/renderer/backend/vulkan/Device.cpp +++ b/source/renderer/backend/vulkan/Device.cpp @@ -104,7 +104,7 @@ std::vector GetAvailableValidationLayers() for (const VkLayerProperties& layer : availableLayers) { - LOGMESSAGE("Vulkan validation layer: '%s' (%s) v%u.%u.%u.%u", + LOGMESSAGE("Vulkan validation layer: '{}' ({}) v{}.{}.{}.{}", layer.layerName, layer.description, VK_API_VERSION_VARIANT(layer.specVersion), VK_API_VERSION_MAJOR(layer.specVersion), @@ -139,7 +139,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback( void* /*userData*/) { if ((messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) || (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)) - LOGMESSAGE("Vulkan: %s", callbackData->pMessage); + LOGMESSAGE("Vulkan: {}", callbackData->pMessage); else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { struct HideRule @@ -171,7 +171,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback( if (it == std::end(hideRules)) LOGWARNING("Vulkan: %s", callbackData->pMessage); else if (!it->skip) - LOGMESSAGE("Vulkan: %s", callbackData->pMessage); + LOGMESSAGE("Vulkan: {}", callbackData->pMessage); } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) LOGERROR("Vulkan: %s", callbackData->pMessage); @@ -347,21 +347,21 @@ std::unique_ptr CDevice::Create(SDL_Window* window) GetAvailablePhysicalDevices(device->m_Instance, device->m_Surface, requiredDeviceExtensions); for (const SAvailablePhysicalDevice& device : availablePhyscialDevices) { - LOGMESSAGE("Vulkan available device: '%s' Type: %u Supported: %c", + LOGMESSAGE("Vulkan available device: '{}' Type: {} Supported: {}", device.properties.deviceName, static_cast(device.properties.deviceType), IsPhysicalDeviceUnsupported(device) ? 'N' : 'Y'); - LOGMESSAGE(" ID: %u VendorID: %u API Version: %u Driver Version: %u", + LOGMESSAGE(" ID: {} VendorID: {} API Version: {} Driver Version: {}", device.properties.deviceID, device.properties.vendorID, device.properties.apiVersion, device.properties.driverVersion); - LOGMESSAGE(" hasRequiredExtensions: %c hasOutputToSurfaceSupport: %c", + LOGMESSAGE(" hasRequiredExtensions: {} hasOutputToSurfaceSupport: {}", device.hasRequiredExtensions ? 'Y' : 'N', device.hasOutputToSurfaceSupport ? 'Y' : 'N'); - LOGMESSAGE(" graphicsQueueFamilyIndex: %u presentQueueFamilyIndex: %u families: %zu", + LOGMESSAGE(" graphicsQueueFamilyIndex: {} presentQueueFamilyIndex: {} families: {}", device.graphicsQueueFamilyIndex, device.presentQueueFamilyIndex, device.queueFamilies.size()); - LOGMESSAGE(" maxBoundDescriptorSets: %u", device.properties.limits.maxBoundDescriptorSets); + LOGMESSAGE(" maxBoundDescriptorSets: {}", device.properties.limits.maxBoundDescriptorSets); for (const VkSurfaceFormatKHR& surfaceFormat : device.surfaceFormats) { - LOGMESSAGE(" Surface format: %u colorSpace: %u Supported: %c", + LOGMESSAGE(" Surface format: {} colorSpace: {} Supported: {}", static_cast(surfaceFormat.format), static_cast(surfaceFormat.colorSpace), IsSurfaceFormatSupported(surfaceFormat) ? 'Y' : 'N'); @@ -369,14 +369,14 @@ std::unique_ptr CDevice::Create(SDL_Window* window) for (uint32_t memoryTypeIndex = 0; memoryTypeIndex < device.memoryProperties.memoryTypeCount; ++memoryTypeIndex) { const VkMemoryType& type = device.memoryProperties.memoryTypes[memoryTypeIndex]; - LOGMESSAGE(" Memory Type Index: %u Flags: %u Heap Index: %u", - memoryTypeIndex, static_cast(type.propertyFlags), type.heapIndex); + LOGMESSAGE(" Memory Type Index: {} Flags: {} Heap Index: {}", + memoryTypeIndex, type.propertyFlags, type.heapIndex); } for (uint32_t memoryHeapIndex = 0; memoryHeapIndex < device.memoryProperties.memoryHeapCount; ++memoryHeapIndex) { const VkMemoryHeap& heap = device.memoryProperties.memoryHeaps[memoryHeapIndex]; - LOGMESSAGE(" Memory Heap Index: %u Size: %zu Flags: %u", - memoryHeapIndex, static_cast(heap.size / 1024), static_cast(heap.flags)); + LOGMESSAGE(" Memory Heap Index: {} Size: {} Flags: {}", + memoryHeapIndex, heap.size / 1024, heap.flags); } } device->m_AvailablePhysicalDevices = availablePhyscialDevices; diff --git a/source/renderer/backend/vulkan/SwapChain.cpp b/source/renderer/backend/vulkan/SwapChain.cpp index 3ee1cba88b..e2f1cae778 100644 --- a/source/renderer/backend/vulkan/SwapChain.cpp +++ b/source/renderer/backend/vulkan/SwapChain.cpp @@ -231,7 +231,7 @@ std::unique_ptr CSwapChain::Create( device->GetVkDevice(), swapChain->m_SwapChain, &imageCount, swapChain->m_Images.data()); } } while (getSwapchainImagesResult == VK_INCOMPLETE); - LOGMESSAGE("SwapChain image count: %u (min: %u)", imageCount, swapChainCreateInfo.minImageCount); + LOGMESSAGE("SwapChain image count: {} (min: {})", imageCount, swapChainCreateInfo.minImageCount); ENSURE_VK_SUCCESS(getSwapchainImagesResult); ENSURE(imageCount > 0); diff --git a/source/scriptinterface/Interface.cpp b/source/scriptinterface/Interface.cpp index 4395f6ea4d..168764c535 100644 --- a/source/scriptinterface/Interface.cpp +++ b/source/scriptinterface/Interface.cpp @@ -178,7 +178,7 @@ bool logmsg(JSContext* cx, unsigned int argc, JS::Value* vp) std::wstring str; if (!Script::FromJSVal(rq, args[0], str)) return false; - LOGMESSAGE("%s", utf8_from_wstring(str)); + LOGMESSAGE("{}", utf8_from_wstring(str)); args.rval().setUndefined(); return true; } @@ -602,7 +602,7 @@ bool Interface::SetGlobal_(const char* name, JS::HandleValue value, bool replace return false; } - LOGMESSAGE("Hotloading new value for global \"%s\".", name); + LOGMESSAGE("Hotloading new value for global \"{}\".", name); ENSURE(JS_DeleteProperty(rq.cx, global, name)); } } diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index 92fce73ce5..1634d7b8bf 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -225,7 +225,7 @@ void CSimulation2Impl::LoadScripts(CComponentManager& componentManager, std::set { if (loadedScripts) loadedScripts->insert(scriptPath); - LOGMESSAGE("Loading simulation script '%s'", scriptPath.string8()); + LOGMESSAGE("Loading simulation script '{}'", scriptPath.string8()); if (!componentManager.LoadScript(scriptPath)) throw CSimulation2::LoadScriptError{"Error loading " + scriptPath.string8()}; } @@ -248,7 +248,7 @@ bool CSimulation2Impl::LoadTriggerScripts(CComponentManager& componentManager, J continue; loadedScripts->insert(scriptName); } - LOGMESSAGE("Loading trigger script '%s'", scriptName.c_str()); + LOGMESSAGE("Loading trigger script '{}'", scriptName); if (!componentManager.LoadScript(scriptName.data())) ok = false; } @@ -268,7 +268,7 @@ Status CSimulation2Impl::ReloadChangedFile(const VfsPath& path) if (!VfsFileExists(path)) return INFO::OK; - LOGMESSAGE("Reloading simulation script '%s'", path.string8()); + LOGMESSAGE("Reloading simulation script '{}'", path.string8()); if (!m_ComponentManager.LoadScript(path, true)) return ERR::FAIL;