From b4109fac7e6ec48c416b5bbcfa9943e5c5405f60 Mon Sep 17 00:00:00 2001 From: iThorgrim Date: Thu, 30 Jan 2025 18:51:04 +0100 Subject: [PATCH] Fix LOG format string --- src/LuaEngine/ElunaConfig.cpp | 2 +- src/LuaEngine/ElunaInstanceAI.cpp | 4 ++-- src/LuaEngine/ElunaLoader.cpp | 22 +++++++++++----------- src/LuaEngine/ElunaTemplate.h | 8 ++++---- src/LuaEngine/LuaEngine.cpp | 14 +++++++------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/LuaEngine/ElunaConfig.cpp b/src/LuaEngine/ElunaConfig.cpp index ec8524ea6c..f7c6029315 100644 --- a/src/LuaEngine/ElunaConfig.cpp +++ b/src/LuaEngine/ElunaConfig.cpp @@ -91,7 +91,7 @@ void ElunaConfig::TokenizeAllowedMaps() m_allowedMaps.emplace(mapId); } catch (std::exception&) { - ELUNA_LOG_ERROR("[Eluna]: Error tokenizing Eluna.OnlyOnMaps, invalid config value '%s'", mapIdStr.c_str()); + ELUNA_LOG_ERROR("[Eluna]: Error tokenizing Eluna.OnlyOnMaps, invalid config value '{}'", mapIdStr.c_str()); } } } diff --git a/src/LuaEngine/ElunaInstanceAI.cpp b/src/LuaEngine/ElunaInstanceAI.cpp index 3e4b5a332d..8fa4a41517 100644 --- a/src/LuaEngine/ElunaInstanceAI.cpp +++ b/src/LuaEngine/ElunaInstanceAI.cpp @@ -83,7 +83,7 @@ void ElunaInstanceAI::Load(const char* data) else { // Stack: error_message - ELUNA_LOG_ERROR("Error while parsing instance data with lua-marshal: %s", lua_tostring(L, -1)); + ELUNA_LOG_ERROR("Error while parsing instance data with lua-marshal: {}", lua_tostring(L, -1)); lua_pop(L, 1); // Stack: (empty) @@ -121,7 +121,7 @@ const char* ElunaInstanceAI::Save() const if (lua_pcall(L, 1, 1, 0) != 0) { // Stack: error_message - ELUNA_LOG_ERROR("Error while saving: %s", lua_tostring(L, -1)); + ELUNA_LOG_ERROR("Error while saving: {}", lua_tostring(L, -1)); lua_pop(L, 1); return NULL; } diff --git a/src/LuaEngine/ElunaLoader.cpp b/src/LuaEngine/ElunaLoader.cpp index 330bc45e31..3cb1e729c1 100644 --- a/src/LuaEngine/ElunaLoader.cpp +++ b/src/LuaEngine/ElunaLoader.cpp @@ -120,7 +120,7 @@ void ElunaLoader::LoadScripts() lua_folderpath.replace(0, 1, home); #endif - ELUNA_LOG_INFO("[Eluna]: Searching for scripts in `%s`", lua_folderpath.c_str()); + ELUNA_LOG_INFO("[Eluna]: Searching for scripts in `{}`", lua_folderpath.c_str()); // open a new temporary Lua state to compile bytecode in lua_State* L = luaL_newstate(); @@ -153,7 +153,7 @@ void ElunaLoader::LoadScripts() if (!m_requirecPath.empty()) m_requirecPath.erase(m_requirecPath.end() - 1); - ELUNA_LOG_INFO("[Eluna]: Loaded and precompiled %u scripts in %u ms", uint32(m_scriptCache.size()), ElunaUtil::GetTimeDiff(oldMSTime)); + ELUNA_LOG_INFO("[Eluna]: Loaded and precompiled {} scripts in {} ms", uint32(m_scriptCache.size()), ElunaUtil::GetTimeDiff(oldMSTime)); // set the cache state to ready m_cacheState = SCRIPT_CACHE_READY; @@ -172,7 +172,7 @@ void ElunaLoader::ReadFiles(lua_State* L, std::string path) { std::string lua_folderpath = sElunaConfig->GetConfig(CONFIG_ELUNA_SCRIPT_PATH); - ELUNA_LOG_DEBUG("[Eluna]: ReadFiles from path `%s`", path.c_str()); + ELUNA_LOG_DEBUG("[Eluna]: ReadFiles from path `{}`", path.c_str()); fs::path someDir(path); fs::directory_iterator end_iter; @@ -247,21 +247,21 @@ bool ElunaLoader::CompileScript(lua_State* L, LuaScript& script) // If something bad happened, try to find an error. if (err != 0) { - ELUNA_LOG_ERROR("[Eluna]: CompileScript failed to load the Lua script `%s`.", script.filename.c_str()); + ELUNA_LOG_ERROR("[Eluna]: CompileScript failed to load the Lua script `{}`.", script.filename.c_str()); Eluna::Report(L); return false; } - ELUNA_LOG_DEBUG("[Eluna]: CompileScript loaded Lua script `%s`", script.filename.c_str()); + ELUNA_LOG_DEBUG("[Eluna]: CompileScript loaded Lua script `{}`", script.filename.c_str()); // Everything's OK so far, the script has been loaded, now we need to start dumping it to bytecode. err = lua_dump(L, (lua_Writer)LoadBytecodeChunk, &script.bytecode); if (err || script.bytecode.empty()) { - ELUNA_LOG_ERROR("[Eluna]: CompileScript failed to dump the Lua script `%s` to bytecode.", script.filename.c_str()); + ELUNA_LOG_ERROR("[Eluna]: CompileScript failed to dump the Lua script `{}` to bytecode.", script.filename.c_str()); Eluna::Report(L); return false; } - ELUNA_LOG_DEBUG("[Eluna]: CompileScript dumped Lua script `%s` to bytecode.", script.filename.c_str()); + ELUNA_LOG_DEBUG("[Eluna]: CompileScript dumped Lua script `{}` to bytecode.", script.filename.c_str()); // pop the loaded function from the stack lua_pop(L, 1); @@ -270,7 +270,7 @@ bool ElunaLoader::CompileScript(lua_State* L, LuaScript& script) void ElunaLoader::ProcessScript(lua_State* L, std::string filename, const std::string& fullpath, int32 mapId) { - ELUNA_LOG_DEBUG("[Eluna]: ProcessScript checking file `%s`", fullpath.c_str()); + ELUNA_LOG_DEBUG("[Eluna]: ProcessScript checking file `{}`", fullpath.c_str()); // split file name std::size_t extDot = filename.find_last_of('.'); @@ -300,7 +300,7 @@ void ElunaLoader::ProcessScript(lua_State* L, std::string filename, const std::s else m_scripts.push_back(script); - ELUNA_LOG_DEBUG("[Eluna]: ProcessScript processed `%s` successfully", fullpath.c_str()); + ELUNA_LOG_DEBUG("[Eluna]: ProcessScript processed `{}` successfully", fullpath.c_str()); } @@ -312,11 +312,11 @@ void ElunaLoader::InitializeFileWatcher() lua_scriptWatcher = lua_fileWatcher.addWatch(lua_folderpath, &elunaUpdateListener, true); if (lua_scriptWatcher >= 0) { - ELUNA_LOG_INFO("[Eluna]: Script reloader is listening on `%s`.", lua_folderpath.c_str()); + ELUNA_LOG_INFO("[Eluna]: Script reloader is listening on `{}`.", lua_folderpath.c_str()); } else { - ELUNA_LOG_INFO("[Eluna]: Failed to initialize the script reloader on `%s`.", lua_folderpath.c_str()); + ELUNA_LOG_INFO("[Eluna]: Failed to initialize the script reloader on `{}`.", lua_folderpath.c_str()); } lua_fileWatcher.watch(); diff --git a/src/LuaEngine/ElunaTemplate.h b/src/LuaEngine/ElunaTemplate.h index 7545c80464..6bcb69e0a0 100644 --- a/src/LuaEngine/ElunaTemplate.h +++ b/src/LuaEngine/ElunaTemplate.h @@ -304,7 +304,7 @@ class ElunaTemplate ElunaObjectType* elunaObject = static_cast(lua_newuserdata(L, sizeof(ElunaObjectType))); if (!elunaObject) { - ELUNA_LOG_ERROR("%s could not create new userdata", tname); + ELUNA_LOG_ERROR("{} could not create new userdata", tname); lua_pushnil(L); return 1; } @@ -315,7 +315,7 @@ class ElunaTemplate lua_rawget(L, LUA_REGISTRYINDEX); if (!lua_istable(L, -1)) { - ELUNA_LOG_ERROR("%s missing metatable", tname); + ELUNA_LOG_ERROR("{} missing metatable", tname); lua_pop(L, 2); lua_pushnil(L); return 1; @@ -343,7 +343,7 @@ class ElunaTemplate } else { - ELUNA_LOG_ERROR("%s", buff); + ELUNA_LOG_ERROR("{}", buff); } return NULL; } @@ -384,7 +384,7 @@ class ElunaTemplate int args = lua_gettop(L) - top; if (args < 0 || args > expected) { - ELUNA_LOG_ERROR("[Eluna]: %s returned unexpected amount of arguments %i out of %i. Report to devs", l->name, args, expected); + ELUNA_LOG_ERROR("[Eluna]: {} returned unexpected amount of arguments {} out of {}. Report to devs", l->name, args, expected); ASSERT(false); } lua_settop(L, top + expected); diff --git a/src/LuaEngine/LuaEngine.cpp b/src/LuaEngine/LuaEngine.cpp index fd93746950..e6956ac175 100644 --- a/src/LuaEngine/LuaEngine.cpp +++ b/src/LuaEngine/LuaEngine.cpp @@ -250,7 +250,7 @@ void Eluna::RunScripts() { int32 const boundMapId = GetBoundMapId(); uint32 const boundInstanceId = GetBoundInstanceId(); - ELUNA_LOG_DEBUG("[Eluna]: Running scripts for state: %i, instance: %u", boundMapId, boundInstanceId); + ELUNA_LOG_DEBUG("[Eluna]: Running scripts for state: {}, instance: {}", boundMapId, boundInstanceId); uint32 oldMSTime = ElunaUtil::GetCurrTime(); uint32 count = 0; @@ -270,7 +270,7 @@ void Eluna::RunScripts() // check that the script file is either global or meant to be loaded for this map if (it->mapId != -1 && it->mapId != boundMapId) { - ELUNA_LOG_DEBUG("[Eluna]: `%s` is tagged %i and will not load for map: %i", it->filename.c_str(), it->mapId, boundMapId); + ELUNA_LOG_DEBUG("[Eluna]: `{}` is tagged {} and will not load for map: {}", it->filename.c_str(), it->mapId, boundMapId); continue; } } @@ -278,7 +278,7 @@ void Eluna::RunScripts() // Check that no duplicate names exist if (loaded.find(it->filename) != loaded.end()) { - ELUNA_LOG_ERROR("[Eluna]: Error loading `%s`. File with same name already loaded from `%s`, rename either file", it->filepath.c_str(), loaded[it->filename].c_str()); + ELUNA_LOG_ERROR("[Eluna]: Error loading `{}`. File with same name already loaded from `{}`, rename either file", it->filepath.c_str(), loaded[it->filename].c_str()); continue; } loaded[it->filename] = it->filepath; @@ -291,7 +291,7 @@ void Eluna::RunScripts() if (ExecuteCall(1, 0)) { // Successfully called require on the script - ELUNA_LOG_DEBUG("[Eluna]: Successfully loaded `%s`", it->filepath.c_str()); + ELUNA_LOG_DEBUG("[Eluna]: Successfully loaded `{}`", it->filepath.c_str()); ++count; continue; } @@ -299,7 +299,7 @@ void Eluna::RunScripts() } // Stack: require lua_pop(L, 1); - ELUNA_LOG_INFO("[Eluna]: Executed %u Lua scripts in %u ms for map: %i, instance: %u", count, ElunaUtil::GetTimeDiff(oldMSTime), boundMapId, boundInstanceId); + ELUNA_LOG_INFO("[Eluna]: Executed {} Lua scripts in {} ms for map: {}, instance: {}", count, ElunaUtil::GetTimeDiff(oldMSTime), boundMapId, boundInstanceId); OnLuaStateOpen(); } @@ -313,7 +313,7 @@ void Eluna::InvalidateObjects() void Eluna::Report(lua_State* _L) { const char* msg = lua_tostring(_L, -1); - ELUNA_LOG_ERROR("%s", msg); + ELUNA_LOG_ERROR("{}", msg); lua_pop(_L, 1); } @@ -358,7 +358,7 @@ bool Eluna::ExecuteCall(int params, int res) // Check function type if (!lua_isfunction(L, base)) { - ELUNA_LOG_ERROR("[Eluna]: Cannot execute call: registered value is %s, not a function.", luaL_tolstring(L, base, NULL)); + ELUNA_LOG_ERROR("[Eluna]: Cannot execute call: registered value is {}, not a function.", luaL_tolstring(L, base, NULL)); ASSERT(false); // stack probably corrupt }