mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
adding nesting to debug logs
This commit is contained in:
@@ -12,6 +12,10 @@ namespace mlx
|
||||
};
|
||||
}
|
||||
|
||||
std::uint32_t Logs::s_nesting = 0;
|
||||
|
||||
constexpr int LOGS_TABS_WIDTH = 4;
|
||||
|
||||
void Logs::Report(LogType type, std::string message)
|
||||
{
|
||||
Report(type, 0, {}, {}, std::move(message));
|
||||
@@ -38,7 +42,14 @@ namespace mlx
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case LogType::Debug: std::cout << Ansi::blue << "[MLX Debug] " << Ansi::def << code_infos << message << '\n'; break;
|
||||
case LogType::Debug:
|
||||
{
|
||||
std::cout << Ansi::blue << "[MLX Debug] " << Ansi::def << std::flush;
|
||||
std::printf("%*s", s_nesting * LOGS_TABS_WIDTH, "");
|
||||
std::fflush(stdout);
|
||||
std::cout << code_infos << message << std::endl;
|
||||
break;
|
||||
}
|
||||
case LogType::Message: std::cout << Ansi::blue << "[MLX Message] " << Ansi::def << code_infos << message << '\n'; break;
|
||||
case LogType::Warning: std::cout << Ansi::magenta << "[MLX Warning] " << Ansi::def << code_infos << message << '\n'; break;
|
||||
case LogType::Error: std::cerr << Ansi::red << "[MLX Error] " << Ansi::def << code_infos << message << '\n'; break;
|
||||
@@ -52,4 +63,15 @@ namespace mlx
|
||||
EventBus::Send("__MlxApplication", Internal::FatalErrorEvent{});
|
||||
}
|
||||
}
|
||||
|
||||
void Logs::BeginSection()
|
||||
{
|
||||
s_nesting++;
|
||||
}
|
||||
|
||||
void Logs::EndSection()
|
||||
{
|
||||
if(s_nesting > 0)
|
||||
s_nesting--;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user