Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Use lcButeoPlugin logging category instea…
Browse files Browse the repository at this point in the history
…d of Buteo LOG_* macros. JB#53712

Remove custom SOCIALD_LOG_* macros.
  • Loading branch information
blammit committed Aug 18, 2021
1 parent 51c0061 commit 8ea28c3
Show file tree
Hide file tree
Showing 38 changed files with 970 additions and 952 deletions.
1 change: 0 additions & 1 deletion src/common/buteosyncfw_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <SyncProfile.h>
#include <Profile.h>
#include <PluginCbInterface.h>
#include <LogMacros.h>

#ifndef SOCIALD_TEST_DEFINE
#define PRIVILEGED_DATA_DIR QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QLatin1String("/.local/share/system/privileged")
Expand Down
9 changes: 4 additions & 5 deletions src/common/common.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ HEADERS += \
$$PWD/buteosyncfw_p.h \
$$PWD/socialdbuteoplugin.h \
$$PWD/socialnetworksyncadaptor.h \
$$PWD/socialdnetworkaccessmanager_p.h \
$$PWD/trace.h

SOURCES += \
$$PWD/socialdbuteoplugin.cpp \
$$PWD/socialnetworksyncadaptor.cpp

HEADERS += $$PWD/socialdnetworkaccessmanager_p.h

SOURCES += socialdnetworkaccessmanager_p.cpp
$$PWD/socialnetworksyncadaptor.cpp \
$$PWD/socialdnetworkaccessmanager_p.cpp \
$$PWD/trace.cpp

TARGETPATH = $$[QT_INSTALL_LIBS]
target.path = $$TARGETPATH
Expand Down
22 changes: 11 additions & 11 deletions src/common/socialdbuteoplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,26 @@ bool SocialdButeoPlugin::startSync()
// purging any synced data associated with those accounts).
if (m_socialNetworkSyncAdaptor && m_socialNetworkSyncAdaptor->enabled()) {
if (m_socialNetworkSyncAdaptor->status() == SocialNetworkSyncAdaptor::Inactive) {
SOCIALD_LOG_DEBUG("performing sync of" << m_dataTypeName <<
qCDebug(lcSocialPlugin) << "performing sync of" << m_dataTypeName <<
"from" << m_socialServiceName <<
"for account" << m_profileAccountId);
"for account" << m_profileAccountId;
m_socialNetworkSyncAdaptor->sync(m_dataTypeName, m_profileAccountId);
return true;
} else {
SOCIALD_LOG_DEBUG(m_socialServiceName << "sync adaptor for" <<
qCDebug(lcSocialPlugin) << m_socialServiceName << "sync adaptor for" <<
m_dataTypeName << "is still busy with last sync of account" <<
m_profileAccountId);
m_profileAccountId;
}
} else {
SOCIALD_LOG_DEBUG("no enabled" << m_socialServiceName << "sync adaptor for" << m_dataTypeName);
qCDebug(lcSocialPlugin) << "no enabled" << m_socialServiceName << "sync adaptor for" << m_dataTypeName;
}
return false;
}

void SocialdButeoPlugin::abortSync(Sync::SyncStatus status)
{
// note: it seems buteo automatically calls abortSync on network connectivity loss...
SOCIALD_LOG_INFO("aborting sync with status:" << status);
qCInfo(lcSocialPlugin) << "aborting sync with status:" << status;
m_socialNetworkSyncAdaptor->abortSync(status);
}

