Skip to content

Commit

Permalink
add the status log level
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Jan 1, 2024
1 parent a908a50 commit 300bbb3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ConfigData {
bool operator==(const Font_&) const = default;
} Font;
struct Debug_ {
std::string LogLevel = "no";
std::string LogLevel = "status";
int LogLimit = 500;
bool operator==(const Debug_&) const = default;
} Debug;
Expand Down
2 changes: 1 addition & 1 deletion include/views/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Debug : public View {
bool AutoScroll = true;
bool ScrollToBottom = false;
bool CommandInited = false;
std::string LogLevel = "v";
std::string LogLevel = "status";
int LogLimit = 500;
};

Expand Down
15 changes: 6 additions & 9 deletions source/views/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,21 +363,18 @@ void Debug::Console::AddLog(const char* level, const char* fmt, ...) {

ImVec4 Debug::Console::LogColor(const char* level) {
std::map<std::string, ImVec4> logColors = {
{"fatal", ImVec4{0.804f, 0, 0, 1.0f}},
{"error", ImVec4{0.804f, 0, 0, 1.0f}},
{"warn", ImVec4{0.804f, 0.804f, 0, 1.0f}},
{"info", ImGui::GetStyle().Colors[ImGuiCol_Text]},
{"v", ImVec4{0.075f, 0.631f, 0.055f, 1.0f}},
{"debug", ImGui::GetStyle().Colors[ImGuiCol_Text]},
{"trace", ImGui::GetStyle().Colors[ImGuiCol_Text]},
{"fatal", ImVec4{0.804f, 0, 0, 1.0f}}, {"error", ImVec4{0.804f, 0, 0, 1.0f}},
{"warn", ImVec4{0.804f, 0.804f, 0, 1.0f}}, {"info", ImVec4{1.0f, 1.0f, 1.0f, 1.0f}},
{"status", ImVec4{1.0f, 1.0f, 1.0f, 1.0f}}, {"v", ImVec4{0.075f, 0.631f, 0.055f, 1.0f}},
{"debug", ImVec4{0.50f, 0.50f, 0.50f, 1.0f}}, {"trace", ImVec4{0.30f, 0.30f, 0.30f, 1.0f}},
};
if (level == nullptr || !logColors.contains(level)) level = "info";
if (level == nullptr || !logColors.contains(level)) level = "status";
return logColors[level];
}

void Debug::Console::draw() {
if (ImGui::BeginPopup("Log Level")) {
const char* items[] = {"fatal", "error", "warn", "info", "v", "debug", "trace", "no"};
const char* items[] = {"fatal", "error", "warn", "info", "status", "v", "debug", "trace", "no"};
static std::string level = LogLevel;
for (int i = 0; i < IM_ARRAYSIZE(items); i++) {
if (ImGui::MenuItem(items[i], nullptr, level == items[i])) {
Expand Down
2 changes: 1 addition & 1 deletion source/views/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void Settings::drawGeneralTab() {
ImGui::SameLine();
ImGui::HelpMarker("views.settings.general.debug.help"_i18n);
ImGui::Indent();
const char *items[] = {"fatal", "error", "warn", "info", "v", "debug", "trace", "no"};
const char *items[] = {"fatal", "error", "warn", "info", "status", "v", "debug", "trace", "no"};
static int current;
for (int i = 0; i < IM_ARRAYSIZE(items); i++) {
if (strcmp(items[i], data.Debug.LogLevel.c_str()) == 0) current = i;
Expand Down

0 comments on commit 300bbb3

Please sign in to comment.