mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-01-05 17:13:29 +08:00
feat: Add more debug logging (#503)
This commit is contained in:
parent
491799efe1
commit
485243f21a
@ -21,7 +21,15 @@ namespace big
|
||||
{
|
||||
bool metric_logs{};
|
||||
|
||||
bool script_event_logs = false;
|
||||
bool script_hook_logs{};
|
||||
|
||||
struct
|
||||
{
|
||||
bool logs = false;
|
||||
|
||||
bool filter_player = true;
|
||||
std::int8_t player_id = -1;
|
||||
} script_event{};
|
||||
} logs{};
|
||||
};
|
||||
|
||||
@ -395,7 +403,7 @@ namespace big
|
||||
void from_json(const nlohmann::json& j)
|
||||
{
|
||||
this->debug.logs.metric_logs = j["debug"]["logs"]["metric_logs"];
|
||||
this->debug.logs.script_event_logs = j["debug"]["logs"]["script_event_logs"];
|
||||
this->debug.logs.script_hook_logs = j["debug"]["logs"]["script_hook_logs"];
|
||||
|
||||
g->notifications.gta_thread_kill.log = j["notifications"]["gta_thread_kill"]["log"];
|
||||
g->notifications.gta_thread_kill.notify = j["notifications"]["gta_thread_kill"]["notify"];
|
||||
@ -688,7 +696,7 @@ namespace big
|
||||
"logs",
|
||||
{
|
||||
{ "metric_logs", this->debug.logs.metric_logs },
|
||||
{ "script_event_logs", this->debug.logs.script_event_logs }
|
||||
{ "script_hook_logs", this->debug.logs.script_hook_logs }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,16 +323,21 @@ namespace big
|
||||
}
|
||||
|
||||
|
||||
if (g->debug.logs.script_event_logs)
|
||||
if (g->debug.logs.script_event.logs && (!g->debug.logs.script_event.filter_player || g->debug.logs.script_event.player_id == player->m_player_id))
|
||||
{
|
||||
LOG(INFO) << "== Begin of Script Event ==";
|
||||
LOG(INFO) << "Player: " << player->get_name();
|
||||
LOG(INFO) << "Hash/Arg #0: " << (int)hash;
|
||||
std::string script_args = "{ ";
|
||||
for (std::size_t i = 0; i < scripted_game_event->m_args_size; i++)
|
||||
{
|
||||
if (i)
|
||||
script_args += ", ";
|
||||
|
||||
for (std::size_t i = 1; i < sizeof(args); i++)
|
||||
LOG(INFO) << "Arg #" << i << ": " << args[i];
|
||||
script_args += std::to_string(args[i]);
|
||||
}
|
||||
script_args += " };";
|
||||
|
||||
LOG(INFO) << "== End of Script Event ==";
|
||||
LOG(G3LOG_DEBUG) << "Script Event:\n"
|
||||
<< "\tPlayer: " << player->get_name() << "\n"
|
||||
<< "\tArgs: " << script_args;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -68,7 +68,7 @@ namespace big
|
||||
if (m_script_hooks.find(gta_thread->m_script_hash) != m_script_hooks.end())
|
||||
{
|
||||
// this should never happen but if it does we catch it
|
||||
LOG(INFO) << "Dynamic native script hook still active for script, cleaning up...";
|
||||
LOG_IF(G3LOG_DEBUG, g->debug.logs.script_hook_logs) << "Dynamic native script hook still active for script, cleaning up...";
|
||||
|
||||
m_script_hooks.erase(gta_thread->m_script_hash);
|
||||
}
|
||||
@ -87,7 +87,7 @@ namespace big
|
||||
{
|
||||
if (m_script_hooks.erase(gta_thread->m_script_hash))
|
||||
{
|
||||
LOG(INFO) << gta_thread->m_name << " script terminated, cleaning up native hooks";
|
||||
LOG_IF(G3LOG_DEBUG, g->debug.logs.script_hook_logs) << gta_thread->m_name << " script terminated, cleaning up native hooks";
|
||||
}
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ namespace big
|
||||
if (program->is_valid())
|
||||
{
|
||||
hook_instance(program);
|
||||
LOG(INFO) << "Hooked " << program->m_name << " script (" << HEX_TO_UPPER(static_cast<void*>(program)) << ")";
|
||||
LOG_IF(G3LOG_DEBUG, g->debug.logs.script_hook_logs) << "Hooked " << program->m_name << " script (" << HEX_TO_UPPER(static_cast<void*>(program)) << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
#include "view_debug.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void debug::logs()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Logs"))
|
||||
{
|
||||
ImGui::Checkbox("Log Metrics", &g->debug.logs.metric_logs);
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
41
BigBaseV2/src/views/debug/views_debug_logs.cpp
Normal file
41
BigBaseV2/src/views/debug/views_debug_logs.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "gui/components/components.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
#include "view_debug.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void debug::logs()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Logs"))
|
||||
{
|
||||
ImGui::Checkbox("Log Metrics", &g->debug.logs.metric_logs);
|
||||
|
||||
ImGui::Checkbox("Native Script Hooks", &g->debug.logs.script_hook_logs);
|
||||
|
||||
if (ImGui::TreeNode("Script Event Logging"))
|
||||
{
|
||||
ImGui::Checkbox("Enable Script Event Logging", &g->debug.logs.script_event.logs);
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Checkbox("Filter by Player", &g->debug.logs.script_event.filter_player);
|
||||
|
||||
if (g->debug.logs.script_event.filter_player)
|
||||
{
|
||||
ImGui::ListBoxHeader("##filter_player");
|
||||
for (const auto& [_, player] : g_player_service->players())
|
||||
{
|
||||
if (components::selectable(player->get_name(), g->debug.logs.script_event.player_id == player->id()))
|
||||
{
|
||||
g->debug.logs.script_event.player_id = player->id();
|
||||
}
|
||||
}
|
||||
ImGui::EndListBox();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user