Skip to content

Commit b94663a

Browse files
Disable log console by default, add a setting in LogManager settings section to enable it
1 parent 77b924d commit b94663a

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

LogManager.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const char* LogManager::log_codes[] = {"FATAL:", "ERROR:", "Warning:", "Info:",
1414
LogManager::LogManager()
1515
{
1616
base_clock = std::chrono::steady_clock::now();
17+
log_console_enabled = false;
1718
}
1819

1920
LogManager* LogManager::get()
@@ -118,6 +119,14 @@ void LogManager::configure(json config, const std::string &defaultDir)
118119
}
119120
}
120121

122+
/*-------------------------------------------------*\
123+
| Check log console configuration |
124+
\*-------------------------------------------------*/
125+
if(config.contains("log_console"))
126+
{
127+
log_console_enabled = config["log_console"];
128+
}
129+
121130
/*-------------------------------------------------*\
122131
| Flush the log |
123132
\*-------------------------------------------------*/
@@ -224,7 +233,10 @@ void LogManager::_append(const char* filename, int line, unsigned int level, con
224233
\*-------------------------------------------------*/
225234
temp_messages.push_back(mes);
226235

227-
all_messages.push_back(mes);
236+
if(log_console_enabled)
237+
{
238+
all_messages.push_back(mes);
239+
}
228240

229241
/*-------------------------------------------------*\
230242
| Flush the queues |

LogManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class LogManager
9393
void clearMessages();
9494
std::vector<PLogMessage> messages();
9595

96+
bool log_console_enabled;
9697
static const char* log_codes[];
9798
};
9899

qt/OpenRGBDialog2.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,23 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
478478
}
479479

480480
/*-----------------------------------------------------*\
481-
| Add the console page |
481+
| If log console is enabled in settings, enable it |
482482
\*-----------------------------------------------------*/
483-
AddConsolePage();
483+
json log_manager_settings = settings_manager->GetSettings("LogManager");
484+
485+
bool log_console_enabled = false;
486+
if(log_manager_settings.contains("log_console"))
487+
{
488+
log_console_enabled = log_manager_settings["log_console"];
489+
}
490+
491+
/*-----------------------------------------------------*\
492+
| Add the log console page |
493+
\*-----------------------------------------------------*/
494+
if(log_console_enabled)
495+
{
496+
AddConsolePage();
497+
}
484498

485499
}
486500

0 commit comments

Comments
 (0)