Add source object name to Object message log

This commit is contained in:
Phillip Stephens 2022-01-09 17:15:59 -08:00
parent a5e204afe4
commit 72082fc409
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
1 changed files with 16 additions and 4 deletions

View File

@ -1330,9 +1330,15 @@ void CStateManager::SendScriptMsg(CEntity* dest, TUniqueId src, EScriptObjectMes
} }
if (m_logScripting) { if (m_logScripting) {
auto srcObj = GetObjectById(src);
if (srcObj != nullptr) {
LogModule.report(logvisor::Info, FMT_STRING("{} is sending '{}' to '{}' id= {} -> {}"), srcObj->GetName(),
ScriptObjectMessageToStr(msg), dest->GetName(), dest->GetUniqueId(), src, dest->GetUniqueId());
} else {
LogModule.report(logvisor::Info, FMT_STRING("Sending '{}' to '{}' id= {}"), ScriptObjectMessageToStr(msg), LogModule.report(logvisor::Info, FMT_STRING("Sending '{}' to '{}' id= {}"), ScriptObjectMessageToStr(msg),
dest->GetName(), dest->GetUniqueId()); dest->GetName(), dest->GetUniqueId());
} }
}
dest->AcceptScriptMsg(msg, src, *this); dest->AcceptScriptMsg(msg, src, *this);
} }
@ -1349,9 +1355,15 @@ void CStateManager::SendScriptMsgAlways(TUniqueId dest, TUniqueId src, EScriptOb
} }
if (m_logScripting) { if (m_logScripting) {
auto srcObj = GetObjectById(src);
if (srcObj != nullptr) {
LogModule.report(logvisor::Info, FMT_STRING("{} is sending '{}' to '{}' id= {} -> {}"), srcObj->GetName(),
ScriptObjectMessageToStr(msg), dst->GetName(), dst->GetUniqueId(), src, dst->GetUniqueId());
} else {
LogModule.report(logvisor::Info, FMT_STRING("Sending '{}' to '{}' id= {}"), ScriptObjectMessageToStr(msg), LogModule.report(logvisor::Info, FMT_STRING("Sending '{}' to '{}' id= {}"), ScriptObjectMessageToStr(msg),
dst->GetName(), dst->GetUniqueId()); dst->GetName(), dst->GetUniqueId());
} }
}
dst->AcceptScriptMsg(msg, src, *this); dst->AcceptScriptMsg(msg, src, *this);
} }