diff options
| author | shuffle2 <godisgovernment@gmail.com> | 2017-06-27 11:40:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-27 11:40:26 -0700 |
| commit | 2579a7c03d68ea04ae02b2b3f122a05a53bee50a (patch) | |
| tree | b8a5d03eba3aa2f45b9e091e33c03ea6229b2d03 /Source/Core/Common/Logging | |
| parent | ce4d514542a0106e193c199ac5dbabfa2c849b8e (diff) | |
| parent | dd8dcdf880d81a599f478bb868a8e8a85d28e7fd (diff) | |
Merge pull request #5607 from leoetlino/logging-fix
Logging fixes
Diffstat (limited to 'Source/Core/Common/Logging')
| -rw-r--r-- | Source/Core/Common/Logging/LogManager.cpp | 18 | ||||
| -rw-r--r-- | Source/Core/Common/Logging/LogManager.h | 2 |
2 files changed, 18 insertions, 2 deletions
diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index 2c09bc5051..2aef9318e7 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -100,18 +100,33 @@ LogManager::LogManager() IniFile::Section* options = ini.GetOrCreateSection("Options"); bool write_file; bool write_console; + bool write_window; options->Get("WriteToFile", &write_file, false); options->Get("WriteToConsole", &write_console, true); + options->Get("WriteToWindow", &write_window, true); + + // Set up log listeners + int verbosity; + options->Get("Verbosity", &verbosity, 0); + + // Ensure the verbosity level is valid + if (verbosity < 1) + verbosity = 1; + if (verbosity > MAX_LOGLEVEL) + verbosity = MAX_LOGLEVEL; for (LogContainer* container : m_Log) { bool enable; logs->Get(container->GetShortName(), &enable, false); container->SetEnable(enable); + container->SetLevel(static_cast<LogTypes::LOG_LEVELS>(verbosity)); if (enable && write_file) container->AddListener(LogListener::FILE_LISTENER); if (enable && write_console) container->AddListener(LogListener::CONSOLE_LISTENER); + if (enable && write_window) + container->AddListener(LogListener::LOG_WINDOW_LISTENER); } m_path_cutoff_point = DeterminePathCutOffPoint(); @@ -149,7 +164,8 @@ void LogManager::LogWithFullPath(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE LogTypes::LOG_LEVEL_TO_CHAR[(int)level], log->GetShortName().c_str(), temp); for (auto listener_id : *log) - m_listeners[listener_id]->Log(level, msg.c_str()); + if (m_listeners[listener_id]) + m_listeners[listener_id]->Log(level, msg.c_str()); } void LogManager::Init() diff --git a/Source/Core/Common/Logging/LogManager.h b/Source/Core/Common/Logging/LogManager.h index 0ec3c1f7de..6562a17058 100644 --- a/Source/Core/Common/Logging/LogManager.h +++ b/Source/Core/Common/Logging/LogManager.h @@ -86,7 +86,7 @@ class LogManager : NonCopyable private: LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS]; static LogManager* m_logManager; // Singleton. Ugh. - std::array<LogListener*, LogListener::NUMBER_OF_LISTENERS> m_listeners; + std::array<LogListener*, LogListener::NUMBER_OF_LISTENERS> m_listeners{}; size_t m_path_cutoff_point = 0; LogManager(); |
