Merge pull request #6638 from GPUCode/new-log
common: Backport yuzu log improvements
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#include "citra_qt/debugger/console.h"
|
||||
#include "citra_qt/uisettings.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/logging/backend.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "ui_configure_debug.h"
|
||||
@@ -89,9 +89,9 @@ void ConfigureDebug::ApplyConfiguration() {
|
||||
UISettings::values.show_console = ui->toggle_console->isChecked();
|
||||
Settings::values.log_filter = ui->log_filter_edit->text().toStdString();
|
||||
Debugger::ToggleConsole();
|
||||
Log::Filter filter;
|
||||
Common::Log::Filter filter;
|
||||
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
||||
Log::SetGlobalFilter(filter);
|
||||
Common::Log::SetGlobalFilter(filter);
|
||||
Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked();
|
||||
Settings::values.renderer_debug = ui->toggle_renderer_debug->isChecked();
|
||||
|
||||
|
@@ -8,10 +8,13 @@
|
||||
#include "citra_qt/configuration/configure_dialog.h"
|
||||
#include "citra_qt/hotkeys.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "ui_configure.h"
|
||||
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, bool enable_web_config)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigureDialog>()), registry(registry) {
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, Core::System& system_,
|
||||
bool enable_web_config)
|
||||
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, registry{registry_},
|
||||
system{system_} {
|
||||
Settings::SetConfiguringGlobal(true);
|
||||
|
||||
ui->setupUi(this);
|
||||
@@ -68,7 +71,7 @@ void ConfigureDialog::ApplyConfiguration() {
|
||||
ui->webTab->ApplyConfiguration();
|
||||
ui->uiTab->ApplyConfiguration();
|
||||
ui->storageTab->ApplyConfiguration();
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
Settings::LogSettings();
|
||||
}
|
||||
|
||||
|
@@ -13,11 +13,15 @@ namespace Ui {
|
||||
class ConfigureDialog;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
class ConfigureDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
|
||||
explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, Core::System& system,
|
||||
bool enable_web_config = true);
|
||||
~ConfigureDialog() override;
|
||||
|
||||
@@ -37,4 +41,5 @@ private:
|
||||
|
||||
std::unique_ptr<Ui::ConfigureDialog> ui;
|
||||
HotkeyRegistry& registry;
|
||||
Core::System& system;
|
||||
};
|
||||
|
@@ -102,7 +102,7 @@ void ConfigurePerGame::ApplyConfiguration() {
|
||||
audio_tab->ApplyConfiguration();
|
||||
debug_tab->ApplyConfiguration();
|
||||
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
Settings::LogSettings();
|
||||
|
||||
game_config->Save();
|
||||
|
@@ -21,6 +21,7 @@ void ToggleConsole() {
|
||||
console_shown = UISettings::values.show_console.GetValue();
|
||||
}
|
||||
|
||||
using namespace Common::Log;
|
||||
#ifdef _WIN32
|
||||
FILE* temp;
|
||||
if (UISettings::values.show_console) {
|
||||
@@ -29,24 +30,20 @@ void ToggleConsole() {
|
||||
freopen_s(&temp, "CONIN$", "r", stdin);
|
||||
freopen_s(&temp, "CONOUT$", "w", stdout);
|
||||
freopen_s(&temp, "CONOUT$", "w", stderr);
|
||||
Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>());
|
||||
SetColorConsoleBackendEnabled(true);
|
||||
}
|
||||
} else {
|
||||
if (FreeConsole()) {
|
||||
// In order to close the console, we have to also detach the streams on it.
|
||||
// Just redirect them to NUL if there is no console window
|
||||
Log::RemoveBackend(Log::ColorConsoleBackend::Name());
|
||||
SetColorConsoleBackendEnabled(false);
|
||||
freopen_s(&temp, "NUL", "r", stdin);
|
||||
freopen_s(&temp, "NUL", "w", stdout);
|
||||
freopen_s(&temp, "NUL", "w", stderr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (UISettings::values.show_console) {
|
||||
Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>());
|
||||
} else {
|
||||
Log::RemoveBackend(Log::ColorConsoleBackend::Name());
|
||||
}
|
||||
SetColorConsoleBackendEnabled(UISettings::values.show_console.GetValue());
|
||||
#endif
|
||||
}
|
||||
} // namespace Debugger
|
||||
|
@@ -8,10 +8,11 @@
|
||||
#include "citra_qt/dumping/options_dialog.h"
|
||||
#include "citra_qt/uisettings.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "ui_dumping_dialog.h"
|
||||
|
||||
DumpingDialog::DumpingDialog(QWidget* parent)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::DumpingDialog>()) {
|
||||
DumpingDialog::DumpingDialog(QWidget* parent, Core::System& system_)
|
||||
: QDialog(parent), ui{std::make_unique<Ui::DumpingDialog>()}, system{system_} {
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -216,5 +217,5 @@ void DumpingDialog::ApplyConfiguration() {
|
||||
Settings::values.audio_encoder_options = ui->audioEncoderOptionsLineEdit->text().toStdString();
|
||||
Settings::values.audio_bitrate = ui->audioBitrateSpinBox->value();
|
||||
UISettings::values.video_dumping_path = last_path;
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
}
|
||||
|
@@ -10,13 +10,17 @@ namespace Ui {
|
||||
class DumpingDialog;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
class DumpingDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DumpingDialog(QWidget* parent);
|
||||
explicit DumpingDialog(QWidget* parent, Core::System& system);
|
||||
~DumpingDialog() override;
|
||||
|
||||
QString GetFilePath() const;
|
||||
@@ -32,6 +36,7 @@ private:
|
||||
QLineEdit* line_edit);
|
||||
|
||||
std::unique_ptr<Ui::DumpingDialog> ui;
|
||||
Core::System& system;
|
||||
|
||||
QString last_path;
|
||||
|
||||
|
@@ -144,25 +144,12 @@ void GMainWindow::ShowTelemetryCallout() {
|
||||
"<br/><br/>Would you like to share your usage data with us?");
|
||||
if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) == QMessageBox::Yes) {
|
||||
NetSettings::values.enable_telemetry = true;
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
}
|
||||
}
|
||||
|
||||
const int GMainWindow::max_recent_files_item;
|
||||
|
||||
static void InitializeLogging() {
|
||||
Log::Filter log_filter;
|
||||
log_filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
||||
Log::SetGlobalFilter(log_filter);
|
||||
|
||||
const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);
|
||||
FileUtil::CreateFullPath(log_dir);
|
||||
Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir + LOG_FILE));
|
||||
#ifdef _WIN32
|
||||
Log::AddBackend(std::make_unique<Log::DebuggerBackend>());
|
||||
#endif
|
||||
}
|
||||
|
||||
static QString PrettyProductName() {
|
||||
#ifdef _WIN32
|
||||
// After Windows 10 Version 2004, Microsoft decided to switch to a different notation: 20H2
|
||||
@@ -188,9 +175,10 @@ static QString PrettyProductName() {
|
||||
GMainWindow::GMainWindow(Core::System& system_)
|
||||
: ui{std::make_unique<Ui::MainWindow>()}, system{system_}, movie{Core::Movie::GetInstance()},
|
||||
config{std::make_unique<Config>()}, emu_thread{nullptr} {
|
||||
InitializeLogging();
|
||||
Common::Log::Initialize();
|
||||
Common::Log::Start();
|
||||
|
||||
Debugger::ToggleConsole();
|
||||
Settings::LogSettings();
|
||||
|
||||
// register types to use in slots and signals
|
||||
qRegisterMetaType<std::size_t>("std::size_t");
|
||||
@@ -1193,12 +1181,13 @@ void GMainWindow::BootGame(const QString& filename) {
|
||||
const std::string config_file_name =
|
||||
title_id == 0 ? name : fmt::format("{:016X}", title_id);
|
||||
Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig);
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
|
||||
LOG_INFO(Frontend, "Using per game config file for title id {}", config_file_name);
|
||||
Settings::LogSettings();
|
||||
}
|
||||
|
||||
Settings::LogSettings();
|
||||
|
||||
// Save configurations
|
||||
UpdateUISettings();
|
||||
game_list->SaveInterfaceLayout();
|
||||
@@ -1936,7 +1925,7 @@ void GMainWindow::ChangeScreenLayout() {
|
||||
}
|
||||
|
||||
Settings::values.layout_option = new_layout;
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
UpdateSecondaryWindowVisibility();
|
||||
}
|
||||
|
||||
@@ -1964,18 +1953,18 @@ void GMainWindow::ToggleScreenLayout() {
|
||||
|
||||
Settings::values.layout_option = new_layout;
|
||||
SyncMenuUISettings();
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
UpdateSecondaryWindowVisibility();
|
||||
}
|
||||
|
||||
void GMainWindow::OnSwapScreens() {
|
||||
Settings::values.swap_screen = ui->action_Screen_Layout_Swap_Screens->isChecked();
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
}
|
||||
|
||||
void GMainWindow::OnRotateScreens() {
|
||||
Settings::values.upright_screen = ui->action_Screen_Layout_Upright_Screens->isChecked();
|
||||
Settings::Apply();
|
||||
system.ApplySettings();
|
||||
}
|
||||
|
||||
void GMainWindow::TriggerSwapScreens() {
|
||||
@@ -2014,7 +2003,7 @@ void GMainWindow::OnLoadState() {
|
||||
void GMainWindow::OnConfigure() {
|
||||
game_list->SetDirectoryWatcherEnabled(false);
|
||||
Settings::SetConfiguringGlobal(true);
|
||||
ConfigureDialog configureDialog(this, hotkey_registry,
|
||||
ConfigureDialog configureDialog(this, hotkey_registry, system,
|
||||
!multiplayer_state->IsHostingPublicRoom());
|
||||
connect(&configureDialog, &ConfigureDialog::LanguageChanged, this,
|
||||
&GMainWindow::OnLanguageChanged);
|
||||
@@ -2336,7 +2325,7 @@ void GMainWindow::OnOpenFFmpeg() {
|
||||
#endif
|
||||
|
||||
void GMainWindow::OnStartVideoDumping() {
|
||||
DumpingDialog dialog(this);
|
||||
DumpingDialog dialog(this, system);
|
||||
if (dialog.exec() != QDialog::DialogCode::Accepted) {
|
||||
ui->action_Dump_Video->setChecked(false);
|
||||
return;
|
||||
@@ -2938,7 +2927,7 @@ int main(int argc, char* argv[]) {
|
||||
// generating shaders
|
||||
setlocale(LC_ALL, "C");
|
||||
|
||||
Core::System& system = Core::System::GetInstance();
|
||||
auto& system{Core::System::GetInstance()};
|
||||
GMainWindow main_window(system);
|
||||
|
||||
// Register frontend applets
|
||||
|
Reference in New Issue
Block a user