Add settings option to enable/disable logging to file, default to enabled
This commit is contained in:
parent
7b454ce5f4
commit
02db89f7fc
5 changed files with 255 additions and 216 deletions
|
|
@ -24,6 +24,7 @@ LogManager::LogManager()
|
|||
{
|
||||
base_clock = std::chrono::steady_clock::now();
|
||||
log_console_enabled = false;
|
||||
log_file_enabled = true;
|
||||
}
|
||||
|
||||
LogManager* LogManager::get()
|
||||
|
|
@ -63,6 +64,13 @@ void LogManager::configure(json config, const filesystem::path& defaultDir)
|
|||
| If the log is not open, create a new log file |
|
||||
\*-------------------------------------------------*/
|
||||
if(!log_stream.is_open())
|
||||
{
|
||||
if(config.contains("log_file"))
|
||||
{
|
||||
log_file_enabled = config["log_file"];
|
||||
}
|
||||
|
||||
if(log_file_enabled)
|
||||
{
|
||||
std::string logname = "OpenRGB_#.log";
|
||||
|
||||
|
|
@ -122,6 +130,7 @@ void LogManager::configure(json config, const filesystem::path& defaultDir)
|
|||
log_stream << "====================================================================================================" << std::endl;
|
||||
log_stream << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Check loglevel configuration |
|
||||
|
|
@ -183,12 +192,12 @@ void LogManager::_flush()
|
|||
| Clear temp message buffers after writing them out |
|
||||
\*-------------------------------------------------*/
|
||||
temp_messages.clear();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Flush the stream |
|
||||
\*-------------------------------------------------*/
|
||||
log_stream.flush();
|
||||
}
|
||||
}
|
||||
|
||||
void LogManager::flush()
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ public:
|
|||
std::vector<PLogMessage> messages();
|
||||
|
||||
bool log_console_enabled;
|
||||
bool log_file_enabled;
|
||||
static const char* log_codes[];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -186,10 +186,23 @@ OpenRGBSettingsPage::OpenRGBSettingsPage(QWidget *parent) :
|
|||
/*---------------------------------------------------------*\
|
||||
| Checkboxes |
|
||||
\*---------------------------------------------------------*/
|
||||
if(log_manager_settings.contains("log_file"))
|
||||
{
|
||||
ui->CheckboxLogFile->setChecked(log_manager_settings["log_file"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->CheckboxLogFile->setChecked(true);
|
||||
}
|
||||
|
||||
if(log_manager_settings.contains("log_console"))
|
||||
{
|
||||
ui->CheckboxLogConsole->setChecked(log_manager_settings["log_console"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->CheckboxLogConsole->setChecked(false);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Load drivers settings (Windows only) |
|
||||
|
|
@ -946,6 +959,14 @@ void Ui::OpenRGBSettingsPage::on_CheckboxLogConsole_clicked()
|
|||
SaveSettings();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBSettingsPage::on_CheckboxLogFile_clicked()
|
||||
{
|
||||
json log_manager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("LogManager");
|
||||
log_manager_settings["log_file"] = ui->CheckboxLogFile->isChecked();
|
||||
ResourceManager::get()->GetSettingsManager()->SetSettings("LogManager", log_manager_settings);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBSettingsPage::on_CheckboxAMDSMBusReduceCPU_clicked()
|
||||
{
|
||||
json drivers_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Drivers");
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ private slots:
|
|||
void on_CheckboxRunZoneChecks_clicked();
|
||||
void on_OpenSettingsFolderButton_clicked();
|
||||
void on_CheckboxLogConsole_clicked();
|
||||
void on_CheckboxLogFile_clicked();
|
||||
void on_CheckboxAMDSMBusReduceCPU_clicked();
|
||||
void on_CheckboxSharedSMBusAccess_clicked();
|
||||
|
||||
|
|
|
|||
|
|
@ -31,29 +31,36 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>441</width>
|
||||
<height>856</height>
|
||||
<width>460</width>
|
||||
<height>950</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="29" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartProfile">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxMinimizeOnClose">
|
||||
<property name="text">
|
||||
<string>Load Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="28" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartCustom">
|
||||
<property name="text">
|
||||
<string>Custom Arguments</string>
|
||||
<string>Minimize On Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="19" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStart">
|
||||
<widget class="QLabel" name="AutoStartLabel">
|
||||
<property name="text">
|
||||
<string>Start At Login</string>
|
||||
<string>Start At Login Settings:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="17" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAMDSMBusReduceCPU">
|
||||
<property name="text">
|
||||
<string>AMD SMBus: Reduce CPU Usage (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="25" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartServer">
|
||||
<property name="text">
|
||||
<string>Start Server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -64,54 +71,39 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAMDSMBusReduceCPU">
|
||||
<item row="10" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxDisableKeyExpansion">
|
||||
<property name="text">
|
||||
<string>AMD SMBus: Reduce CPU Usage (restart required)</string>
|
||||
<string>Disable key expansion in device view</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="18" column="0">
|
||||
<widget class="QLabel" name="AutoStartLabel">
|
||||
<item row="15" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxLogConsole">
|
||||
<property name="text">
|
||||
<string>Start At Login Settings:</string>
|
||||
<string>Enable Log Console (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="24" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartServer">
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSaveGeometry">
|
||||
<property name="text">
|
||||
<string>Start Server</string>
|
||||
<string>Save Geometry On Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="32" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSetOnExit">
|
||||
<property name="text">
|
||||
<string>Set Profile on Exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxLanguage"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="ThemeLabel">
|
||||
<property name="text">
|
||||
<string>Theme (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="12" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxHexFormat"/>
|
||||
</item>
|
||||
<item row="29" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxAutoStartProfile"/>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxShowLEDView">
|
||||
<property name="text">
|
||||
<string>Show LED view by default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="28" column="1">
|
||||
<widget class="QLineEdit" name="TextCustomArgs"/>
|
||||
</item>
|
||||
<item row="33" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxExitProfile"/>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxRunZoneChecks">
|
||||
<property name="text">
|
||||
|
|
@ -119,41 +111,10 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="32" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxExitProfile"/>
|
||||
<item row="31" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxSuspendProfile"/>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxLogConsole">
|
||||
<property name="text">
|
||||
<string>Enable Log Console (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxTheme"/>
|
||||
</item>
|
||||
<item row="27" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartClient">
|
||||
<property name="text">
|
||||
<string>Start Client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxDisableKeyExpansion">
|
||||
<property name="text">
|
||||
<string>Disable key expansion in device view</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="33" column="0">
|
||||
<widget class="QLabel" name="AutoStartStatusLabel">
|
||||
<property name="text">
|
||||
<string>Start at Login Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="34" column="0">
|
||||
<item row="35" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
|
@ -169,72 +130,62 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="25" column="1">
|
||||
<widget class="QLineEdit" name="TextServerHost"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSaveGeometry">
|
||||
<property name="text">
|
||||
<string>Save Geometry On Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxMinimizeOnClose">
|
||||
<property name="text">
|
||||
<string>Minimize On Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="23" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartMinimized">
|
||||
<property name="text">
|
||||
<string>Start Minimized</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="UserInterfaceSettingsLabel">
|
||||
<property name="text">
|
||||
<string>User Interface Settings:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="27" column="1">
|
||||
<widget class="QLineEdit" name="TextClientHost"/>
|
||||
</item>
|
||||
<item row="17" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSharedSMBusAccess">
|
||||
<property name="text">
|
||||
<string>Shared SMBus Access (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="0">
|
||||
<widget class="QLabel" name="DriversSettingsLabel">
|
||||
<property name="text">
|
||||
<string>Drivers Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxLanguage"/>
|
||||
</item>
|
||||
<item row="26" column="0">
|
||||
<item row="27" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartSetServerPort">
|
||||
<property name="text">
|
||||
<string>Set Server Port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxLoadGeometry">
|
||||
<item row="34" column="0">
|
||||
<widget class="QLabel" name="AutoStartStatusLabel">
|
||||
<property name="text">
|
||||
<string>Load Window Geometry</string>
|
||||
<string>Start at Login Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="18" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSharedSMBusAccess">
|
||||
<property name="text">
|
||||
<string>Shared SMBus Access (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="28" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartClient">
|
||||
<property name="text">
|
||||
<string>Start Client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="26" column="1">
|
||||
<widget class="QLineEdit" name="TextServerHost"/>
|
||||
</item>
|
||||
<item row="30" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartProfile">
|
||||
<property name="text">
|
||||
<string>Load Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="33" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSetOnExit">
|
||||
<property name="text">
|
||||
<string>Set Profile on Exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="HexFormatLabel">
|
||||
<property name="text">
|
||||
<string>Hex Format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="32" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxResumeProfile"/>
|
||||
</item>
|
||||
<item row="27" column="1">
|
||||
<widget class="QLineEdit" name="TextServerPort">
|
||||
<property name="inputMask">
|
||||
<string>90000</string>
|
||||
|
|
@ -247,6 +198,44 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="ThemeLabel">
|
||||
<property name="text">
|
||||
<string>Theme (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxShowLEDView">
|
||||
<property name="text">
|
||||
<string>Show LED view by default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="31" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSetOnSuspend">
|
||||
<property name="text">
|
||||
<string>Set Profile on Suspend</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="26" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartSetServerHost">
|
||||
<property name="text">
|
||||
<string>Set Server Host</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxTheme"/>
|
||||
</item>
|
||||
<item row="24" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartMinimized">
|
||||
<property name="text">
|
||||
<string>Start Minimized</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="LogManagerSettingsLabel">
|
||||
<property name="text">
|
||||
|
|
@ -254,6 +243,30 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="UserInterfaceSettingsLabel">
|
||||
<property name="text">
|
||||
<string>User Interface Settings:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="28" column="1">
|
||||
<widget class="QLineEdit" name="TextClientHost"/>
|
||||
</item>
|
||||
<item row="32" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSetOnResume">
|
||||
<property name="text">
|
||||
<string>Set Profile on Resume</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0">
|
||||
<widget class="QLabel" name="DriversSettingsLabel">
|
||||
<property name="text">
|
||||
<string>Drivers Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="LabelLanguage">
|
||||
<property name="text">
|
||||
|
|
@ -261,42 +274,36 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="25" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartSetServerHost">
|
||||
<item row="29" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartCustom">
|
||||
<property name="text">
|
||||
<string>Set Server Host</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="HexFormatLabel">
|
||||
<property name="text">
|
||||
<string>Hex Format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxHexFormat"/>
|
||||
</item>
|
||||
<item row="30" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSetOnSuspend">
|
||||
<property name="text">
|
||||
<string>Set Profile on Suspend</string>
|
||||
<string>Custom Arguments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="30" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxSuspendProfile"/>
|
||||
<widget class="QComboBox" name="ComboBoxAutoStartProfile"/>
|
||||
</item>
|
||||
<item row="31" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSetOnResume">
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxLoadGeometry">
|
||||
<property name="text">
|
||||
<string>Set Profile on Resume</string>
|
||||
<string>Load Window Geometry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="31" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxResumeProfile"/>
|
||||
<item row="20" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStart">
|
||||
<property name="text">
|
||||
<string>Start At Login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxLogFile">
|
||||
<property name="text">
|
||||
<string>Enable Log File (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue