Disable log console by default, add a setting in LogManager settings section to enable it

This commit is contained in:
Adam Honse 2021-10-06 19:16:11 -05:00
parent 77b924d5f7
commit b94663aa03
3 changed files with 30 additions and 3 deletions

View file

@ -14,6 +14,7 @@ const char* LogManager::log_codes[] = {"FATAL:", "ERROR:", "Warning:", "Info:",
LogManager::LogManager()
{
base_clock = std::chrono::steady_clock::now();
log_console_enabled = false;
}
LogManager* LogManager::get()
@ -118,6 +119,14 @@ void LogManager::configure(json config, const std::string &defaultDir)
}
}
/*-------------------------------------------------*\
| Check log console configuration |
\*-------------------------------------------------*/
if(config.contains("log_console"))
{
log_console_enabled = config["log_console"];
}
/*-------------------------------------------------*\
| Flush the log |
\*-------------------------------------------------*/
@ -224,7 +233,10 @@ void LogManager::_append(const char* filename, int line, unsigned int level, con
\*-------------------------------------------------*/
temp_messages.push_back(mes);
if(log_console_enabled)
{
all_messages.push_back(mes);
}
/*-------------------------------------------------*\
| Flush the queues |

View file

@ -93,6 +93,7 @@ public:
void clearMessages();
std::vector<PLogMessage> messages();
bool log_console_enabled;
static const char* log_codes[];
};

View file

@ -478,9 +478,23 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
}
/*-----------------------------------------------------*\
| Add the console page |
| If log console is enabled in settings, enable it |
\*-----------------------------------------------------*/
json log_manager_settings = settings_manager->GetSettings("LogManager");
bool log_console_enabled = false;
if(log_manager_settings.contains("log_console"))
{
log_console_enabled = log_manager_settings["log_console"];
}
/*-----------------------------------------------------*\
| Add the log console page |
\*-----------------------------------------------------*/
if(log_console_enabled)
{
AddConsolePage();
}
}