logic: Enable/Disable Logging in Preferences
* disabled by default
This commit is contained in:
@@ -18,17 +18,19 @@
|
|||||||
<font_size_min><!-- INTEGER: minimum font size in pt --></font_size_min>
|
<font_size_min><!-- INTEGER: minimum font size in pt --></font_size_min>
|
||||||
<font_size_std><!-- INTEGER: standard font size in pt --></font_size_std>
|
<font_size_std><!-- INTEGER: standard font size in pt --></font_size_std>
|
||||||
|
|
||||||
<show_external_non_fatal_errors><!-- BOOL: show non-fatal errors in unindexed files --></show_external_non_fatal_errors>
|
|
||||||
|
|
||||||
<window_base_width><!-- INTEGER: initial width of an overlay window --></window_base_width>
|
<window_base_width><!-- INTEGER: initial width of an overlay window --></window_base_width>
|
||||||
<window_base_height><!-- INTEGER: initial height of an overlay window --></window_base_height>
|
<window_base_height><!-- INTEGER: initial height of an overlay window --></window_base_height>
|
||||||
|
|
||||||
<scroll_speed><!-- DECIMAL: multiplier for default scroll speed in views --></scroll_speed>
|
<scroll_speed><!-- DECIMAL: multiplier for default scroll speed in views --></scroll_speed>
|
||||||
|
|
||||||
|
<logging_enabled><!-- BOOL: define if console and file logging is enabled --></logging_enabled>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<indexing>
|
<indexing>
|
||||||
<indexer_thread_count><!-- INTEGER: number of threads indexing the source code --></indexer_thread_count>
|
<indexer_thread_count><!-- INTEGER: number of threads indexing the source code --></indexer_thread_count>
|
||||||
|
|
||||||
|
<show_external_non_fatal_errors><!-- BOOL: show non-fatal errors in unindexed files --></show_external_non_fatal_errors>
|
||||||
|
|
||||||
<cxx>
|
<cxx>
|
||||||
<compiler_flags>
|
<compiler_flags>
|
||||||
<compiler_flag><!-- STRING: compiler flag, including the dash e.g. -v --></compiler_flag>
|
<compiler_flag><!-- STRING: compiler flag, including the dash e.g. -v --></compiler_flag>
|
||||||
|
|||||||
+3
-19
@@ -1,8 +1,5 @@
|
|||||||
#include "utility/AppPath.h"
|
#include "utility/AppPath.h"
|
||||||
#include "utility/commandline/CommandLineParser.h"
|
#include "utility/commandline/CommandLineParser.h"
|
||||||
#include "utility/logging/ConsoleLogger.h"
|
|
||||||
#include "utility/logging/FileLogger.h"
|
|
||||||
#include "utility/logging/LogManager.h"
|
|
||||||
#include "utility/ResourcePaths.h"
|
#include "utility/ResourcePaths.h"
|
||||||
#include "utility/ScopedFunctor.h"
|
#include "utility/ScopedFunctor.h"
|
||||||
#include "utility/UserPaths.h"
|
#include "utility/UserPaths.h"
|
||||||
@@ -19,18 +16,6 @@
|
|||||||
#include "qt/window/QtMainWindow.h"
|
#include "qt/window/QtMainWindow.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
void init()
|
|
||||||
{
|
|
||||||
std::shared_ptr<ConsoleLogger> consoleLogger = std::make_shared<ConsoleLogger>();
|
|
||||||
consoleLogger->setLogLevel(Logger::LOG_WARNINGS | Logger::LOG_ERRORS);
|
|
||||||
LogManager::getInstance()->addLogger(consoleLogger);
|
|
||||||
|
|
||||||
std::shared_ptr<FileLogger> fileLogger = std::make_shared<FileLogger>();
|
|
||||||
fileLogger->setLogLevel(Logger::LOG_ALL);
|
|
||||||
FileLogger::setFilePath(UserPaths::getLogPath());
|
|
||||||
LogManager::getInstance()->addLogger(fileLogger);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication::setApplicationName("Coati");
|
QApplication::setApplicationName("Coati");
|
||||||
@@ -57,7 +42,6 @@ int main(int argc, char *argv[])
|
|||||||
QtCoreApplication qtApp(argc, argv);
|
QtCoreApplication qtApp(argc, argv);
|
||||||
|
|
||||||
setupApp(argc, argv);
|
setupApp(argc, argv);
|
||||||
init();
|
|
||||||
|
|
||||||
Application::createInstance(version, nullptr, nullptr);
|
Application::createInstance(version, nullptr, nullptr);
|
||||||
ScopedFunctor f([](){
|
ScopedFunctor f([](){
|
||||||
@@ -88,15 +72,12 @@ int main(int argc, char *argv[])
|
|||||||
QtApplication qtApp(argc, argv);
|
QtApplication qtApp(argc, argv);
|
||||||
|
|
||||||
setupApp(argc, argv);
|
setupApp(argc, argv);
|
||||||
init();
|
|
||||||
|
|
||||||
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
|
||||||
QtViewFactory viewFactory;
|
QtViewFactory viewFactory;
|
||||||
QtNetworkFactory networkFactory;
|
QtNetworkFactory networkFactory;
|
||||||
|
|
||||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
|
||||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".ttf");
|
|
||||||
Application::createInstance(version, &viewFactory, &networkFactory);
|
Application::createInstance(version, &viewFactory, &networkFactory);
|
||||||
ScopedFunctor f([](){
|
ScopedFunctor f([](){
|
||||||
Application::destroyInstance();
|
Application::destroyInstance();
|
||||||
@@ -104,6 +85,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
commandLineParser.projectLoad();
|
commandLineParser.projectLoad();
|
||||||
|
|
||||||
|
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||||
|
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".ttf");
|
||||||
|
|
||||||
return qtApp.exec();
|
return qtApp.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
#include "utility/file/FileSystem.h"
|
#include "utility/file/FileSystem.h"
|
||||||
|
#include "utility/logging/ConsoleLogger.h"
|
||||||
|
#include "utility/logging/FileLogger.h"
|
||||||
#include "utility/logging/logging.h"
|
#include "utility/logging/logging.h"
|
||||||
|
#include "utility/logging/LogManager.h"
|
||||||
#include "utility/messaging/MessageQueue.h"
|
#include "utility/messaging/MessageQueue.h"
|
||||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||||
@@ -75,6 +78,23 @@ void Application::loadSettings()
|
|||||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||||
settings->load(FilePath(UserPaths::getAppSettingsPath()));
|
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());
|
loadStyle(settings->getColorSchemePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,16 @@ void ApplicationSettings::setScrollSpeed(float scrollSpeed)
|
|||||||
setValue<float>("application/scroll_speed", 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
|
int ApplicationSettings::getIndexerThreadCount() const
|
||||||
{
|
{
|
||||||
return getValue<int>("indexing/indexer_thread_count", 4);
|
return getValue<int>("indexing/indexer_thread_count", 4);
|
||||||
@@ -167,12 +177,12 @@ void ApplicationSettings::setIndexerThreadCount(const int count)
|
|||||||
|
|
||||||
bool ApplicationSettings::getShowExternalNonFatalErrors() const
|
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)
|
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
|
std::string ApplicationSettings::getJavaPath() const
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ public:
|
|||||||
float getScrollSpeed() const;
|
float getScrollSpeed() const;
|
||||||
void setScrollSpeed(float scrollSpeed);
|
void setScrollSpeed(float scrollSpeed);
|
||||||
|
|
||||||
|
bool getLoggingEnabled() const;
|
||||||
|
void setLoggingEnabled(bool loggingEnabled);
|
||||||
|
|
||||||
// indexing
|
// indexing
|
||||||
int getIndexerThreadCount() const;
|
int getIndexerThreadCount() const;
|
||||||
void setIndexerThreadCount(const int count);
|
void setIndexerThreadCount(const int count);
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ void LogManager::removeLoggersByType(const std::string& type)
|
|||||||
m_logManagerImplementation.removeLoggersByType(type);
|
m_logManagerImplementation.removeLoggersByType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogManager::clearLoggers()
|
||||||
|
{
|
||||||
|
m_logManagerImplementation.clearLoggers();
|
||||||
|
}
|
||||||
|
|
||||||
int LogManager::getLoggerCount() const
|
int LogManager::getLoggerCount() const
|
||||||
{
|
{
|
||||||
return m_logManagerImplementation.getLoggerCount();
|
return m_logManagerImplementation.getLoggerCount();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public:
|
|||||||
void addLogger(std::shared_ptr<Logger> logger);
|
void addLogger(std::shared_ptr<Logger> logger);
|
||||||
void removeLogger(std::shared_ptr<Logger> logger);
|
void removeLogger(std::shared_ptr<Logger> logger);
|
||||||
void removeLoggersByType(const std::string& type);
|
void removeLoggersByType(const std::string& type);
|
||||||
|
void clearLoggers();
|
||||||
int getLoggerCount() const;
|
int getLoggerCount() const;
|
||||||
|
|
||||||
void logInfo(
|
void logInfo(
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ void LogManagerImplementation::removeLoggersByType(const std::string& type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogManagerImplementation::clearLoggers()
|
||||||
|
{
|
||||||
|
m_loggers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
int LogManagerImplementation::getLoggerCount() const
|
int LogManagerImplementation::getLoggerCount() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lockGuard(m_loggerMutex);
|
std::lock_guard<std::mutex> lockGuard(m_loggerMutex);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
void addLogger(std::shared_ptr<Logger> logger);
|
void addLogger(std::shared_ptr<Logger> logger);
|
||||||
void removeLogger(std::shared_ptr<Logger> logger);
|
void removeLogger(std::shared_ptr<Logger> logger);
|
||||||
void removeLoggersByType(const std::string& type);
|
void removeLoggersByType(const std::string& type);
|
||||||
|
void clearLoggers();
|
||||||
int getLoggerCount() const;
|
int getLoggerCount() const;
|
||||||
|
|
||||||
void logInfo(
|
void logInfo(
|
||||||
|
|||||||
@@ -99,6 +99,19 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
|
|||||||
);
|
);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
// logging
|
||||||
|
m_loggingEnabled = new QCheckBox("Enable console and file logging", this);
|
||||||
|
|
||||||
|
layout->addWidget(createFormLabel("Logging"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||||
|
layout->addWidget(m_loggingEnabled, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
|
||||||
|
|
||||||
|
addHelpButton(
|
||||||
|
"Save log files and show log information in the console."
|
||||||
|
, layout, row
|
||||||
|
);
|
||||||
|
|
||||||
|
row++;
|
||||||
|
|
||||||
layout->setRowMinimumHeight(row++, 20);
|
layout->setRowMinimumHeight(row++, 20);
|
||||||
|
|
||||||
// indexing
|
// indexing
|
||||||
@@ -191,6 +204,7 @@ void QtProjectWizzardContentPreferences::load()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
|
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
|
||||||
|
m_loggingEnabled->setChecked(appSettings->getLoggingEnabled());
|
||||||
|
|
||||||
m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1);
|
m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1);
|
||||||
m_fatalErrors->setChecked(appSettings->getShowExternalNonFatalErrors());
|
m_fatalErrors->setChecked(appSettings->getShowExternalNonFatalErrors());
|
||||||
@@ -219,6 +233,8 @@ void QtProjectWizzardContentPreferences::save()
|
|||||||
appSettings->setScrollSpeed(scrollSpeed);
|
appSettings->setScrollSpeed(scrollSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appSettings->setLoggingEnabled(m_loggingEnabled->isChecked());
|
||||||
|
|
||||||
appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1);
|
appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1);
|
||||||
appSettings->setShowExternalNonFatalErrors(m_fatalErrors->isChecked());
|
appSettings->setShowExternalNonFatalErrors(m_fatalErrors->isChecked());
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,12 @@ private:
|
|||||||
QComboBox* m_tabWidth;
|
QComboBox* m_tabWidth;
|
||||||
|
|
||||||
QComboBox* m_colorSchemes;
|
QComboBox* m_colorSchemes;
|
||||||
QLineEdit* m_scrollSpeed;
|
|
||||||
std::vector<FilePath> m_colorSchemePaths;
|
std::vector<FilePath> m_colorSchemePaths;
|
||||||
int m_oldColorSchemeIndex;
|
int m_oldColorSchemeIndex;
|
||||||
|
|
||||||
|
QLineEdit* m_scrollSpeed;
|
||||||
|
QCheckBox* m_loggingEnabled;
|
||||||
|
|
||||||
QComboBox* m_threads;
|
QComboBox* m_threads;
|
||||||
QCheckBox* m_fatalErrors;
|
QCheckBox* m_fatalErrors;
|
||||||
|
|
||||||
|
|||||||
+3
-19
@@ -1,7 +1,4 @@
|
|||||||
#include "utility/AppPath.h"
|
#include "utility/AppPath.h"
|
||||||
#include "utility/logging/ConsoleLogger.h"
|
|
||||||
#include "utility/logging/FileLogger.h"
|
|
||||||
#include "utility/logging/LogManager.h"
|
|
||||||
#include "utility/ResourcePaths.h"
|
#include "utility/ResourcePaths.h"
|
||||||
#include "utility/ScopedFunctor.h"
|
#include "utility/ScopedFunctor.h"
|
||||||
#include "utility/UserPaths.h"
|
#include "utility/UserPaths.h"
|
||||||
@@ -16,18 +13,6 @@
|
|||||||
#include "qt/window/QtMainWindow.h"
|
#include "qt/window/QtMainWindow.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
void init()
|
|
||||||
{
|
|
||||||
std::shared_ptr<ConsoleLogger> consoleLogger = std::make_shared<ConsoleLogger>();
|
|
||||||
consoleLogger->setLogLevel(Logger::LOG_WARNINGS | Logger::LOG_ERRORS);
|
|
||||||
LogManager::getInstance()->addLogger(consoleLogger);
|
|
||||||
|
|
||||||
std::shared_ptr<FileLogger> fileLogger = std::make_shared<FileLogger>();
|
|
||||||
fileLogger->setLogLevel(Logger::LOG_ALL);
|
|
||||||
FileLogger::setFilePath(UserPaths::getLogPath());
|
|
||||||
LogManager::getInstance()->addLogger(fileLogger);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication::setApplicationName("Coati Trial");
|
QApplication::setApplicationName("Coati Trial");
|
||||||
@@ -45,20 +30,19 @@ int main(int argc, char *argv[])
|
|||||||
QtApplication qtApp(argc, argv);
|
QtApplication qtApp(argc, argv);
|
||||||
|
|
||||||
setupApp(argc, argv);
|
setupApp(argc, argv);
|
||||||
init();
|
|
||||||
|
|
||||||
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
|
||||||
QtViewFactory viewFactory;
|
QtViewFactory viewFactory;
|
||||||
QtNetworkFactory networkFactory;
|
QtNetworkFactory networkFactory;
|
||||||
|
|
||||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
|
||||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".ttf");
|
|
||||||
|
|
||||||
Application::createInstance(version, &viewFactory, &networkFactory);
|
Application::createInstance(version, &viewFactory, &networkFactory);
|
||||||
ScopedFunctor f([](){
|
ScopedFunctor f([](){
|
||||||
Application::destroyInstance();
|
Application::destroyInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||||
|
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".ttf");
|
||||||
|
|
||||||
return qtApp.exec();
|
return qtApp.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user