Skip to content
Permalink
Browse files

Merge pull request #7994 from faxx1080/qt_adddebuglog

DolphinQt: Add debug log option in GUI for debug builds
  • Loading branch information...
leoetlino committed May 10, 2019
2 parents 123bbbc + 1030dec commit 672e8d78c6c509934666b60139a98c8f1ed52183
Showing with 23 additions and 11 deletions.
  1. +21 −11 Source/Core/DolphinQt/Config/LogConfigWidget.cpp
  2. +2 −0 Source/Core/DolphinQt/Config/LogConfigWidget.h
@@ -47,6 +47,7 @@ void LogConfigWidget::CreateWidgets()
m_verbosity_error = new QRadioButton(tr("Error"));
m_verbosity_warning = new QRadioButton(tr("Warning"));
m_verbosity_info = new QRadioButton(tr("Info"));
m_verbosity_debug = new QRadioButton(tr("Debug"));

auto* outputs = new QGroupBox(tr("Logger Outputs"));
auto* outputs_layout = new QVBoxLayout;
@@ -74,6 +75,10 @@ void LogConfigWidget::CreateWidgets()
verbosity_layout->addWidget(m_verbosity_error);
verbosity_layout->addWidget(m_verbosity_warning);
verbosity_layout->addWidget(m_verbosity_info);
if (MAX_LOGLEVEL == LogTypes::LOG_LEVELS::LDEBUG)
{
verbosity_layout->addWidget(m_verbosity_debug);
}

layout->addWidget(outputs);
outputs_layout->addWidget(m_out_file);
@@ -97,6 +102,7 @@ void LogConfigWidget::ConnectWidgets()
connect(m_verbosity_error, &QRadioButton::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_verbosity_warning, &QRadioButton::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_verbosity_info, &QRadioButton::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_verbosity_debug, &QRadioButton::toggled, this, &LogConfigWidget::SaveSettings);

connect(m_out_file, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_out_console, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);
@@ -131,11 +137,12 @@ void LogConfigWidget::LoadSettings()
setFloating(settings.value(QStringLiteral("logconfigwidget/floating")).toBool());

// Config - Verbosity
int verbosity = logmanager->GetLogLevel();
m_verbosity_notice->setChecked(verbosity == 1);
m_verbosity_error->setChecked(verbosity == 2);
m_verbosity_warning->setChecked(verbosity == 3);
m_verbosity_info->setChecked(verbosity == 4);
const LogTypes::LOG_LEVELS verbosity = logmanager->GetLogLevel();
m_verbosity_notice->setChecked(verbosity == LogTypes::LOG_LEVELS::LNOTICE);
m_verbosity_error->setChecked(verbosity == LogTypes::LOG_LEVELS::LERROR);
m_verbosity_warning->setChecked(verbosity == LogTypes::LOG_LEVELS::LWARNING);
m_verbosity_info->setChecked(verbosity == LogTypes::LOG_LEVELS::LINFO);
m_verbosity_debug->setChecked(verbosity == LogTypes::LOG_LEVELS::LDEBUG);

// Config - Outputs
m_out_file->setChecked(logmanager->IsListenerEnabled(LogListener::FILE_LISTENER));
@@ -165,22 +172,25 @@ void LogConfigWidget::SaveSettings()
settings.setValue(QStringLiteral("logconfigwidget/floating"), isFloating());

// Config - Verbosity
int verbosity = 1;
LogTypes::LOG_LEVELS verbosity = LogTypes::LOG_LEVELS::LNOTICE;

if (m_verbosity_notice->isChecked())
verbosity = 1;
verbosity = LogTypes::LOG_LEVELS::LNOTICE;

if (m_verbosity_error->isChecked())
verbosity = 2;
verbosity = LogTypes::LOG_LEVELS::LERROR;

if (m_verbosity_warning->isChecked())
verbosity = 3;
verbosity = LogTypes::LOG_LEVELS::LWARNING;

if (m_verbosity_info->isChecked())
verbosity = 4;
verbosity = LogTypes::LOG_LEVELS::LINFO;

if (m_verbosity_debug->isChecked())
verbosity = LogTypes::LOG_LEVELS::LDEBUG;

// Config - Verbosity
LogManager::GetInstance()->SetLogLevel(static_cast<LogTypes::LOG_LEVELS>(verbosity));
LogManager::GetInstance()->SetLogLevel(verbosity);

// Config - Outputs
LogManager::GetInstance()->EnableListener(LogListener::FILE_LISTENER, m_out_file->isChecked());
@@ -33,6 +33,8 @@ class LogConfigWidget final : public QDockWidget
QRadioButton* m_verbosity_error;
QRadioButton* m_verbosity_warning;
QRadioButton* m_verbosity_info;
QRadioButton* m_verbosity_debug;

QCheckBox* m_out_file;
QCheckBox* m_out_console;
QCheckBox* m_out_window;

0 comments on commit 672e8d7

Please sign in to comment.
You can’t perform that action at this time.