optimize nested calling log

This commit is contained in:
gb 2023-05-15 09:02:58 +08:00
parent 957c901dc9
commit 9c1fab4368
1 changed files with 11 additions and 1 deletions

View File

@ -1571,6 +1571,7 @@ Twpp::Result huagao_ds::setupFileXferReset(const Twpp::Identity& origin, Twpp::S
}
Result huagao_ds::call(const Identity& origin, DataGroup dg, Dat dat, Msg msg, void* data) {
static bool in_calling = false;
static unsigned nested_events = 0;
bool calling = in_calling;
if (calling)
@ -1585,7 +1586,9 @@ Result huagao_ds::call(const Identity& origin, DataGroup dg, Dat dat, Msg msg, v
}
else
{
load_sane_util::log_info(L"Nested Call: discard 'Msg::ProcessEvent'!\r\n", 0);
if(nested_events == 0)
load_sane_util::log_info(L"Nested Call: discard 'Msg::ProcessEvent'!\r\n", 0);
nested_events++;
return { ReturnCode::NotDsEvent, ConditionCode::Success };
}
}
@ -1600,6 +1603,13 @@ Result huagao_ds::call(const Identity& origin, DataGroup dg, Dat dat, Msg msg, v
{
in_calling = true;
}
if (nested_events > 1)
{
wchar_t buf[256] = { 0 };
swprintf_s(buf, _countof(buf) - 1, L"Discard %u nested Msg::ProcessEvent messages before.\r\n", nested_events);
load_sane_util::log_info(buf, 0);
}
nested_events = 0;
try {
// we can override almost anything from SourceFromThis, even the top-most source instance call