From af26835e3537ac6dd06de75a8a385ebd3a6de2fc Mon Sep 17 00:00:00 2001 From: "Herman S." <429230+has207@users.noreply.github.com> Date: Tue, 11 Nov 2025 10:08:33 +0900 Subject: [PATCH] [Logging] Remove file logging from the UI process UI process to only output to consle, game process to log to file --- src/xenia/base/logging.cc | 32 +++++++++------------------- src/xenia/base/main_win.cc | 4 ++-- src/xenia/base/main_win.h | 3 ++- src/xenia/ui/windowed_app_main_qt.cc | 4 ++-- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/xenia/base/logging.cc b/src/xenia/base/logging.cc index 273f7b451..5e955a62e 100644 --- a/src/xenia/base/logging.cc +++ b/src/xenia/base/logging.cc @@ -438,33 +438,21 @@ void InitializeLogging(const std::string_view app_name, bool is_game_process) { logger_->AddLogSink(std::make_unique(app_name)); } #else - FILE* log_file = nullptr; - if (cvars::log_file.empty()) { - // Default log file name based on process type - std::string file_name; - if (is_game_process) { - file_name = fmt::format("{}_game.log", app_name); + // Only enable file logging for game processes, not the UI process + if (is_game_process) { + FILE* log_file = nullptr; + if (cvars::log_file.empty()) { + // Default log file name for game process + std::string file_name = fmt::format("{}.log", app_name); + auto file_path = xe::filesystem::GetExecutableFolder() / file_name; + log_file = xe::filesystem::OpenFile(file_path, "wt"); } else { - file_name = fmt::format("{}.log", app_name); - } - auto file_path = xe::filesystem::GetExecutableFolder() / file_name; - log_file = xe::filesystem::OpenFile(file_path, "wt"); - } else { - // User specified log file - if (is_game_process) { - // Game process with explicit log file - prepend "game_" - std::filesystem::path log_path(cvars::log_file); - std::string filename = "game_" + log_path.filename().string(); - auto modified_path = log_path.parent_path() / filename; - xe::filesystem::CreateParentFolder(modified_path); - log_file = xe::filesystem::OpenFile(modified_path, "wt"); - } else { - // UI process uses log file as-is + // User specified log file - use as-is for game process xe::filesystem::CreateParentFolder(cvars::log_file); log_file = xe::filesystem::OpenFile(cvars::log_file, "wt"); } + logger_->AddLogSink(std::make_unique(log_file, true)); } - logger_->AddLogSink(std::make_unique(log_file, true)); if (cvars::log_to_stdout) { logger_->AddLogSink(std::make_unique(stdout, false)); diff --git a/src/xenia/base/main_win.cc b/src/xenia/base/main_win.cc index 67f110fcc..98e84a071 100644 --- a/src/xenia/base/main_win.cc +++ b/src/xenia/base/main_win.cc @@ -116,9 +116,9 @@ bool ParseWin32LaunchArguments( return true; } -int InitializeWin32App(const std::string_view app_name) { +int InitializeWin32App(const std::string_view app_name, bool is_game_process) { // Initialize logging. Needs parsed FLAGS. - xe::InitializeLogging(app_name); + xe::InitializeLogging(app_name, is_game_process); // Print version info. XELOGI( diff --git a/src/xenia/base/main_win.h b/src/xenia/base/main_win.h index 87a07b272..58894d12f 100644 --- a/src/xenia/base/main_win.h +++ b/src/xenia/base/main_win.h @@ -21,7 +21,8 @@ bool ParseWin32LaunchArguments( const std::vector& positional_options, std::vector* args_out); // InitializeWin32App uses cvars, call ParseWin32LaunchArguments before. -int InitializeWin32App(const std::string_view app_name); +int InitializeWin32App(const std::string_view app_name, + bool is_game_process = false); void ShutdownWin32App(); } // namespace xe diff --git a/src/xenia/ui/windowed_app_main_qt.cc b/src/xenia/ui/windowed_app_main_qt.cc index 9dd288505..19a43bbb0 100644 --- a/src/xenia/ui/windowed_app_main_qt.cc +++ b/src/xenia/ui/windowed_app_main_qt.cc @@ -246,9 +246,9 @@ int main(int argc, char** argv) { } // Use Windows-specific initialization which properly sets up logging - xe::InitializeWin32App(app->GetName()); + xe::InitializeWin32App(app->GetName(), is_game_process); #else - xe::InitializeLogging(app->GetName()); + xe::InitializeLogging(app->GetName(), is_game_process); #endif if (app->OnInitialize()) {