Rework logs a little bit to allow choosing the log level from settings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include <CPUSettings.hpp>
|
||||
#include <Options.hpp>
|
||||
#include <log.hpp>
|
||||
#include <Log.hpp>
|
||||
#include <imgui.h>
|
||||
|
||||
CPUSettings::CPUSettings() {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user