mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 19:05:42 +00:00
feat(Core/Logging): rework logging (#4692)
* feat(Core/Logging): rework logging * correct level for sql.sql * del unused config options * Correct build * correct after merge * whitespace 20:29:37 1. 'Player.cpp'. Replace (1) 20:29:37 2. 'ObjectMgr.cpp'. Replace (3) * 1 * correct logging * correct affter merge * 1 * 2 * LOG_LEVEL_WARN * #include "AppenderDB.h" * 3 * 4 * 5 * 1. 'WorldSocket.cpp'. Replace (1) * 6 * 1
This commit is contained in:
@@ -354,7 +354,7 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj)
|
||||
if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
|
||||
{
|
||||
Creature* creature = new Creature;
|
||||
//sLog->outDebug(LOG_FILTER_POOLSYS, "Spawning creature %u", guid);
|
||||
//LOG_DEBUG("pool", "Spawning creature %u", guid);
|
||||
if (!creature->LoadCreatureFromDB(obj->guid, map))
|
||||
{
|
||||
delete creature;
|
||||
@@ -378,7 +378,7 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj)
|
||||
if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
|
||||
{
|
||||
GameObject* pGameobject = sObjectMgr->IsGameObjectStaticTransport(data->id) ? new StaticTransport() : new GameObject();
|
||||
//sLog->outDebug(LOG_FILTER_POOLSYS, "Spawning gameobject %u", guid);
|
||||
//LOG_DEBUG("pool", "Spawning gameobject %u", guid);
|
||||
if (!pGameobject->LoadGameObjectFromDB(obj->guid, map, false))
|
||||
{
|
||||
delete pGameobject;
|
||||
@@ -410,7 +410,7 @@ void PoolGroup<Quest>::Spawn1Object(PoolObject* obj)
|
||||
for (PooledQuestRelation::iterator itr = qr.first; itr != qr.second; ++itr)
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_POOLSYS, "PoolGroup<Quest>: Adding quest %u to creature %u", itr->first, itr->second);
|
||||
LOG_DEBUG("pool", "PoolGroup<Quest>: Adding quest %u to creature %u", itr->first, itr->second);
|
||||
#endif
|
||||
questMap->insert(QuestRelations::value_type(itr->second, itr->first));
|
||||
}
|
||||
@@ -421,7 +421,7 @@ void PoolGroup<Quest>::Spawn1Object(PoolObject* obj)
|
||||
for (PooledQuestRelation::iterator itr = qr.first; itr != qr.second; ++itr)
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_POOLSYS, "PoolGroup<Quest>: Adding quest %u to GO %u", itr->first, itr->second);
|
||||
LOG_DEBUG("pool", "PoolGroup<Quest>: Adding quest %u to GO %u", itr->first, itr->second);
|
||||
#endif
|
||||
questMap->insert(QuestRelations::value_type(itr->second, itr->first));
|
||||
}
|
||||
@@ -431,7 +431,7 @@ template <>
|
||||
void PoolGroup<Quest>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom)
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_POOLSYS, "PoolGroup<Quest>: Spawning pool %u", poolId);
|
||||
LOG_DEBUG("pool", "PoolGroup<Quest>: Spawning pool %u", poolId);
|
||||
#endif
|
||||
// load state from db
|
||||
if (!triggerFrom)
|
||||
@@ -560,8 +560,8 @@ void PoolMgr::LoadFromDB()
|
||||
if (!result)
|
||||
{
|
||||
mPoolTemplate.clear();
|
||||
sLog->outString(">> Loaded 0 object pools. DB table `pool_template` is empty.");
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded 0 object pools. DB table `pool_template` is empty.");
|
||||
LOG_INFO("server", " ");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -578,13 +578,13 @@ void PoolMgr::LoadFromDB()
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u objects pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded %u objects pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
|
||||
// Creatures
|
||||
|
||||
sLog->outString("Loading Creatures Pooling Data...");
|
||||
LOG_INFO("server", "Loading Creatures Pooling Data...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -593,8 +593,8 @@ void PoolMgr::LoadFromDB()
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 creatures in pools. DB table `pool_creature` is empty.");
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded 0 creatures in pools. DB table `pool_creature` is empty.");
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -610,18 +610,18 @@ void PoolMgr::LoadFromDB()
|
||||
CreatureData const* data = sObjectMgr->GetCreatureData(guid);
|
||||
if (!data)
|
||||
{
|
||||
sLog->outErrorDb("`pool_creature` has a non existing creature spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_creature` has a non existing creature spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
|
||||
continue;
|
||||
}
|
||||
auto it = mPoolTemplate.find(pool_id);
|
||||
if (it == mPoolTemplate.end())
|
||||
{
|
||||
sLog->outErrorDb("`pool_creature` pool id (%u) is not in `pool_template`, skipped.", pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_creature` pool id (%u) is not in `pool_template`, skipped.", pool_id);
|
||||
continue;
|
||||
}
|
||||
if (chance < 0 || chance > 100)
|
||||
{
|
||||
sLog->outErrorDb("`pool_creature` has an invalid chance (%f) for creature guid (%u) in pool id (%u), skipped.", chance, guid, pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_creature` has an invalid chance (%f) for creature guid (%u) in pool id (%u), skipped.", chance, guid, pool_id);
|
||||
continue;
|
||||
}
|
||||
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
||||
@@ -635,14 +635,14 @@ void PoolMgr::LoadFromDB()
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u creatures in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded %u creatures in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
}
|
||||
|
||||
// Gameobjects
|
||||
|
||||
sLog->outString("Loading Gameobject Pooling Data...");
|
||||
LOG_INFO("server", "Loading Gameobject Pooling Data...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -651,8 +651,8 @@ void PoolMgr::LoadFromDB()
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 gameobjects in pools. DB table `pool_gameobject` is empty.");
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded 0 gameobjects in pools. DB table `pool_gameobject` is empty.");
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -668,7 +668,7 @@ void PoolMgr::LoadFromDB()
|
||||
GameObjectData const* data = sObjectMgr->GetGOData(guid);
|
||||
if (!data)
|
||||
{
|
||||
sLog->outErrorDb("`pool_gameobject` has a non existing gameobject spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_gameobject` has a non existing gameobject spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -677,20 +677,20 @@ void PoolMgr::LoadFromDB()
|
||||
goinfo->type != GAMEOBJECT_TYPE_GOOBER &&
|
||||
goinfo->type != GAMEOBJECT_TYPE_FISHINGHOLE)
|
||||
{
|
||||
sLog->outErrorDb("`pool_gameobject` has a not lootable gameobject spawn (GUID: %u, type: %u) defined for pool id (%u), skipped.", guid, goinfo->type, pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_gameobject` has a not lootable gameobject spawn (GUID: %u, type: %u) defined for pool id (%u), skipped.", guid, goinfo->type, pool_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto it = mPoolTemplate.find(pool_id);
|
||||
if (it == mPoolTemplate.end())
|
||||
{
|
||||
sLog->outErrorDb("`pool_gameobject` pool id (%u) is not in `pool_template`, skipped.", pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_gameobject` pool id (%u) is not in `pool_template`, skipped.", pool_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chance < 0 || chance > 100)
|
||||
{
|
||||
sLog->outErrorDb("`pool_gameobject` has an invalid chance (%f) for gameobject guid (%u) in pool id (%u), skipped.", chance, guid, pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_gameobject` has an invalid chance (%f) for gameobject guid (%u) in pool id (%u), skipped.", chance, guid, pool_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -705,14 +705,14 @@ void PoolMgr::LoadFromDB()
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u gameobject in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded %u gameobject in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
}
|
||||
|
||||
// Pool of pools
|
||||
|
||||
sLog->outString("Loading Mother Pooling Data...");
|
||||
LOG_INFO("server", "Loading Mother Pooling Data...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -721,8 +721,8 @@ void PoolMgr::LoadFromDB()
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 pools in pools");
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded 0 pools in pools");
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -739,7 +739,7 @@ void PoolMgr::LoadFromDB()
|
||||
auto it = mPoolTemplate.find(mother_pool_id);
|
||||
if (it == mPoolTemplate.end())
|
||||
{
|
||||
sLog->outErrorDb("`pool_pool` mother_pool id (%u) is not in `pool_template`, skipped.", mother_pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_pool` mother_pool id (%u) is not in `pool_template`, skipped.", mother_pool_id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -747,18 +747,18 @@ void PoolMgr::LoadFromDB()
|
||||
auto it = mPoolTemplate.find(child_pool_id);
|
||||
if (it == mPoolTemplate.end())
|
||||
{
|
||||
sLog->outErrorDb("`pool_pool` included pool_id (%u) is not in `pool_template`, skipped.", child_pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_pool` included pool_id (%u) is not in `pool_template`, skipped.", child_pool_id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (mother_pool_id == child_pool_id)
|
||||
{
|
||||
sLog->outErrorDb("`pool_pool` pool_id (%u) includes itself, dead-lock detected, skipped.", child_pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_pool` pool_id (%u) includes itself, dead-lock detected, skipped.", child_pool_id);
|
||||
continue;
|
||||
}
|
||||
if (chance < 0 || chance > 100)
|
||||
{
|
||||
sLog->outErrorDb("`pool_pool` has an invalid chance (%f) for pool id (%u) in mother pool id (%u), skipped.", chance, child_pool_id, mother_pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_pool` has an invalid chance (%f) for pool id (%u) in mother pool id (%u), skipped.", chance, child_pool_id, mother_pool_id);
|
||||
continue;
|
||||
}
|
||||
PoolTemplateData* pPoolTemplateMother = &mPoolTemplate[mother_pool_id];
|
||||
@@ -788,7 +788,7 @@ void PoolMgr::LoadFromDB()
|
||||
ss << *itr << ' ';
|
||||
ss << "create(s) a circular reference, which can cause the server to freeze.\nRemoving the last link between mother pool "
|
||||
<< poolItr->first << " and child pool " << poolItr->second;
|
||||
sLog->outErrorDb("%s", ss.str().c_str());
|
||||
LOG_ERROR("sql.sql", "%s", ss.str().c_str());
|
||||
mPoolPoolGroups[poolItr->second].RemoveOneRelation(poolItr->first);
|
||||
mPoolSearchMap.erase(poolItr);
|
||||
--count;
|
||||
@@ -797,12 +797,12 @@ void PoolMgr::LoadFromDB()
|
||||
}
|
||||
}
|
||||
|
||||
sLog->outString(">> Loaded %u pools in mother pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded %u pools in mother pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
}
|
||||
|
||||
sLog->outString("Loading Quest Pooling Data...");
|
||||
LOG_INFO("server", "Loading Quest Pooling Data...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -811,8 +811,8 @@ void PoolMgr::LoadFromDB()
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 quests in pools");
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded 0 quests in pools");
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -838,20 +838,20 @@ void PoolMgr::LoadFromDB()
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
|
||||
if (!quest)
|
||||
{
|
||||
sLog->outErrorDb("`pool_quest` has a non existing quest template (Entry: %u) defined for pool id (%u), skipped.", entry, pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_quest` has a non existing quest template (Entry: %u) defined for pool id (%u), skipped.", entry, pool_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto it = mPoolTemplate.find(pool_id);
|
||||
if (it == mPoolTemplate.end())
|
||||
{
|
||||
sLog->outErrorDb("`pool_quest` pool id (%u) is not in `pool_template`, skipped.", pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_quest` pool id (%u) is not in `pool_template`, skipped.", pool_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!quest->IsDailyOrWeekly())
|
||||
{
|
||||
sLog->outErrorDb("`pool_quest` has an quest (%u) which is not daily or weekly in pool id (%u), use ExclusiveGroup instead, skipped.", entry, pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_quest` has an quest (%u) which is not daily or weekly in pool id (%u), use ExclusiveGroup instead, skipped.", entry, pool_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -862,7 +862,7 @@ void PoolMgr::LoadFromDB()
|
||||
|
||||
if (poolTypeMap[pool_id] != currType)
|
||||
{
|
||||
sLog->outErrorDb("`pool_quest` quest %u is %s but pool (%u) is specified for %s, mixing not allowed, skipped.",
|
||||
LOG_ERROR("sql.sql", "`pool_quest` quest %u is %s but pool (%u) is specified for %s, mixing not allowed, skipped.",
|
||||
entry, currType == QUEST_DAILY ? "QUEST_DAILY" : "QUEST_WEEKLY", pool_id, poolTypeMap[pool_id] == QUEST_DAILY ? "QUEST_DAILY" : "QUEST_WEEKLY");
|
||||
continue;
|
||||
}
|
||||
@@ -872,7 +872,7 @@ void PoolMgr::LoadFromDB()
|
||||
|
||||
if (creBounds.first == creBounds.second && goBounds.first == goBounds.second)
|
||||
{
|
||||
sLog->outErrorDb("`pool_quest` lists entry (%u) as member of pool (%u) but is not started anywhere, skipped.", entry, pool_id);
|
||||
LOG_ERROR("sql.sql", "`pool_quest` lists entry (%u) as member of pool (%u) but is not started anywhere, skipped.", entry, pool_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -887,13 +887,13 @@ void PoolMgr::LoadFromDB()
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u quests in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Loaded %u quests in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
}
|
||||
|
||||
// The initialize method will spawn all pools not in an event and not in another pool, this is why there is 2 left joins with 2 null checks
|
||||
sLog->outString("Starting objects pooling system...");
|
||||
LOG_INFO("server", "Starting objects pooling system...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -903,8 +903,8 @@ void PoolMgr::LoadFromDB()
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Pool handling system initialized, 0 pools spawned.");
|
||||
sLog->outString();
|
||||
LOG_INFO("server", ">> Pool handling system initialized, 0 pools spawned.");
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -920,9 +920,9 @@ void PoolMgr::LoadFromDB()
|
||||
if (pool_pool_id)
|
||||
// The pool is a child pool in pool_pool table. Ideally we should remove it from the pool handler to ensure it never gets spawned,
|
||||
// however that could recursively invalidate entire chain of mother pools. It can be done in the future but for now we'll do nothing.
|
||||
sLog->outErrorDb("Pool Id %u has no equal chance pooled entites defined and explicit chance sum is not 100. This broken pool is a child pool of Id %u and cannot be safely removed.", pool_entry, fields[2].GetUInt32());
|
||||
LOG_ERROR("sql.sql", "Pool Id %u has no equal chance pooled entites defined and explicit chance sum is not 100. This broken pool is a child pool of Id %u and cannot be safely removed.", pool_entry, fields[2].GetUInt32());
|
||||
else
|
||||
sLog->outErrorDb("Pool Id %u has no equal chance pooled entites defined and explicit chance sum is not 100. The pool will not be spawned.", pool_entry);
|
||||
LOG_ERROR("sql.sql", "Pool Id %u has no equal chance pooled entites defined and explicit chance sum is not 100. The pool will not be spawned.", pool_entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -934,8 +934,8 @@ void PoolMgr::LoadFromDB()
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outBasic("Pool handling system initialized, %u pools spawned in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
LOG_INFO("server", "Pool handling system initialized, %u pools spawned in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user