Skip to content

Commit

Permalink
Fix LOG format string
Browse files Browse the repository at this point in the history
  • Loading branch information
iThorgrim committed Jan 30, 2025
1 parent 1c61304 commit b4109fa
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/LuaEngine/ElunaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
4 changes: 2 additions & 2 deletions src/LuaEngine/ElunaInstanceAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 11 additions & 11 deletions src/LuaEngine/ElunaLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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('.');
Expand Down Expand Up @@ -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());
}


Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/LuaEngine/ElunaTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class ElunaTemplate
ElunaObjectType* elunaObject = static_cast<ElunaObjectType*>(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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -343,7 +343,7 @@ class ElunaTemplate
}
else
{
ELUNA_LOG_ERROR("%s", buff);
ELUNA_LOG_ERROR("{}", buff);
}
return NULL;
}
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions src/LuaEngine/LuaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -270,15 +270,15 @@ 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;
}
}

// 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;
Expand All @@ -291,15 +291,15 @@ 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;
}
// Stack: require
}
// 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();
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit b4109fa

Please sign in to comment.