Expand Down Expand Up @@ -219,7 +219,7 @@ void SocialdButeoPlugin::connectivityStateChanged(Sync::ConnectivityType type, b
{
// See TransportTracker.cpp:149 for example
// Sync::CONNECTIVITY_INTERNET, true|false
SOCIALD_LOG_INFO("notified of connectivity change:" << type << state);
qCInfo(lcSocialPlugin) << "notified of connectivity change:" << type << state;
if (type == Sync::CONNECTIVITY_INTERNET && state == false) {
// we lost connectivity during sync.
abortSync(Sync::SYNC_CONNECTION_ERROR);
Expand Down Expand Up @@ -297,15 +297,15 @@ QList<Buteo::SyncProfile*> SocialdButeoPlugin::ensurePerAccountSyncProfilesExist

if (!foundProfile) {
// it should have been generated for the account when the account was added.
SOCIALD_LOG_INFO("no per-account" << profile().name() <<
"sync profile exists for account:" << currAccount->id());
qCInfo(lcSocialPlugin) << "no per-account" << profile().name() <<
"sync profile exists for account:" << currAccount->id();

// create the per-account profile... we shouldn't need to do this...
QString profileName = createProfile(&m_profileManager, profile().name(), currAccount, dataTypeSyncService, true, QVariantMap());
Buteo::SyncProfile *newProfile = m_profileManager.syncProfile(profileName);
if (!newProfile) {
SOCIALD_LOG_ERROR("unable to create per-account" << profile().name() <<
"sync profile for account:" << currAccount->id());
qCWarning(lcSocialPlugin) << "unable to create per-account" << profile().name() <<
"sync profile for account:" << currAccount->id();
} else {
// enable the sync schedule for the profile.
Buteo::SyncSchedule schedule = newProfile->syncSchedule();
Expand Down
26 changes: 13 additions & 13 deletions src/common/socialnetworksyncadaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ void SocialNetworkSyncAdaptor::sync(const QString &dataType, int accountId)
{
Q_UNUSED(dataType)
Q_UNUSED(accountId)
SOCIALD_LOG_ERROR("sync() must be overridden by derived types");
qCWarning(lcSocialPlugin) << "sync() must be overridden by derived types";
}

void SocialNetworkSyncAdaptor::abortSync(Sync::SyncStatus status)
{
SOCIALD_LOG_INFO("forcing timeout of outstanding replies due to abort:" << status);
qCInfo(lcSocialPlugin) << "forcing timeout of outstanding replies due to abort:" << status;
m_syncAborted = true;
triggerReplyTimeouts();
}
Expand All @@ -141,9 +141,9 @@ bool SocialNetworkSyncAdaptor::checkAccount(Accounts::Account *account)
bool globallyEnabled = account->enabled();
Accounts::Service srv(m_accountManager->service(syncServiceName()));
if (!srv.isValid()) {
SOCIALD_LOG_INFO("invalid service" << syncServiceName() <<
qCInfo(lcSocialPlugin) << "invalid service" << syncServiceName() <<
"specified, account" << account->id() <<
"will be disabled for" << m_serviceName << dataTypeName(m_dataType) << "sync");
"will be disabled for" << m_serviceName << dataTypeName(m_dataType) << "sync";
return false;
}
account->selectService(srv);
Expand Down Expand Up @@ -265,8 +265,8 @@ void SocialNetworkSyncAdaptor::setInitialActive(bool enabled)
void SocialNetworkSyncAdaptor::setFinishedInactive()
{
finalCleanup();
SOCIALD_LOG_INFO("Finished" << m_serviceName << SocialNetworkSyncAdaptor::dataTypeName(m_dataType) <<
"sync at:" << QDateTime::currentDateTime().toString(Qt::ISODate));
qCInfo(lcSocialPlugin) << "Finished" << m_serviceName << SocialNetworkSyncAdaptor::dataTypeName(m_dataType) <<
"sync at:" << QDateTime::currentDateTime().toString(Qt::ISODate);
setStatus(SocialNetworkSyncAdaptor::Inactive);
}

Expand All @@ -275,21 +275,21 @@ void SocialNetworkSyncAdaptor::incrementSemaphore(int accountId)
int semaphoreValue = m_accountSyncSemaphores.value(accountId);
semaphoreValue += 1;
m_accountSyncSemaphores.insert(accountId, semaphoreValue);
SOCIALD_LOG_DEBUG("incremented busy semaphore for account" << accountId << "to:" << semaphoreValue);
qCDebug(lcSocialPlugin) << "incremented busy semaphore for account" << accountId << "to:" << semaphoreValue;
}

void SocialNetworkSyncAdaptor::decrementSemaphore(int accountId)
{
if (!m_accountSyncSemaphores.contains(accountId)) {
SOCIALD_LOG_ERROR("no such semaphore for account" << accountId);
qCWarning(lcSocialPlugin) << "no such semaphore for account" << accountId;
return;
}

int semaphoreValue = m_accountSyncSemaphores.value(accountId);
semaphoreValue -= 1;
SOCIALD_LOG_DEBUG("decremented busy semaphore for account" << accountId << "to:" << semaphoreValue);
qCDebug(lcSocialPlugin) << "decremented busy semaphore for account" << accountId << "to:" << semaphoreValue;
if (semaphoreValue < 0) {
SOCIALD_LOG_ERROR("busy semaphore is negative for account" << accountId);
qCWarning(lcSocialPlugin) << "busy semaphore is negative for account" << accountId;
return;
}
m_accountSyncSemaphores.insert(accountId, semaphoreValue);
Expand Down Expand Up @@ -333,7 +333,7 @@ void SocialNetworkSyncAdaptor::timeoutReply()
QNetworkReply *reply = timer->property("networkReply").value<QNetworkReply*>();
int accountId = timer->property("accountId").toInt();

SOCIALD_LOG_ERROR("network request timed out while performing sync with account" << accountId);
qCWarning(lcSocialPlugin) << "network request timed out while performing sync with account" << accountId;

m_networkReplyTimeouts[accountId].remove(reply);
reply->setProperty("isError", QVariant::fromValue<bool>(true));
Expand Down Expand Up @@ -444,7 +444,7 @@ void SocialNetworkSyncAdaptor::purgeCachedImages(SocialImagesDatabase *database,

QList<SocialImage::ConstPtr> images = database->images();
foreach (SocialImage::ConstPtr image, images) {
SOCIALD_LOG_DEBUG("Purge cached image " << image->imageFile() << " for account " << image->accountId());
qCDebug(lcSocialPlugin) << "Purge cached image " << image->imageFile() << " for account " << image->accountId();
QFile::remove(image->imageFile());
}

Expand All @@ -461,7 +461,7 @@ void SocialNetworkSyncAdaptor::purgeExpiredImages(SocialImagesDatabase *database

QList<SocialImage::ConstPtr> images = database->images();
foreach (SocialImage::ConstPtr image, images) {
SOCIALD_LOG_DEBUG("Purge expired image " << image->imageFile() << " for account " << image->accountId());
qCDebug(lcSocialPlugin) << "Purge expired image " << image->imageFile() << " for account " << image->accountId();
QFile::remove(image->imageFile());
}

Expand Down
25 changes: 25 additions & 0 deletions src/common/trace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/****************************************************************************
**
** Copyright (C) 2021 Jolla Ltd.
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/

#include "trace.h"

Q_LOGGING_CATEGORY(lcSocialPlugin, "buteo.plugin.social", QtWarningMsg)
Q_LOGGING_CATEGORY(lcSocialPluginTrace, "buteo.plugin.social.trace", QtWarningMsg)

8 changes: 3 additions & 5 deletions src/common/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
#ifndef TRACE_H
#define TRACE_H

#include "buteosyncfw_p.h"
#include <QLoggingCategory>

#define SOCIALD_LOG_TRACE(message) LOG_TRACE("trace: " << message) /* MSYNCD_LOGGING_LEVEL >= 8 */
#define SOCIALD_LOG_DEBUG(message) LOG_DEBUG("debug: " << message) /* MSYNCD_LOGGING_LEVEL >= 7 */
#define SOCIALD_LOG_INFO(message) LOG_INFO("info : " << message) /* MSYNCD_LOGGING_LEVEL >= 6 */
#define SOCIALD_LOG_ERROR(message) LOG_WARNING("ERROR: " << message) /* MSYNCD_LOGGING_LEVEL == * */
Q_DECLARE_LOGGING_CATEGORY(lcSocialPlugin)
Q_DECLARE_LOGGING_CATEGORY(lcSocialPluginTrace)

#endif // TRACE_H

0 comments on commit 8ea28c3

Please sign in to comment.