From 909f54c80abb7195c2e82c6e06c414f4526a339e Mon Sep 17 00:00:00 2001 From: Pierre Rochard Date: Fri, 15 Jun 2018 19:02:52 -0400 Subject: [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 --- src/wallet/wallet.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/wallet/wallet.h') 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 + void WalletLogPrintf(std::string fmt, Params... parameters) const { + LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...); + }; + }; /** A key allocated from the key pool. */ -- cgit v1.2.3