diff --git a/src/common/config.cpp b/src/common/config.cpp index cc3b86315..0260d8e17 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -66,6 +66,7 @@ static bool vkHostMarkers = false; static bool vkGuestMarkers = false; static bool rdocEnable = false; static bool isFpsColor = true; +static bool isSeparateLogFilesEnabled = false; static s16 cursorState = HideCursorState::Idle; static int cursorHideTimeout = 5; // 5 seconds (default) static bool useUnifiedInputConfig = true; @@ -451,6 +452,10 @@ void setLogFilter(const std::string& type) { logFilter = type; } +void setSeparateLogFilesEnabled(bool enabled) { + isSeparateLogFilesEnabled = enabled; +} + void setUserName(const std::string& type) { userName = type; } @@ -656,6 +661,10 @@ u32 GetLanguage() { return m_language; } +bool getSeparateLogFilesEnabled() { + return isSeparateLogFilesEnabled; +} + int getBackgroundImageOpacity() { return backgroundImageOpacity; } @@ -761,6 +770,7 @@ void load(const std::filesystem::path& path) { const toml::value& debug = data.at("Debug"); isDebugDump = toml::find_or(debug, "DebugDump", false); + isSeparateLogFilesEnabled = toml::find_or(debug, "isSeparateLogFilesEnabled", false); isShaderDebug = toml::find_or(debug, "CollectShader", false); isFpsColor = toml::find_or(debug, "FPSColor", true); } @@ -887,6 +897,7 @@ void save(const std::filesystem::path& path) { data["Vulkan"]["rdocEnable"] = rdocEnable; data["Debug"]["DebugDump"] = isDebugDump; data["Debug"]["CollectShader"] = isShaderDebug; + data["Debug"]["isSeparateLogFilesEnabled"] = isSeparateLogFilesEnabled; data["Debug"]["FPSColor"] = isFpsColor; data["Keys"]["TrophyKey"] = trophyKey; diff --git a/src/common/config.h b/src/common/config.h index 7b9bc789b..abf8da8aa 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -111,7 +111,8 @@ void setIsMotionControlsEnabled(bool use); void setLogType(const std::string& type); void setLogFilter(const std::string& type); - +void setSeparateLogFilesEnabled(bool enabled); +bool getSeparateLogFilesEnabled(); void setVkValidation(bool enable); void setVkSyncValidation(bool enable); void setRdocEnabled(bool enable); diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 7802977f5..c16a5399a 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -139,8 +139,9 @@ public: std::filesystem::create_directory(log_dir); Filter filter; filter.ParseFilterString(Config::getLogFilter()); - instance = std::unique_ptr(new Impl(log_dir / LOG_FILE, filter), - Deleter); + const auto& log_file_path = log_file.empty() ? LOG_FILE : log_file; + instance = std::unique_ptr( + new Impl(log_dir / log_file_path, filter), Deleter); initialization_in_progress_suppress_logging = false; } diff --git a/src/emulator.cpp b/src/emulator.cpp index cd981add2..0f444c887 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -50,29 +50,6 @@ Emulator::Emulator() { SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); #endif - // Start logger. - Common::Log::Initialize(); - Common::Log::Start(); - LOG_INFO(Loader, "Starting shadps4 emulator v{} ", Common::VERSION); - LOG_INFO(Loader, "Revision {}", Common::g_scm_rev); - LOG_INFO(Loader, "Branch {}", Common::g_scm_branch); - LOG_INFO(Loader, "Description {}", Common::g_scm_desc); - LOG_INFO(Loader, "Remote {}", Common::g_scm_remote_url); - - LOG_INFO(Config, "General LogType: {}", Config::getLogType()); - LOG_INFO(Config, "General isNeo: {}", Config::isNeoModeConsole()); - LOG_INFO(Config, "GPU isNullGpu: {}", Config::nullGpu()); - LOG_INFO(Config, "GPU shouldDumpShaders: {}", Config::dumpShaders()); - LOG_INFO(Config, "GPU vblankDivider: {}", Config::vblankDiv()); - LOG_INFO(Config, "Vulkan gpuId: {}", Config::getGpuId()); - LOG_INFO(Config, "Vulkan vkValidation: {}", Config::vkValidationEnabled()); - LOG_INFO(Config, "Vulkan vkValidationSync: {}", Config::vkValidationSyncEnabled()); - LOG_INFO(Config, "Vulkan vkValidationGpu: {}", Config::vkValidationGpuEnabled()); - LOG_INFO(Config, "Vulkan crashDiagnostics: {}", Config::getVkCrashDiagnosticEnabled()); - LOG_INFO(Config, "Vulkan hostMarkers: {}", Config::getVkHostMarkersEnabled()); - LOG_INFO(Config, "Vulkan guestMarkers: {}", Config::getVkGuestMarkersEnabled()); - LOG_INFO(Config, "Vulkan rdocEnable: {}", Config::isRdocEnabled()); - // Create stdin/stdout/stderr Common::Singleton::Instance()->CreateStdHandles(); @@ -90,9 +67,8 @@ Emulator::Emulator() { const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); QString filePath = QString::fromStdString((user_dir / "play_time.txt").string()); QFile file(filePath); - if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { - LOG_INFO(Loader, "Error opening or creating play_time.txt"); - } + ASSERT_MSG(file.open(QIODevice::ReadWrite | QIODevice::Text), + "Error opening or creating play_time.txt"); #endif } @@ -138,6 +114,34 @@ void Emulator::Run(const std::filesystem::path& file, const std::vectorGetString("CONTENT_ID"); ASSERT_MSG(content_id.has_value(), "Failed to get CONTENT_ID"); id = std::string(*content_id, 7, 9); + + if (Config::getSeparateLogFilesEnabled()) { + Common::Log::Initialize(id + ".log"); + } + else { + Common::Log::Initialize(); + } + Common::Log::Start(); + LOG_INFO(Loader, "Starting shadps4 emulator v{} ", Common::VERSION); + LOG_INFO(Loader, "Revision {}", Common::g_scm_rev); + LOG_INFO(Loader, "Branch {}", Common::g_scm_branch); + LOG_INFO(Loader, "Description {}", Common::g_scm_desc); + LOG_INFO(Loader, "Remote {}", Common::g_scm_remote_url); + + LOG_INFO(Config, "General LogType: {}", Config::getLogType()); + LOG_INFO(Config, "General isNeo: {}", Config::isNeoModeConsole()); + LOG_INFO(Config, "GPU isNullGpu: {}", Config::nullGpu()); + LOG_INFO(Config, "GPU shouldDumpShaders: {}", Config::dumpShaders()); + LOG_INFO(Config, "GPU vblankDivider: {}", Config::vblankDiv()); + LOG_INFO(Config, "Vulkan gpuId: {}", Config::getGpuId()); + LOG_INFO(Config, "Vulkan vkValidation: {}", Config::vkValidationEnabled()); + LOG_INFO(Config, "Vulkan vkValidationSync: {}", Config::vkValidationSyncEnabled()); + LOG_INFO(Config, "Vulkan vkValidationGpu: {}", Config::vkValidationGpuEnabled()); + LOG_INFO(Config, "Vulkan crashDiagnostics: {}", Config::getVkCrashDiagnosticEnabled()); + LOG_INFO(Config, "Vulkan hostMarkers: {}", Config::getVkHostMarkersEnabled()); + LOG_INFO(Config, "Vulkan guestMarkers: {}", Config::getVkGuestMarkersEnabled()); + LOG_INFO(Config, "Vulkan rdocEnable: {}", Config::isRdocEnabled()); + Libraries::NpTrophy::game_serial = id; const auto trophyDir = Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / id / "TrophyFiles"; diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index bf09c979b..ce6f59937 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -425,6 +425,8 @@ void SettingsDialog::LoadValuesFromConfig() { QString::fromStdString(toml::find_or(data, "Keys", "TrophyKey", ""))); ui->trophyKeyLineEdit->setEchoMode(QLineEdit::Password); ui->debugDump->setChecked(toml::find_or(data, "Debug", "DebugDump", false)); + ui->separateLogFilesCheckbox->setChecked( + toml::find_or(data, "Debug", "isSeparateLogFilesEnabled", false)); ui->vkValidationCheckBox->setChecked(toml::find_or(data, "Vulkan", "validation", false)); ui->vkSyncValidationCheckBox->setChecked( toml::find_or(data, "Vulkan", "validation_sync", false)); @@ -648,7 +650,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) { text = tr("Copy GPU Buffers:\\nGets around race conditions involving GPU submits.\\nMay or may not help with PM4 type 0 crashes."); } else if (elementName == "collectShaderCheckBox") { text = tr("Collect Shaders:\\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10)."); - } + } else if (elementName == "separateLogFilesCheckbox") { + text = tr("Separate Log Files:\\nWrites a separate logfile for each game.");} // clang-format on ui->descriptionText->setText(text.replace("\\n", "\n")); } @@ -700,6 +703,7 @@ void SettingsDialog::UpdateSettings() { Config::setLoadGameSizeEnabled(ui->gameSizeCheckBox->isChecked()); Config::setShowSplash(ui->showSplashCheckBox->isChecked()); Config::setDebugDump(ui->debugDump->isChecked()); + Config::setSeparateLogFilesEnabled(ui->separateLogFilesCheckbox->isChecked()); Config::setVkValidation(ui->vkValidationCheckBox->isChecked()); Config::setVkSyncValidation(ui->vkSyncValidationCheckBox->isChecked()); Config::setRdocEnabled(ui->rdocCheckBox->isChecked()); diff --git a/src/qt_gui/settings_dialog.ui b/src/qt_gui/settings_dialog.ui index fe8d6733e..2df328fbe 100644 --- a/src/qt_gui/settings_dialog.ui +++ b/src/qt_gui/settings_dialog.ui @@ -59,7 +59,7 @@ - 0 + 6 @@ -73,8 +73,8 @@ 0 0 - 946 - 536 + 718 + 332 @@ -454,8 +454,8 @@ 0 0 - 946 - 536 + 646 + 395 @@ -903,8 +903,8 @@ 0 0 - 946 - 536 + 545 + 141 @@ -1198,8 +1198,8 @@ 0 0 - 946 - 536 + 234 + 292 @@ -1342,8 +1342,8 @@ 0 0 - 946 - 536 + 455 + 252 @@ -1626,8 +1626,8 @@ 0 0 - 946 - 536 + 216 + 254 @@ -1888,39 +1888,50 @@ - - - Enable Crash Diagnostics - - - - - - - Collect Shaders - - - - - - - Copy GPU Buffers - - - - - - - Host Debug Markers - - - - - - - Guest Debug Markers - - + + + + + Collect Shaders + + + + + + + Copy GPU Buffers + + + + + + + Enable Crash Diagnostics + + + + + + + Host Debug Markers + + + + + + + Guest Debug Markers + + + + + + + Separate Log Files + + + +