Refactoring/service logging functional (#793)

This commit is contained in:
Garegin Harutyunyan 2024-08-08 19:13:49 +04:00 committed by GitHub
parent 1343d10aa7
commit 264d77463d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 38 additions and 5 deletions

View file

@ -99,6 +99,29 @@ void Logger::deInit()
m_file.close();
}
bool Logger::setServiceLogsEnabled(bool enabled) {
#ifdef AMNEZIA_DESKTOP
IpcClient *m_IpcClient = new IpcClient;
if (!m_IpcClient->isSocketConnected()) {
if (!IpcClient::init(m_IpcClient)) {
qWarning() << "Error occurred when init IPC client";
return false;
}
}
if (m_IpcClient->Interface()) {
m_IpcClient->Interface()->setLogsEnabled(enabled);
}
else {
qWarning() << "Error occurred setting up service logs";
return false;
}
#endif
return true;
}
QString Logger::userLogsDir()
{
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/log";
@ -141,7 +164,9 @@ bool Logger::openLogsFolder()
bool Logger::openServiceLogsFolder()
{
QString path = Utils::systemLogPath();
#ifdef Q_OS_WIN
path = "file:///" + path;
#endif
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
return true;
}
@ -184,8 +209,7 @@ void Logger::clearServiceLogs()
}
if (m_IpcClient->Interface()) {
m_IpcClient->Interface()->setLogsEnabled(false);
m_IpcClient->Interface()->cleanUp();
m_IpcClient->Interface()->clearLogs();
}
else {
qWarning() << "Error occurred cleaning up service logs";