Allow setting log level when using libsyncthing
This commit is contained in:
parent
e832ccf51d
commit
287ec5542b
|
@ -1 +1 @@
|
|||
Subproject commit e4c68a80109060a64fe149a108de1a5f18728738
|
||||
Subproject commit 16566e444297261f99359ea1107471ae70c628a7
|
|
@ -29,6 +29,7 @@ SyncthingLauncher *SyncthingLauncher::s_mainInstance = nullptr;
|
|||
*/
|
||||
SyncthingLauncher::SyncthingLauncher(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_libsyncthingLogLevel(LibSyncthing::LogLevel::Info)
|
||||
, m_manuallyStopped(true)
|
||||
, m_emittingOutput(false)
|
||||
{
|
||||
|
@ -118,6 +119,7 @@ void SyncthingLauncher::launch(const Settings::Launcher &launcherSettings)
|
|||
if (launcherSettings.useLibSyncthing) {
|
||||
LibSyncthing::RuntimeOptions options;
|
||||
options.configDir = launcherSettings.libSyncthing.configDir.toStdString();
|
||||
setLibSyncthingLogLevel(launcherSettings.libSyncthing.logLevel);
|
||||
launch(options);
|
||||
} else {
|
||||
launch(launcherSettings.syncthingPath, SyncthingProcess::splitArguments(launcherSettings.syncthingArgs));
|
||||
|
@ -204,7 +206,7 @@ static const char *const logLevelStrings[] = {
|
|||
void SyncthingLauncher::handleLoggingCallback(LibSyncthing::LogLevel level, const char *message, size_t messageSize)
|
||||
{
|
||||
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
|
||||
if (level < LibSyncthing::LogLevel::Info) {
|
||||
if (level < m_libsyncthingLogLevel) {
|
||||
return;
|
||||
}
|
||||
QByteArray messageData;
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
bool isManuallyStopped() const;
|
||||
bool isEmittingOutput() const;
|
||||
void setEmittingOutput(bool emittingOutput);
|
||||
LibSyncthing::LogLevel libSyncthingLogLevel() const;
|
||||
void setLibSyncthingLogLevel(LibSyncthing::LogLevel logLevel);
|
||||
static bool isLibSyncthingAvailable();
|
||||
static SyncthingLauncher *mainInstance();
|
||||
static void setMainInstance(SyncthingLauncher *mainInstance);
|
||||
|
@ -70,6 +72,7 @@ private:
|
|||
QFuture<void> m_future;
|
||||
QByteArray m_outputBuffer;
|
||||
CppUtilities::DateTime m_futureStarted;
|
||||
LibSyncthing::LogLevel m_libsyncthingLogLevel;
|
||||
bool m_manuallyStopped;
|
||||
bool m_emittingOutput;
|
||||
bool m_useLibSyncthing;
|
||||
|
@ -114,6 +117,18 @@ inline bool SyncthingLauncher::isEmittingOutput() const
|
|||
return m_emittingOutput;
|
||||
}
|
||||
|
||||
/// \brief Returns the log level used for libsyncthing.
|
||||
inline LibSyncthing::LogLevel SyncthingLauncher::libSyncthingLogLevel() const
|
||||
{
|
||||
return m_libsyncthingLogLevel;
|
||||
}
|
||||
|
||||
/// \brief Sets the log level used for libsyncthing.
|
||||
inline void SyncthingLauncher::setLibSyncthingLogLevel(LibSyncthing::LogLevel logLevel)
|
||||
{
|
||||
m_libsyncthingLogLevel = logLevel;
|
||||
}
|
||||
|
||||
/// \brief Returns the SyncthingLauncher instance previously assigned via SyncthingLauncher::setMainInstance().
|
||||
inline SyncthingLauncher *SyncthingLauncher::mainInstance()
|
||||
{
|
||||
|
|
|
@ -71,6 +71,42 @@
|
|||
<item row="3" column="1">
|
||||
<widget class="QtUtilities::PathSelection" name="configDirPathSelection" native="true"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="logLevelLabel">
|
||||
<property name="text">
|
||||
<string>Log level</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="logLevelComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Verbose</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Info</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Warning</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Fatal</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -281,5 +317,37 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>useBuiltInVersionCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>logLevelLabel</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>227</x>
|
||||
<y>61</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>116</x>
|
||||
<y>143</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>useBuiltInVersionCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>logLevelComboBox</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>227</x>
|
||||
<y>61</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>180</x>
|
||||
<y>145</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
|
@ -274,6 +274,7 @@ void restore()
|
|||
launcher.autostartEnabled = settings.value(QStringLiteral("syncthingAutostart"), launcher.autostartEnabled).toBool();
|
||||
launcher.useLibSyncthing = settings.value(QStringLiteral("useLibSyncthing"), launcher.useLibSyncthing).toBool();
|
||||
launcher.libSyncthing.configDir = settings.value(QStringLiteral("libSyncthingConfigDir"), launcher.libSyncthing.configDir).toString();
|
||||
launcher.libSyncthing.logLevel = static_cast<LibSyncthing::LogLevel>(settings.value(QStringLiteral("libSyncthingLogLevel"), static_cast<int>(launcher.libSyncthing.logLevel)).toInt());
|
||||
launcher.syncthingPath = settings.value(QStringLiteral("syncthingPath"), launcher.syncthingPath).toString();
|
||||
launcher.syncthingArgs = settings.value(QStringLiteral("syncthingArgs"), launcher.syncthingArgs).toString();
|
||||
launcher.considerForReconnect = settings.value(QStringLiteral("considerLauncherForReconnect"), launcher.considerForReconnect).toBool();
|
||||
|
@ -372,6 +373,7 @@ void save()
|
|||
settings.setValue(QStringLiteral("syncthingAutostart"), launcher.autostartEnabled);
|
||||
settings.setValue(QStringLiteral("useLibSyncthing"), launcher.useLibSyncthing);
|
||||
settings.setValue(QStringLiteral("libSyncthingConfigDir"), launcher.libSyncthing.configDir);
|
||||
settings.setValue(QStringLiteral("libSyncthingLogLevel"), static_cast<int>(launcher.libSyncthing.logLevel));
|
||||
settings.setValue(QStringLiteral("syncthingPath"), launcher.syncthingPath);
|
||||
settings.setValue(QStringLiteral("syncthingArgs"), launcher.syncthingArgs);
|
||||
settings.setValue(QStringLiteral("considerLauncherForReconnect"), launcher.considerForReconnect);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../../connector/syncthingconnectionsettings.h"
|
||||
#include "../../model/syncthingicons.h"
|
||||
#include "../../libsyncthing/interface.h"
|
||||
#include "../global.h"
|
||||
|
||||
#include <qtutilities/settingsdialog/qtsettings.h>
|
||||
|
@ -82,6 +83,7 @@ struct SYNCTHINGWIDGETS_EXPORT Launcher {
|
|||
|
||||
struct SYNCTHINGWIDGETS_EXPORT LibSyncthing {
|
||||
QString configDir;
|
||||
::LibSyncthing::LogLevel logLevel = ::LibSyncthing::LogLevel::Info;
|
||||
} libSyncthing;
|
||||
|
||||
static Data::SyncthingProcess &toolProcess(const QString &tool);
|
||||
|
|
|
@ -908,6 +908,7 @@ QWidget *LauncherOptionPage::setupWidget()
|
|||
connect(m_launcher, &SyncthingLauncher::outputAvailable, this, &LauncherOptionPage::handleSyncthingOutputAvailable, Qt::QueuedConnection);
|
||||
connect(m_launcher, &SyncthingLauncher::exited, this, &LauncherOptionPage::handleSyncthingExited, Qt::QueuedConnection);
|
||||
connect(m_launcher, &SyncthingLauncher::errorOccurred, this, &LauncherOptionPage::handleSyncthingError, Qt::QueuedConnection);
|
||||
connect(ui()->logLevelComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &LauncherOptionPage::updateLibSyncthingLogLevel);
|
||||
m_launcher->setEmittingOutput(true);
|
||||
}
|
||||
connect(ui()->launchNowPushButton, &QPushButton::clicked, this, &LauncherOptionPage::launch);
|
||||
|
@ -923,6 +924,7 @@ bool LauncherOptionPage::apply()
|
|||
settings.autostartEnabled = ui()->enabledCheckBox->isChecked();
|
||||
settings.useLibSyncthing = ui()->useBuiltInVersionCheckBox->isChecked();
|
||||
settings.libSyncthing.configDir = ui()->configDirPathSelection->lineEdit()->text();
|
||||
settings.libSyncthing.logLevel = static_cast<LibSyncthing::LogLevel>(ui()->logLevelComboBox->currentIndex());
|
||||
settings.syncthingPath = ui()->syncthingPathSelection->lineEdit()->text();
|
||||
settings.syncthingArgs = ui()->argumentsLineEdit->text();
|
||||
settings.considerForReconnect = ui()->considerForReconnectCheckBox->isChecked();
|
||||
|
@ -944,6 +946,7 @@ void LauncherOptionPage::reset()
|
|||
ui()->useBuiltInVersionCheckBox->setChecked(settings.useLibSyncthing);
|
||||
ui()->useBuiltInVersionCheckBox->setVisible(settings.useLibSyncthing || SyncthingLauncher::isLibSyncthingAvailable());
|
||||
ui()->configDirPathSelection->lineEdit()->setText(settings.libSyncthing.configDir);
|
||||
ui()->logLevelComboBox->setCurrentIndex(static_cast<int>(settings.libSyncthing.logLevel));
|
||||
ui()->syncthingPathSelection->lineEdit()->setText(settings.syncthingPath);
|
||||
ui()->argumentsLineEdit->setText(settings.syncthingArgs);
|
||||
ui()->considerForReconnectCheckBox->setChecked(settings.considerForReconnect);
|
||||
|
@ -1070,14 +1073,19 @@ void LauncherOptionPage::launch()
|
|||
if (isRunning()) {
|
||||
return;
|
||||
}
|
||||
const auto launcherSettings(values().launcher);
|
||||
const auto &launcherSettings(values().launcher);
|
||||
if (m_tool.isEmpty()) {
|
||||
m_launcher->launch(launcherSettings);
|
||||
} else {
|
||||
const auto toolParams(launcherSettings.tools.value(m_tool));
|
||||
m_process->startSyncthing(toolParams.path, SyncthingProcess::splitArguments(toolParams.args));
|
||||
handleSyncthingLaunched(true);
|
||||
return;
|
||||
}
|
||||
const auto toolParams(launcherSettings.tools.value(m_tool));
|
||||
m_process->startSyncthing(toolParams.path, SyncthingProcess::splitArguments(toolParams.args));
|
||||
handleSyncthingLaunched(true);
|
||||
}
|
||||
|
||||
void LauncherOptionPage::updateLibSyncthingLogLevel()
|
||||
{
|
||||
m_launcher->setLibSyncthingLogLevel(static_cast<LibSyncthing::LogLevel>(ui()->logLevelComboBox->currentIndex()));
|
||||
}
|
||||
|
||||
void LauncherOptionPage::stop()
|
||||
|
|
|
@ -117,6 +117,7 @@ private slots:
|
|||
void handleSyncthingError(QProcess::ProcessError error);
|
||||
bool isRunning() const;
|
||||
void launch();
|
||||
void updateLibSyncthingLogLevel();
|
||||
void stop();
|
||||
void restoreDefaultArguments();
|
||||
|
||||
|
|
Loading…
Reference in New Issue