logging improvements
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "Gen.h"
|
||||
#include "Global.h"
|
||||
#include "Instance.h"
|
||||
#include "Log.h"
|
||||
#include "Mesh.h"
|
||||
#include "Puzzle.h"
|
||||
#include "Tools.h"
|
||||
@@ -153,27 +154,45 @@ namespace Tools
|
||||
if (ImGui::Begin("Log"))
|
||||
{
|
||||
ImGui::Checkbox("Shorten File Names", &debug.ShortenLogFileNames);
|
||||
ImGui::BeginTable(
|
||||
"tbl", 4, ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_SizingFixedFit);
|
||||
ImGui::BeginTable("tbl",
|
||||
4,
|
||||
ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable |
|
||||
ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg);
|
||||
ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableSetupColumn("Log");
|
||||
ImGui::TableSetupColumn("Line", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableSetupColumn("File", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
auto& logs = GetLogHistory();
|
||||
for (int32_t i = 0; i < bx::min(100, LogInternal::LogHistorySize); ++i)
|
||||
{
|
||||
int32_t idx = GetLogHistory().WriteIdx - i - 1;
|
||||
int32_t idx = logs.WriteIdx - i - 1;
|
||||
if (idx < 0) idx += LogInternal::LogHistorySize;
|
||||
const char* line = &GetLogHistory().LogBuffer[idx * LogInternal::MaxLineSize];
|
||||
const char* line = &logs.LogBuffer[idx * LogInternal::MaxLineSize];
|
||||
if (line[0] != 0)
|
||||
{
|
||||
int64_t timeOffset = GetLogHistory().WriteTime[idx] - time.StartTime;
|
||||
int64_t timeOffset = logs.WriteTime[idx] - time.StartTime;
|
||||
double writeTime = (double)timeOffset / bx::getHPFrequency();
|
||||
uint32_t fileLine = GetLogHistory().LineBuffer[idx];
|
||||
const char* filePath = &GetLogHistory().FileBuffer[idx * LogInternal::MaxLineSize];
|
||||
uint32_t fileLine = logs.LineBuffer[idx];
|
||||
const char* filePath = &logs.FileBuffer[idx * LogInternal::MaxLineSize];
|
||||
const char* filePathRes =
|
||||
debug.ShortenLogFileNames ? bx::FilePath{filePath}.getFileName().getPtr() : filePath;
|
||||
|
||||
// ImVec4 texCol = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
// if (logs.WriteType[idx] == ELogType::Warn)
|
||||
// texCol = {1.0f, 1.0f, 0.8f, 1.0f};
|
||||
// else if (logs.WriteType[idx] == ELogType::Error)
|
||||
// texCol = {1.0f, 0.8f, 0.8f, 1.0f};
|
||||
// ImGui::PushStyleColor(ImGuiCol_Text, texCol);
|
||||
ImVec4 bgCol = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
if (logs.WriteType[idx] == ELogType::Warn)
|
||||
bgCol = {0.2f, 0.2f, 0.0f, 1.0f};
|
||||
else if (logs.WriteType[idx] == ELogType::Error)
|
||||
bgCol = {0.2f, 0.0f, 0.0f, 1.0f};
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBg, bgCol);
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, bgCol);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%.01f", writeTime);
|
||||
@@ -187,6 +206,8 @@ namespace Tools
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", filePathRes);
|
||||
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
|
||||
Reference in New Issue
Block a user