refactor(Core/Logging): switch to fmt style for LOG_ (#10366)

* feat(Core/Common): add support fmt style for ASSERT and ABORT

* correct CheckCompactArrayMaskOverflow

* 1

* Update src/server/game/Spells/Spell.cpp

* rework logging

* add fmt replace logs

* logging

* FMT_LOG_

* settings

* fix startup

* 1

* 2

* 3

* 4

* 5

* fmt::print

* to fmt
This commit is contained in:
Kargatum
2022-01-27 22:44:41 +07:00
committed by GitHub
parent 5228d29379
commit 5969df4e30
211 changed files with 3689 additions and 3842 deletions

View File

@@ -528,23 +528,23 @@ void SpellCastTargets::OutDebug() const
if (!m_targetMask)
LOG_INFO("spells", "No targets");
LOG_INFO("spells", "target mask: %u", m_targetMask);
LOG_INFO("spells", "target mask: {}", m_targetMask);
if (m_targetMask & (TARGET_FLAG_UNIT_MASK | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_GAMEOBJECT_MASK))
LOG_INFO("spells", "Object target: %s", m_objectTargetGUID.ToString().c_str());
LOG_INFO("spells", "Object target: {}", m_objectTargetGUID.ToString());
if (m_targetMask & TARGET_FLAG_ITEM)
LOG_INFO("spells", "Item target: %s", m_itemTargetGUID.ToString().c_str());
LOG_INFO("spells", "Item target: {}", m_itemTargetGUID.ToString());
if (m_targetMask & TARGET_FLAG_TRADE_ITEM)
LOG_INFO("spells", "Trade item target: %s", m_itemTargetGUID.ToString().c_str());
LOG_INFO("spells", "Trade item target: {}", m_itemTargetGUID.ToString());
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
LOG_INFO("spells", "Source location: transport guid: %s trans offset: %s position: %s",
m_src._transportGUID.ToString().c_str(), m_src._transportOffset.ToString().c_str(), m_src._position.ToString().c_str());
LOG_INFO("spells", "Source location: transport guid: {} trans offset: {} position: {}",
m_src._transportGUID.ToString(), m_src._transportOffset.ToString(), m_src._position.ToString());
if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
LOG_INFO("spells", "Destination location: transport guid: %s trans offset: %s position: %s",
m_dst._transportGUID.ToString().c_str(), m_dst._transportOffset.ToString().c_str(), m_dst._position.ToString().c_str());
LOG_INFO("spells", "Destination location: transport guid: {} trans offset: {} position: {}",
m_dst._transportGUID.ToString(), m_dst._transportOffset.ToString(), m_dst._position.ToString());
if (m_targetMask & TARGET_FLAG_STRING)
LOG_INFO("spells", "String: %s", m_strTarget.c_str());
LOG_INFO("spells", "speed: %f", m_speed);
LOG_INFO("spells", "elevation: %f", m_elevation);
LOG_INFO("spells", "String: {}", m_strTarget);
LOG_INFO("spells", "speed: {}", m_speed);
LOG_INFO("spells", "elevation: {}", m_elevation);
}
SpellValue::SpellValue(SpellInfo const* proto)
@@ -696,7 +696,7 @@ Spell::~Spell()
{
// Clean the reference to avoid later crash.
// If this error is repeating, we may have to add an ASSERT to better track down how we get into this case.
LOG_ERROR("spells", "Spell::~Spell: deleting spell for spell ID %u. However, spell still referenced.", m_spellInfo->Id);
LOG_ERROR("spells", "Spell::~Spell: deleting spell for spell ID {}. However, spell still referenced.", m_spellInfo->Id);
*m_selfContainer = nullptr;
}
@@ -1025,7 +1025,7 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar
}
break;
case TARGET_SELECT_CATEGORY_NYI:
LOG_DEBUG("spells.aura", "SPELL: target type %u, found in spellID %u, effect %u is not implemented yet!", m_spellInfo->Id, effIndex, targetType.GetTarget());
LOG_DEBUG("spells.aura", "SPELL: target type {}, found in spellID {}, effect {} is not implemented yet!", m_spellInfo->Id, effIndex, targetType.GetTarget());
break;
default:
ASSERT(false && "Spell::SelectEffectImplicitTargets: received not implemented select target category");
@@ -1056,7 +1056,7 @@ void Spell::SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTa
}
else
{
LOG_DEBUG("spells.aura", "SPELL: cannot find channel spell target for spell ID %u, effect %u", m_spellInfo->Id, effIndex);
LOG_DEBUG("spells.aura", "SPELL: cannot find channel spell target for spell ID {}, effect {}", m_spellInfo->Id, effIndex);
}
break;
}
@@ -1076,7 +1076,7 @@ void Spell::SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTa
}
else //if (!m_targets.HasDst())
{
LOG_DEBUG("spells.aura", "SPELL: cannot find channel spell destination for spell ID %u, effect %u", m_spellInfo->Id, effIndex);
LOG_DEBUG("spells.aura", "SPELL: cannot find channel spell destination for spell ID {}, effect {}", m_spellInfo->Id, effIndex);
}
break;
case TARGET_DEST_CHANNEL_CASTER:
@@ -1123,7 +1123,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
// handle emergency case - try to use other provided targets if no conditions provided
if (targetType.GetCheckType() == TARGET_CHECK_ENTRY && (!condList || condList->empty()))
{
LOG_DEBUG("spells.aura", "Spell::SelectImplicitNearbyTargets: no conditions entry for target with TARGET_CHECK_ENTRY of spell ID %u, effect %u - selecting default targets", m_spellInfo->Id, effIndex);
LOG_DEBUG("spells.aura", "Spell::SelectImplicitNearbyTargets: no conditions entry for target with TARGET_CHECK_ENTRY of spell ID {}, effect {} - selecting default targets", m_spellInfo->Id, effIndex);
switch (targetType.GetObjectType())
{
case TARGET_OBJECT_TYPE_GOBJ:
@@ -1150,14 +1150,14 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
WorldObject* target = SearchNearbyTarget(range, targetType.GetObjectType(), targetType.GetCheckType(), condList);
if (!target)
{
LOG_DEBUG("spells.aura", "Spell::SelectImplicitNearbyTargets: cannot find nearby target for spell ID %u, effect %u", m_spellInfo->Id, effIndex);
LOG_DEBUG("spells.aura", "Spell::SelectImplicitNearbyTargets: cannot find nearby target for spell ID {}, effect {}", m_spellInfo->Id, effIndex);
return;
}
CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
if (!target)
{
//LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set nullptr target, effect %u", m_spellInfo->Id, effIndex);
//LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id {} set nullptr target, effect {}", m_spellInfo->Id, effIndex);
return;
}
@@ -1178,7 +1178,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
}
else
{
//LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected unit, got %s, effect %u", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask);
//LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id {} set object of wrong type, expected unit, got {}, effect {}", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask);
return;
}
break;
@@ -1188,7 +1188,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
AddGOTarget(gobjTarget, effMask);
else
{
//LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected gameobject, got %s, effect %u", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask);
//LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id {} set object of wrong type, expected gameobject, got {}, effect {}", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask);
return;
}
break;
@@ -1359,7 +1359,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
}
else
{
LOG_DEBUG("spells.aura", "SPELL: unknown target coordinates for spell ID %u", m_spellInfo->Id);
LOG_DEBUG("spells.aura", "SPELL: unknown target coordinates for spell ID {}", m_spellInfo->Id);
if (WorldObject* target = m_targets.GetObjectTarget())
dest = SpellDestination(*target);
}
@@ -1683,7 +1683,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTarge
if (a > -0.0001f)
a = 0;
LOG_ERROR("spells", "Spell::SelectTrajTargets: a %f b %f", a, b);
LOG_ERROR("spells", "Spell::SelectTrajTargets: a {} b {}", a, b);
// Xinef: hack for distance, many trajectory spells have RangeEntry 1 (self)
float bestDist = m_spellInfo->GetMaxRange(false) * 2;
@@ -1702,13 +1702,13 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTarge
const float objDist2d = std::fabs(m_targets.GetSrcPos()->GetExactDist2d(*itr) * cos(m_targets.GetSrcPos()->GetRelativeAngle(*itr)));
const float dz = std::fabs((*itr)->GetPositionZ() - m_targets.GetSrcPos()->m_positionZ);
LOG_ERROR("spells", "Spell::SelectTrajTargets: check %u, dist between %f %f, height between %f %f.",
LOG_ERROR("spells", "Spell::SelectTrajTargets: check {}, dist between {} {}, height between {} {}.",
(*itr)->GetEntry(), objDist2d - size, objDist2d + size, dz - size, dz + size);
float dist = objDist2d - size;
float height = dist * (a * dist + b);
LOG_ERROR("spells", "Spell::SelectTrajTargets: dist %f, height %f.", dist, height);
LOG_ERROR("spells", "Spell::SelectTrajTargets: dist {}, height {}.", dist, height);
if (dist < bestDist && height < dz + size && height > dz - size)
{
@@ -1717,7 +1717,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTarge
}
#define CHECK_DIST {\
LOG_ERROR("spells", "Spell::SelectTrajTargets: dist %f, height %f.", dist, height);\
LOG_ERROR("spells", "Spell::SelectTrajTargets: dist {}, height {}.", dist, height);\
if (dist > bestDist)\
continue;\
if (dist < objDist2d + size && dist > objDist2d - size)\
@@ -1793,7 +1793,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTarge
float distSq = (*itr)->GetExactDistSq(x, y, z);
float sizeSq = (*itr)->GetObjectSize();
sizeSq *= sizeSq;
LOG_ERROR("spells", "Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);
LOG_ERROR("spells", "Initial {} {} {} {} {}", x, y, z, distSq, sizeSq);
if (distSq > sizeSq)
{
float factor = 1 - sqrt(sizeSq / distSq);
@@ -1802,7 +1802,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTarge
z += factor * ((*itr)->GetPositionZ() - z);
distSq = (*itr)->GetExactDistSq(x, y, z);
LOG_ERROR("spells", "Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);
LOG_ERROR("spells", "Initial {} {} {} {} {}", x, y, z, distSq, sizeSq);
}
}
@@ -3063,7 +3063,7 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask)
{
if (CanExecuteTriggersOnHit(effMask, i->triggeredByAura) && roll_chance_i(i->chance))
{
LOG_DEBUG("spells.aura", "Spell %d triggered spell %d by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->triggeredSpell->Id);
LOG_DEBUG("spells.aura", "Spell {} triggered spell {} by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->triggeredSpell->Id);
// SPELL_AURA_ADD_TARGET_TRIGGER auras shouldn't trigger auras without duration
// set duration of current aura to the triggered spell
@@ -3425,7 +3425,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
// set timer base at cast time
ReSetTimer();
LOG_DEBUG("spells.aura", "Spell::prepare: spell id %u source %u caster %d customCastFlags %u mask %u", m_spellInfo->Id, m_caster->GetEntry(), m_originalCaster ? m_originalCaster->GetEntry() : -1, _triggeredCastFlags, m_targets.GetTargetMask());
LOG_DEBUG("spells.aura", "Spell::prepare: spell id {} source {} caster {} customCastFlags {} mask {}", m_spellInfo->Id, m_caster->GetEntry(), m_originalCaster ? m_originalCaster->GetEntry() : -1, _triggeredCastFlags, m_targets.GetTargetMask());
if (!(m_spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && !(m_spellInfo->Attributes & SPELL_ATTR0_ALLOW_WHILE_SITTING) && !m_triggeredByAuraSpell && m_caster->IsSitState())
{
@@ -4113,7 +4113,7 @@ void Spell::update(uint32 difftime)
if (m_targets.GetUnitTargetGUID() && !m_targets.GetUnitTarget())
{
LOG_DEBUG("spells.aura", "Spell %u is cancelled due to removal of target.", m_spellInfo->Id);
LOG_DEBUG("spells.aura", "Spell {} is cancelled due to removal of target.", m_spellInfo->Id);
cancel();
return;
}
@@ -4171,7 +4171,7 @@ void Spell::update(uint32 difftime)
// Xinef: so the aura can be removed in different updates for all units
else if ((m_timer < 0 || m_timer > 300) && !UpdateChanneledTargetList())
{
LOG_DEBUG("spells.aura", "Channeled spell %d is removed due to lack of targets", m_spellInfo->Id);
LOG_DEBUG("spells.aura", "Channeled spell {} is removed due to lack of targets", m_spellInfo->Id);
SendChannelUpdate(0);
finish();
}
@@ -4235,7 +4235,7 @@ void Spell::finish(bool ok)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell);
if (spellInfo && spellInfo->SpellIconID == 2056)
{
LOG_DEBUG("spells.aura", "Statue %s is unsummoned in spell %d finish", m_caster->GetGUID().ToString().c_str(), m_spellInfo->Id);
LOG_DEBUG("spells.aura", "Statue {} is unsummoned in spell {} finish", m_caster->GetGUID().ToString(), m_spellInfo->Id);
m_caster->setDeathState(JUST_DIED);
return;
}
@@ -4445,7 +4445,7 @@ void Spell::SendSpellStart()
if (!IsNeedSendToClient(false))
return;
//LOG_DEBUG("spells.aura", "Sending SMSG_SPELL_START id=%u", m_spellInfo->Id);
//LOG_DEBUG("spells.aura", "Sending SMSG_SPELL_START id={}", m_spellInfo->Id);
uint32 castFlags = CAST_FLAG_HAS_TRAJECTORY;
@@ -4500,7 +4500,7 @@ void Spell::SendSpellGo()
if (!IsNeedSendToClient(true))
return;
//LOG_DEBUG("spells.aura", "Sending SMSG_SPELL_GO id=%u", m_spellInfo->Id);
//LOG_DEBUG("spells.aura", "Sending SMSG_SPELL_GO id={}", m_spellInfo->Id);
uint32 castFlags = CAST_FLAG_UNKNOWN_9;
@@ -4938,7 +4938,7 @@ void Spell::TakeCastItem()
{
// This code is to avoid a crash
// I'm not sure, if this is really an error, but I guess every item needs a prototype
LOG_ERROR("spells", "Cast item has no item prototype %s", m_CastItem->GetGUID().ToString().c_str());
LOG_ERROR("spells", "Cast item has no item prototype {}", m_CastItem->GetGUID().ToString());
return;
}
@@ -5034,7 +5034,7 @@ void Spell::TakePower()
if (PowerType >= MAX_POWERS)
{
LOG_ERROR("spells", "Spell::TakePower: Unknown power type '%d'", PowerType);
LOG_ERROR("spells", "Spell::TakePower: Unknown power type '{}'", PowerType);
return;
}
@@ -5293,7 +5293,7 @@ void Spell::HandleThreatSpells()
else if (!m_spellInfo->_IsPositiveSpell() && !IsFriendly && target->CanHaveThreatList())
target->AddThreat(m_caster, threatToAdd, m_spellInfo->GetSchoolMask(), m_spellInfo);
}
LOG_DEBUG("spells.aura", "Spell %u, added an additional %f threat for %s %u target(s)", m_spellInfo->Id, threat, m_spellInfo->_IsPositiveSpell() ? "assisting" : "harming", uint32(m_UniqueTargetInfo.size()));
LOG_DEBUG("spells.aura", "Spell {}, added an additional {} threat for {} {} target(s)", m_spellInfo->Id, threat, m_spellInfo->_IsPositiveSpell() ? "assisting" : "harming", uint32(m_UniqueTargetInfo.size()));
}
void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, uint32 i, SpellEffectHandleMode mode)
@@ -5306,7 +5306,7 @@ void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOT
uint8 eff = m_spellInfo->Effects[i].Effect;
LOG_DEBUG("spells.aura", "Spell: %u Effect : %u", m_spellInfo->Id, eff);
LOG_DEBUG("spells.aura", "Spell: {} Effect : {}", m_spellInfo->Id, eff);
// we do not need DamageMultiplier here.
damage = CalculateSpellDamage(i, nullptr);
@@ -6770,7 +6770,7 @@ SpellCastResult Spell::CheckPower()
// Check valid power type
if (m_spellInfo->PowerType >= MAX_POWERS)
{
LOG_ERROR("spells", "Spell::CheckPower: Unknown power type '%d'", m_spellInfo->PowerType);
LOG_ERROR("spells", "Spell::CheckPower: Unknown power type '{}'", m_spellInfo->PowerType);
return SPELL_FAILED_UNKNOWN;
}
@@ -7415,7 +7415,7 @@ void Spell::Delayed() // only called in DealDamage()
else
m_timer += delaytime;
LOG_DEBUG("spells", "Spell %u partially interrupted for (%d) ms at damage", m_spellInfo->Id, delaytime);
LOG_DEBUG("spells", "Spell {} partially interrupted for ({}) ms at damage", m_spellInfo->Id, delaytime);
WorldPacket data(SMSG_SPELL_DELAYED, 8 + 4);
data << m_caster->GetPackGUID();
@@ -7453,7 +7453,7 @@ void Spell::DelayedChannel()
else
m_timer -= delaytime;
LOG_DEBUG("spells.aura", "Spell %u partially interrupted for %i ms, new duration: %u ms", m_spellInfo->Id, delaytime, m_timer);
LOG_DEBUG("spells.aura", "Spell {} partially interrupted for {} ms, new duration: {} ms", m_spellInfo->Id, delaytime, m_timer);
for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
if ((*ihit).missCondition == SPELL_MISS_NONE)
@@ -7713,8 +7713,8 @@ SpellEvent::~SpellEvent()
}
else
{
LOG_ERROR("spells", "~SpellEvent: %s %s tried to delete non-deletable spell %u. Was not deleted, causes memory leak.",
(m_Spell->GetCaster()->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), m_Spell->GetCaster()->GetGUID().ToString().c_str(), m_Spell->m_spellInfo->Id);
LOG_ERROR("spells", "~SpellEvent: {} {} tried to delete non-deletable spell {}. Was not deleted, causes memory leak.",
(m_Spell->GetCaster()->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), m_Spell->GetCaster()->GetGUID().ToString(), m_Spell->m_spellInfo->Id);
ABORT();
}
}
@@ -8130,7 +8130,7 @@ void Spell::LoadScripts()
m_loadedScripts.erase(bitr);
continue;
}
LOG_DEBUG("spells.aura", "Spell::LoadScripts: Script `%s` for spell `%u` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
LOG_DEBUG("spells.aura", "Spell::LoadScripts: Script `{}` for spell `{}` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
(*itr)->Register();
++itr;
}