summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/bbstored/BBStoreDHousekeeping.cpp22
-rw-r--r--lib/backupstore/HousekeepStoreAccount.cpp5
-rw-r--r--lib/backupstore/HousekeepStoreAccount.h2
-rw-r--r--lib/common/Logging.h11
4 files changed, 31 insertions, 9 deletions
diff --git a/bin/bbstored/BBStoreDHousekeeping.cpp b/bin/bbstored/BBStoreDHousekeeping.cpp
index d0f83aed..96fa7c80 100644
--- a/bin/bbstored/BBStoreDHousekeeping.cpp
+++ b/bin/bbstored/BBStoreDHousekeeping.cpp
@@ -100,15 +100,23 @@ void BackupStoreDaemon::RunHousekeepingIfNeeded()
{
try
{
- // Tag log output to identify account
- std::ostringstream tag;
- tag << "hk/" << BOX_FORMAT_ACCOUNT(*i);
- Logging::Tagger tagWithClientID(tag.str());
-
- // Get the account root
std::string rootDir;
int discSet = 0;
- mpAccounts->GetAccountRoot(*i, rootDir, discSet);
+
+ {
+ // Tag log output to identify account
+ std::ostringstream tag;
+ tag << "hk/" << BOX_FORMAT_ACCOUNT(*i);
+ Logging::Tagger tagWithClientID(tag.str());
+
+ // Get the account root
+ mpAccounts->GetAccountRoot(*i, rootDir, discSet);
+
+ // Reset tagging as HousekeepStoreAccount will
+ // do that itself, to avoid duplicate tagging.
+ // Happens automatically when tagWithClientID
+ // goes out of scope.
+ }
// Do housekeeping on this account
HousekeepStoreAccount housekeeping(*i, rootDir,
diff --git a/lib/backupstore/HousekeepStoreAccount.cpp b/lib/backupstore/HousekeepStoreAccount.cpp
index 311ae433..86eb1059 100644
--- a/lib/backupstore/HousekeepStoreAccount.cpp
+++ b/lib/backupstore/HousekeepStoreAccount.cpp
@@ -65,6 +65,9 @@ HousekeepStoreAccount::HousekeepStoreAccount(int AccountID,
mRefCountsAdjusted(0),
mCountUntilNextInterprocessMsgCheck(POLL_INTERPROCESS_MSG_CHECK_FREQUENCY)
{
+ std::ostringstream tag;
+ tag << "hk/" << BOX_FORMAT_ACCOUNT(mAccountID);
+ mTagWithClientID.Change(tag.str());
}
// --------------------------------------------------------------------------
@@ -128,7 +131,7 @@ bool HousekeepStoreAccount::DoHousekeeping(bool KeepTryingForever)
std::ostringstream tag;
tag << "hk/" << BOX_FORMAT_ACCOUNT(mAccountID) << "/" <<
info->GetAccountName();
- Logging::Tagger tagWithClientID(tag.str());
+ mTagWithClientID.Change(tag.str());
// Calculate how much should be deleted
mDeletionSizeTarget = info->GetBlocksUsed() - info->GetBlocksSoftLimit();
diff --git a/lib/backupstore/HousekeepStoreAccount.h b/lib/backupstore/HousekeepStoreAccount.h
index 61cff868..cfa05a2e 100644
--- a/lib/backupstore/HousekeepStoreAccount.h
+++ b/lib/backupstore/HousekeepStoreAccount.h
@@ -105,6 +105,8 @@ private:
// Poll frequency
int mCountUntilNextInterprocessMsgCheck;
+
+ Logging::Tagger mTagWithClientID;
};
#endif // HOUSEKEEPSTOREACCOUNT__H
diff --git a/lib/common/Logging.h b/lib/common/Logging.h
index 574677f1..81062e38 100644
--- a/lib/common/Logging.h
+++ b/lib/common/Logging.h
@@ -346,15 +346,24 @@ class Logging
std::string mOldTag;
public:
+ Tagger()
+ : mOldTag(Logging::GetProgramName())
+ {
+ }
Tagger(const std::string& rTempTag)
+ : mOldTag(Logging::GetProgramName())
{
- mOldTag = Logging::GetProgramName();
Logging::SetProgramName(mOldTag + " " + rTempTag);
}
~Tagger()
{
Logging::SetProgramName(mOldTag);
}
+
+ void Change(const std::string& newTempTag)
+ {
+ Logging::SetProgramName(mOldTag + " " + newTempTag);
+ }
};
};