Qt: Add log window

This commit is contained in:
Stenzek
2023-09-30 14:40:50 +10:00
parent 8afccdd590
commit 4ad777f54f
22 changed files with 808 additions and 160 deletions

View File

@ -295,7 +295,7 @@ static const SettingInfo s_settings[] = {
{SettingInfo::Type::String, "CrosshairColor", TRANSLATE_NOOP("GunCon", "Cursor Color"),
TRANSLATE_NOOP("GunCon", "Applies a color to the chosen crosshair images, can be used for multiple players. Specify "
"in HTML/CSS format (e.g. #aabbcc)"),
"#ffffff"},
"#ffffff", nullptr, nullptr, nullptr, nullptr, nullptr, 0.0f},
{SettingInfo::Type::Float, "XScale", TRANSLATE_NOOP("GunCon", "X Scale"),
TRANSLATE_NOOP("GunCon", "Scales X coordinates relative to the center of the screen."), "1.0", "0.01", "2.0", "0.01",
"%.0f%%", nullptr, 100.0f}};

View File

@ -355,6 +355,7 @@ void Settings::Load(SettingsInterface& si)
log_level = ParseLogLevelName(si.GetStringValue("Logging", "LogLevel", GetLogLevelName(DEFAULT_LOG_LEVEL)).c_str())
.value_or(DEFAULT_LOG_LEVEL);
log_filter = si.GetStringValue("Logging", "LogFilter", "");
log_timestamps = si.GetBoolValue("Logging", "LogTimestamps", true);
log_to_console = si.GetBoolValue("Logging", "LogToConsole", DEFAULT_LOG_TO_CONSOLE);
log_to_debug = si.GetBoolValue("Logging", "LogToDebug", false);
log_to_window = si.GetBoolValue("Logging", "LogToWindow", false);
@ -555,6 +556,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetStringValue("Logging", "LogLevel", GetLogLevelName(log_level));
si.SetStringValue("Logging", "LogFilter", log_filter.c_str());
si.SetBoolValue("Logging", "LogTimestamps", log_timestamps);
si.SetBoolValue("Logging", "LogToConsole", log_to_console);
si.SetBoolValue("Logging", "LogToDebug", log_to_debug);
si.SetBoolValue("Logging", "LogToWindow", log_to_window);
@ -703,14 +705,15 @@ void Settings::FixIncompatibleSettings(bool display_osd_messages)
void Settings::UpdateLogSettings()
{
Log::SetFilterLevel(log_level);
Log::SetConsoleOutputParams(log_to_console, log_filter.empty() ? nullptr : log_filter.c_str(), log_level);
Log::SetDebugOutputParams(log_to_debug, log_filter.empty() ? nullptr : log_filter.c_str(), log_level);
Log::SetLogLevel(log_level);
Log::SetLogfilter(log_filter);
Log::SetConsoleOutputParams(log_to_console, log_timestamps);
Log::SetDebugOutputParams(log_to_debug);
if (log_to_file)
{
Log::SetFileOutputParams(log_to_file, Path::Combine(EmuFolders::DataRoot, "duckstation.log").c_str(), true,
log_filter.empty() ? nullptr : log_filter.c_str(), log_level);
Log::SetFileOutputParams(log_to_file, Path::Combine(EmuFolders::DataRoot, "duckstation.log").c_str(),
log_timestamps);
}
else
{
@ -1528,3 +1531,132 @@ bool EmuFolders::EnsureFoldersExist()
result = FileSystem::EnsureDirectoryExists(Textures.c_str(), false) && result;
return result;
}
static const char* s_log_filters[] = {
"Achievements",
"AnalogController",
"AnalogJoystick",
"AudioStream",
"AutoUpdaterDialog",
"BIOS",
"Bus",
"ByteStream",
"CDImage",
"CDImageBin",
"CDImageCHD",
"CDImageCueSheet",
"CDImageDevice",
"CDImageEcm",
"CDImageMds",
"CDImageMemory",
"CDImagePBP",
"CDImagePPF",
"CDROM",
"CDROMAsyncReader",
"CDSubChannelReplacement",
"CPU::CodeCache",
"CPU::Core",
"CPU::Recompiler",
"Common::PageFaultHandler",
"ControllerBindingWidget",
"CueParser",
"Cheats",
"DMA",
"DisplayWidget",
"FileSystem",
"FullscreenUI",
"GDBConnection",
"GDBProtocol",
"GDBServer",
"GPU",
"GPUBackend",
"GPUDevice",
"GPUShaderCache",
"GPUTexture",
"GPU_HW",
"GPU_SW",
"GameDatabase",
"GameList",
"GunCon",
"HTTPDownloader",
"Host",
"HostInterfaceProgressCallback",
"INISettingsInterface",
"ISOReader",
"ImGuiFullscreen",
"ImGuiManager",
"Image",
"InputManager",
"InterruptController",
"JitCodeBuffer",
"MDEC",
"MainWindow",
"MemoryArena",
"MemoryCard",
"Multitap",
"NoGUIHost",
"PCDrv",
"PGXP",
"PSFLoader",
"Pad",
"PlatformMisc",
"PlayStationMouse",
"PostProcessing",
"ProgressCallback",
"QTTranslations",
"QtHost",
"ReShadeFXShader",
"Recompiler::CodeGenerator",
"RegTestHost",
"SDLInputSource",
"SIO",
"SPIRVCompiler",
"SPU",
"Settings",
"ShaderGen",
"StateWrapper",
"System",
"TextureReplacements",
"Timers",
"TimingEvents",
"WAVWriter",
"WindowInfo",
#ifdef ENABLE_CUBEB
"CubebAudioStream",
#endif
#ifdef ENABLE_OPENGL
"GL::Context",
"OpenGLDevice",
#endif
#ifdef ENABLE_VULKAN
"VulkanDevice",
#endif
#if defined(_WIN32)
"D3D11Device",
"D3D12Device",
"D3D12StreamBuffer",
"D3DCommon",
"DInputSource",
"Win32ProgressCallback",
"Win32RawInputSource",
"XAudio2AudioStream",
"XInputSource",
#elif defined(__APPLE__)
"CocoaNoGUIPlatform",
"CocoaProgressCallback",
"MetalDevice",
#else
"ContextEGLWayland",
"X11NoGUIPlatform",
"WaylandNoGUIPlatform",
#endif
};
std::span<const char*> Settings::GetLogFilters()
{
return s_log_filters;
}

View File

@ -248,6 +248,7 @@ struct Settings
LOGLEVEL log_level = DEFAULT_LOG_LEVEL;
std::string log_filter;
bool log_timestamps = true;
bool log_to_console = DEFAULT_LOG_TO_CONSOLE;
bool log_to_debug = false;
bool log_to_window = false;
@ -345,6 +346,7 @@ struct Settings
static std::optional<LOGLEVEL> ParseLogLevelName(const char* str);
static const char* GetLogLevelName(LOGLEVEL level);
static const char* GetLogLevelDisplayName(LOGLEVEL level);
static std::span<const char*> GetLogFilters();
static std::optional<ConsoleRegion> ParseConsoleRegionName(const char* str);
static const char* GetConsoleRegionName(ConsoleRegion region);

View File

@ -3692,6 +3692,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
}
if (g_settings.log_level != old_settings.log_level || g_settings.log_filter != old_settings.log_filter ||
g_settings.log_timestamps != old_settings.log_timestamps ||
g_settings.log_to_console != old_settings.log_to_console ||
g_settings.log_to_debug != old_settings.log_to_debug || g_settings.log_to_window != old_settings.log_to_window ||
g_settings.log_to_file != old_settings.log_to_file)