mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
feat(Logging): add support new logging (#17)
This commit is contained in:
@@ -80,7 +80,7 @@ void ElunaInstanceAI::Load(const char* data)
|
||||
}
|
||||
else
|
||||
{
|
||||
ELUNA_LOG_ERROR("Error while loading instance data: Expected data to be a table (type 5), got type %d instead", lua_type(L, -1));
|
||||
ELUNA_LOG_ERROR("Error while loading instance data: Expected data to be a table (type 5), got type {} instead", lua_type(L, -1));
|
||||
lua_pop(L, 1);
|
||||
// Stack: (empty)
|
||||
|
||||
@@ -92,7 +92,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)
|
||||
|
||||
@@ -135,7 +135,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;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
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);
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
ElunaObject** ptrHold = static_cast<ElunaObject**>(lua_newuserdata(L, sizeof(ElunaObject*)));
|
||||
if (!ptrHold)
|
||||
{
|
||||
ELUNA_LOG_ERROR("%s could not create new userdata", tname);
|
||||
ELUNA_LOG_ERROR("{} could not create new userdata", tname);
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public:
|
||||
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;
|
||||
@@ -299,7 +299,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
ELUNA_LOG_ERROR("%s", buff);
|
||||
ELUNA_LOG_ERROR("{}", buff);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -332,7 +332,7 @@ public:
|
||||
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);
|
||||
|
||||
@@ -2586,7 +2586,7 @@ namespace LuaGlobalFunctions
|
||||
*/
|
||||
int PrintInfo(lua_State* L)
|
||||
{
|
||||
ELUNA_LOG_INFO("%s", GetStackAsString(L).c_str());
|
||||
ELUNA_LOG_INFO("{}", GetStackAsString(L));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2597,7 +2597,7 @@ namespace LuaGlobalFunctions
|
||||
*/
|
||||
int PrintError(lua_State* L)
|
||||
{
|
||||
ELUNA_LOG_ERROR("%s", GetStackAsString(L).c_str());
|
||||
ELUNA_LOG_ERROR("{}", GetStackAsString(L));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2608,7 +2608,7 @@ namespace LuaGlobalFunctions
|
||||
*/
|
||||
int PrintDebug(lua_State* L)
|
||||
{
|
||||
ELUNA_LOG_DEBUG("%s", GetStackAsString(L).c_str());
|
||||
ELUNA_LOG_DEBUG("{}", GetStackAsString(L));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ void HttpManager::HttpWorkerThread()
|
||||
std::string path;
|
||||
|
||||
if (!ParseUrl(req->url, host, path)) {
|
||||
ELUNA_LOG_ERROR("[Eluna]: Could not parse URL %s", req->url.c_str());
|
||||
ELUNA_LOG_ERROR("[Eluna]: Could not parse URL {}", req->url);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ void HttpManager::HttpWorkerThread()
|
||||
httplib::Error err = res.error();
|
||||
if (err != httplib::Error::Success)
|
||||
{
|
||||
ELUNA_LOG_ERROR("[Eluna]: HTTP request error: %s", httplib::to_string(err).c_str());
|
||||
ELUNA_LOG_ERROR("[Eluna]: HTTP request error: {}", httplib::to_string(err));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ void HttpManager::HttpWorkerThread()
|
||||
|
||||
if (!ParseUrl(location, host, path))
|
||||
{
|
||||
ELUNA_LOG_ERROR("[Eluna]: Could not parse URL after redirect: %s", location.c_str());
|
||||
ELUNA_LOG_ERROR("[Eluna]: Could not parse URL after redirect: {}", location);
|
||||
continue;
|
||||
}
|
||||
httplib::Client cli2(host);
|
||||
@@ -171,7 +171,7 @@ void HttpManager::HttpWorkerThread()
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
ELUNA_LOG_ERROR("[Eluna]: HTTP request error: %s", ex.what());
|
||||
ELUNA_LOG_ERROR("[Eluna]: HTTP request error: {}", ex.what());
|
||||
}
|
||||
|
||||
delete req;
|
||||
@@ -210,7 +210,7 @@ httplib::Result HttpManager::DoRequest(httplib::Client& client, HttpWorkItem* re
|
||||
return client.Options(path, req->headers);
|
||||
}
|
||||
|
||||
ELUNA_LOG_ERROR("[Eluna]: HTTP request error: invalid HTTP verb %s", req->httpVerb.c_str());
|
||||
ELUNA_LOG_ERROR("[Eluna]: HTTP request error: invalid HTTP verb {}", req->httpVerb));
|
||||
return client.Get(path, req->headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,14 +118,14 @@ void Eluna::LoadScriptPaths()
|
||||
if (const char* home = getenv("HOME"))
|
||||
lua_folderpath.replace(0, 1, home);
|
||||
#endif
|
||||
ELUNA_LOG_INFO("[Eluna]: Searching scripts from `%s`", lua_folderpath.c_str());
|
||||
ELUNA_LOG_INFO("[Eluna]: Searching scripts from `{}`", lua_folderpath);
|
||||
lua_requirepath.clear();
|
||||
GetScripts(lua_folderpath);
|
||||
// Erase last ;
|
||||
if (!lua_requirepath.empty())
|
||||
lua_requirepath.erase(lua_requirepath.end() - 1);
|
||||
|
||||
ELUNA_LOG_DEBUG("[Eluna]: Loaded %u scripts in %u ms", uint32(lua_scripts.size() + lua_extensions.size()), ElunaUtil::GetTimeDiff(oldMSTime));
|
||||
ELUNA_LOG_DEBUG("[Eluna]: Loaded {} scripts in {} ms", lua_scripts.size() + lua_extensions.size(), ElunaUtil::GetTimeDiff(oldMSTime));
|
||||
}
|
||||
|
||||
void Eluna::_ReloadEluna()
|
||||
@@ -326,7 +326,7 @@ void Eluna::DestroyBindStores()
|
||||
|
||||
void Eluna::AddScriptPath(std::string filename, const std::string& fullpath)
|
||||
{
|
||||
ELUNA_LOG_DEBUG("[Eluna]: AddScriptPath Checking file `%s`", fullpath.c_str());
|
||||
ELUNA_LOG_DEBUG("[Eluna]: AddScriptPath Checking file `{}`", fullpath);
|
||||
|
||||
// split file name
|
||||
std::size_t extDot = filename.find_last_of('.');
|
||||
@@ -349,13 +349,13 @@ void Eluna::AddScriptPath(std::string filename, const std::string& fullpath)
|
||||
lua_extensions.push_back(script);
|
||||
else
|
||||
lua_scripts.push_back(script);
|
||||
ELUNA_LOG_DEBUG("[Eluna]: AddScriptPath add path `%s`", fullpath.c_str());
|
||||
ELUNA_LOG_DEBUG("[Eluna]: AddScriptPath add path `{}`", fullpath);
|
||||
}
|
||||
|
||||
// Finds lua script files from given path (including subdirectories) and pushes them to scripts
|
||||
void Eluna::GetScripts(std::string path)
|
||||
{
|
||||
ELUNA_LOG_DEBUG("[Eluna]: GetScripts from path `%s`", path.c_str());
|
||||
ELUNA_LOG_DEBUG("[Eluna]: GetScripts from path `{}`", path);
|
||||
|
||||
#ifdef USING_BOOST
|
||||
boost::filesystem::path someDir(path);
|
||||
@@ -480,7 +480,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, loaded[it->filename]);
|
||||
continue;
|
||||
}
|
||||
loaded[it->filename] = it->filepath;
|
||||
@@ -490,7 +490,7 @@ void Eluna::RunScripts()
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
ELUNA_LOG_DEBUG("[Eluna]: `%s` was already loaded or required", it->filepath.c_str());
|
||||
ELUNA_LOG_DEBUG("[Eluna]: `{}` was already loaded or required", it->filepath);
|
||||
continue;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
@@ -499,7 +499,7 @@ void Eluna::RunScripts()
|
||||
if (luaL_loadfile(L, it->filepath.c_str()))
|
||||
{
|
||||
// Stack: package, modules, errmsg
|
||||
ELUNA_LOG_ERROR("[Eluna]: Error loading `%s`", it->filepath.c_str());
|
||||
ELUNA_LOG_ERROR("[Eluna]: Error loading `{}`", it->filepath);
|
||||
Report(L);
|
||||
// Stack: package, modules
|
||||
continue;
|
||||
@@ -519,14 +519,14 @@ void Eluna::RunScripts()
|
||||
// Stack: package, modules
|
||||
|
||||
// successfully loaded and ran file
|
||||
ELUNA_LOG_DEBUG("[Eluna]: Successfully loaded `%s`", it->filepath.c_str());
|
||||
ELUNA_LOG_DEBUG("[Eluna]: Successfully loaded `{}`", it->filepath);
|
||||
++count;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Stack: package, modules
|
||||
lua_pop(L, 2);
|
||||
ELUNA_LOG_INFO("[Eluna]: Executed %u Lua scripts in %u ms", count, ElunaUtil::GetTimeDiff(oldMSTime));
|
||||
ELUNA_LOG_INFO("[Eluna]: Executed {} Lua scripts in {} ms", count, ElunaUtil::GetTimeDiff(oldMSTime));
|
||||
|
||||
OnLuaStateOpen();
|
||||
}
|
||||
@@ -544,7 +544,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);
|
||||
}
|
||||
|
||||
@@ -589,7 +589,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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user