Skip to content

Commit 4ad190a

Browse files
committedMay 11, 2017
Use Qt logging categories for logging
This gives more insight about the logs and allow setting fine-tuned logging rules. The categories are set to only output Info by default so this allows us to provide more concise logging while keeping the ability to extract more information for a specific category when developping or debugging customer issues. Issue #5647
1 parent 3a19365 commit 4ad190a

File tree

106 files changed

+841
-785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+841
-785
lines changed
 

‎cmake/modules/Warnings.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# For details see the accompanying COPYING* file.
44

55
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
6-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-long-long")
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-long-long -Wno-gnu-zero-variadic-macro-arguments")
77
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
88

99
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")

‎src/gui/accountmanager.cpp

+15-13
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static const char serverVersionC[] = "serverVersion";
3737

3838
namespace OCC {
3939

40+
Q_LOGGING_CATEGORY(lcAccountManager, "gui.account.manager", QtInfoMsg)
41+
4042
AccountManager *AccountManager::instance()
4143
{
4244
static AccountManager instance;
@@ -47,7 +49,7 @@ bool AccountManager::restore()
4749
{
4850
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
4951
if (settings->status() != QSettings::NoError) {
50-
qDebug() << "Could not read settings from" << settings->fileName()
52+
qCDebug(lcAccountManager) << "Could not read settings from" << settings->fileName()
5153
<< settings->status();
5254
return false;
5355
}
@@ -75,7 +77,7 @@ bool AccountManager::restore()
7577

7678
bool AccountManager::restoreFromLegacySettings()
7779
{
78-
qDebug() << "Migrate: restoreFromLegacySettings, checking settings group"
80+
qCDebug(lcAccountManager) << "Migrate: restoreFromLegacySettings, checking settings group"
7981
<< Theme::instance()->appName();
8082

8183
// try to open the correctly themed settings
@@ -91,7 +93,7 @@ bool AccountManager::restoreFromLegacySettings()
9193
oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/'));
9294
oCCfgFile += QLatin1String("/ownCloud/owncloud.cfg");
9395

94-
qDebug() << "Migrate: checking old config " << oCCfgFile;
96+
qCDebug(lcAccountManager) << "Migrate: checking old config " << oCCfgFile;
9597

9698
QFileInfo fi( oCCfgFile );
9799
if( fi.isReadable() ) {
@@ -107,7 +109,7 @@ bool AccountManager::restoreFromLegacySettings()
107109

108110
// in case the urls are equal reset the settings object to read from
109111
// the ownCloud settings object
110-
qDebug() << "Migrate oC config if " << oCUrl << " == " << overrideUrl << ":"
112+
qCDebug(lcAccountManager) << "Migrate oC config if " << oCUrl << " == " << overrideUrl << ":"
111113
<< (oCUrl == overrideUrl ? "Yes" : "No");
112114
if( oCUrl == overrideUrl ) {
113115
settings = std::move(oCSettings);
@@ -138,31 +140,31 @@ void AccountManager::save(bool saveCredentials)
138140
}
139141

140142
settings->sync();
141-
qDebug() << "Saved all account settings, status:" << settings->status();
143+
qCDebug(lcAccountManager) << "Saved all account settings, status:" << settings->status();
142144
}
143145

144146
void AccountManager::saveAccount(Account* a)
145147
{
146-
qDebug() << "Saving account" << a->url().toString();
148+
qCDebug(lcAccountManager) << "Saving account" << a->url().toString();
147149
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
148150
settings->beginGroup(a->id());
149151
saveAccountHelper(a, *settings, false); // don't save credentials they might not have been loaded yet
150152
settings->endGroup();
151153

152154
settings->sync();
153-
qDebug() << "Saved account settings, status:" << settings->status();
155+
qCDebug(lcAccountManager) << "Saved account settings, status:" << settings->status();
154156
}
155157

156158
void AccountManager::saveAccountState(AccountState* a)
157159
{
158-
qDebug() << "Saving account state" << a->account()->url().toString();
160+
qCDebug(lcAccountManager) << "Saving account state" << a->account()->url().toString();
159161
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
160162
settings->beginGroup(a->account()->id());
161163
a->writeToSettings(*settings);
162164
settings->endGroup();
163165

164166
settings->sync();
165-
qDebug() << "Saved account state settings, status:" << settings->status();
167+
qCDebug(lcAccountManager) << "Saved account state settings, status:" << settings->status();
166168
}
167169

168170
void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool saveCredentials)
@@ -189,7 +191,7 @@ void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool s
189191

190192
// Save accepted certificates.
191193
settings.beginGroup(QLatin1String("General"));
192-
qDebug() << "Saving " << acc->approvedCerts().count() << " unknown certs.";
194+
qCDebug(lcAccountManager) << "Saving " << acc->approvedCerts().count() << " unknown certs.";
193195
QByteArray certs;
194196
Q_FOREACH( const QSslCertificate& cert, acc->approvedCerts() ) {
195197
certs += cert.toPem() + '\n';
@@ -203,7 +205,7 @@ void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool s
203205
if (acc->_am) {
204206
CookieJar* jar = qobject_cast<CookieJar*>(acc->_am->cookieJar());
205207
if (jar) {
206-
qDebug() << "Saving cookies." << acc->cookieJarPath();
208+
qCDebug(lcAccountManager) << "Saving cookies." << acc->cookieJarPath();
207209
jar->save(acc->cookieJarPath());
208210
}
209211
}
@@ -214,7 +216,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings& settings)
214216
auto urlConfig = settings.value(QLatin1String(urlC));
215217
if (!urlConfig.isValid()) {
216218
// No URL probably means a corrupted entry in the account settings
217-
qDebug() << "No URL for account " << settings.group();
219+
qCDebug(lcAccountManager) << "No URL for account " << settings.group();
218220
return AccountPtr();
219221
}
220222

@@ -243,7 +245,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings& settings)
243245
acc->setUrl(urlConfig.toUrl());
244246
}
245247

246-
qDebug() << "Account for" << acc->url() << "using auth type" << authType;
248+
qCDebug(lcAccountManager) << "Account for" << acc->url() << "using auth type" << authType;
247249

248250
acc->_serverVersion = settings.value(QLatin1String(serverVersionC)).toString();
249251

0 commit comments

Comments
 (0)
Please sign in to comment.