aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorPierre Rochard <pierre@rochard.org>2018-06-15 19:02:52 -0400
committerPierre Rochard <pierre@rochard.org>2018-08-02 12:09:39 -0400
commit909f54c80abb7195c2e82c6e06c414f4526a339e (patch)
treed0bb2bf8350d71c611da2b21b96870285d8351fe /src/wallet/wallet.h
parent1ef57a96b8b7255bd1f1ea0583846f18305419bf (diff)
downloadbitcoin-909f54c80abb7195c2e82c6e06c414f4526a339e.tar.xz
[wallet] Add wallet name to log messages
After multiple wallets became supported, wallet-related log messages became ambiguous as to which wallet they were being emitted by. fixes #11317
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index e005147073..06a7c0a752 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -1195,6 +1195,19 @@ public:
/** overwrite all flags by the given uint64_t
returns false if unknown, non-tolerable flags are present */
bool SetWalletFlags(uint64_t overwriteFlags, bool memOnly);
+
+ /** Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet has no name */
+ const std::string GetDisplayName() const {
+ std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName();
+ return strprintf("[%s]", wallet_name);
+ };
+
+ /** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */
+ template<typename... Params>
+ void WalletLogPrintf(std::string fmt, Params... parameters) const {
+ LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...);
+ };
+
};
/** A key allocated from the key pool. */