logic: Enable/Disable Logging in Preferences
* disabled by default
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#include "Application.h"
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/ConsoleLogger.h"
|
||||
#include "utility/logging/FileLogger.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
@@ -75,6 +78,23 @@ void Application::loadSettings()
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
settings->load(FilePath(UserPaths::getAppSettingsPath()));
|
||||
|
||||
LogManager* logManager = LogManager::getInstance().get();
|
||||
if (settings->getLoggingEnabled() && !logManager->getLoggerCount())
|
||||
{
|
||||
std::shared_ptr<ConsoleLogger> consoleLogger = std::make_shared<ConsoleLogger>();
|
||||
// consoleLogger->setLogLevel(Logger::LOG_WARNINGS | Logger::LOG_ERRORS);
|
||||
logManager->addLogger(consoleLogger);
|
||||
|
||||
FileLogger::setFilePath(UserPaths::getLogPath());
|
||||
std::shared_ptr<FileLogger> fileLogger = std::make_shared<FileLogger>();
|
||||
fileLogger->setLogLevel(Logger::LOG_ALL);
|
||||
logManager->addLogger(fileLogger);
|
||||
}
|
||||
else
|
||||
{
|
||||
logManager->clearLoggers();
|
||||
}
|
||||
|
||||
loadStyle(settings->getColorSchemePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -155,6 +155,16 @@ void ApplicationSettings::setScrollSpeed(float scrollSpeed)
|
||||
setValue<float>("application/scroll_speed", scrollSpeed);
|
||||
}
|
||||
|
||||
bool ApplicationSettings::getLoggingEnabled() const
|
||||
{
|
||||
return getValue<float>("application/logging_enabled", false);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setLoggingEnabled(bool loggingEnabled)
|
||||
{
|
||||
setValue<bool>("application/logging_enabled", loggingEnabled);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getIndexerThreadCount() const
|
||||
{
|
||||
return getValue<int>("indexing/indexer_thread_count", 4);
|
||||
@@ -167,12 +177,12 @@ void ApplicationSettings::setIndexerThreadCount(const int count)
|
||||
|
||||
bool ApplicationSettings::getShowExternalNonFatalErrors() const
|
||||
{
|
||||
return getValue<bool>("application/show_external_non_fatal_errors", false);
|
||||
return getValue<bool>("indexing/show_external_non_fatal_errors", false);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setShowExternalNonFatalErrors(const bool show)
|
||||
{
|
||||
setValue<bool>("application/show_external_non_fatal_errors", show);
|
||||
setValue<bool>("indexing/show_external_non_fatal_errors", show);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getJavaPath() const
|
||||
|
||||
@@ -47,6 +47,9 @@ public:
|
||||
float getScrollSpeed() const;
|
||||
void setScrollSpeed(float scrollSpeed);
|
||||
|
||||
bool getLoggingEnabled() const;
|
||||
void setLoggingEnabled(bool loggingEnabled);
|
||||
|
||||
// indexing
|
||||
int getIndexerThreadCount() const;
|
||||
void setIndexerThreadCount(const int count);
|
||||
|
||||
@@ -39,6 +39,11 @@ void LogManager::removeLoggersByType(const std::string& type)
|
||||
m_logManagerImplementation.removeLoggersByType(type);
|
||||
}
|
||||
|
||||
void LogManager::clearLoggers()
|
||||
{
|
||||
m_logManagerImplementation.clearLoggers();
|
||||
}
|
||||
|
||||
int LogManager::getLoggerCount() const
|
||||
{
|
||||
return m_logManagerImplementation.getLoggerCount();
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
void addLogger(std::shared_ptr<Logger> logger);
|
||||
void removeLogger(std::shared_ptr<Logger> logger);
|
||||
void removeLoggersByType(const std::string& type);
|
||||
void clearLoggers();
|
||||
int getLoggerCount() const;
|
||||
|
||||
void logInfo(
|
||||
|
||||
@@ -49,6 +49,11 @@ void LogManagerImplementation::removeLoggersByType(const std::string& type)
|
||||
}
|
||||
}
|
||||
|
||||
void LogManagerImplementation::clearLoggers()
|
||||
{
|
||||
m_loggers.clear();
|
||||
}
|
||||
|
||||
int LogManagerImplementation::getLoggerCount() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuard(m_loggerMutex);
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
void addLogger(std::shared_ptr<Logger> logger);
|
||||
void removeLogger(std::shared_ptr<Logger> logger);
|
||||
void removeLoggersByType(const std::string& type);
|
||||
void clearLoggers();
|
||||
int getLoggerCount() const;
|
||||
|
||||
void logInfo(
|
||||
|
||||
Reference in New Issue
Block a user