Rework logs a little bit to allow choosing the log level from settings

This commit is contained in:
2026-04-07 15:45:30 +02:00
parent fda755f7d8
commit 2db12b8083
48 changed files with 536 additions and 1182 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
#include <CPUSettings.hpp>
#include <Options.hpp>
#include <log.hpp>
#include <Log.hpp>
#include <imgui.h>
CPUSettings::CPUSettings() {
+1 -1
View File
@@ -1,7 +1,7 @@
#include <GeneralSettings.hpp>
#include <Options.hpp>
#include <imgui.h>
#include <log.hpp>
#include <Log.hpp>
GeneralSettings::GeneralSettings(gui::NativeWindow& window) : window(window) {
savesPath = Options::GetInstance().GetValue<std::string>("general", "savePath");
+34
View File
@@ -0,0 +1,34 @@
#include <MiscSettings.hpp>
#include <Options.hpp>
#include <imgui.h>
#include <Log.hpp>
MiscSettings::MiscSettings() {
currLogLevel = static_cast<Util::LogLevel>(Options::GetInstance().GetValue<int>("misc", "logLevel"));
}
void MiscSettings::render() {
const char* items[] = {
"Trace", "Debug", "Warn", "Info", "Error", "Always", "Panic"
};
const char* combo_preview_value = items[selectedLogLevel];
if (ImGui::BeginCombo("CPU Type", combo_preview_value)) {
for (int n = 0; n < IM_ARRAYSIZE(items); n++) {
const bool is_selected = (selectedLogLevel == n);
if (ImGui::Selectable(items[n], is_selected)) {
selectedLogLevel = n;
modified = true;
}
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
if(modified) {
Options::GetInstance().SetValue<int>("misc", "logLevel", static_cast<int>(selectedLogLevel));
}
}
+11
View File
@@ -0,0 +1,11 @@
#pragma once
#include <SettingsTab.hpp>
#include <Log.hpp>
struct MiscSettings final : SettingsTab {
void render() override;
explicit MiscSettings();
private:
Util::LogLevel currLogLevel;
int selectedLogLevel = 4;
};