diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-08-06 16:43:49 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-08-06 17:36:23 +0200 |
commit | 26f59f5054ef4c045e24be0fd222c39e46670c51 (patch) | |
tree | 234621222a5c8511cd5fe7d79c16853bafa2b090 /src/wallet/wallet.h | |
parent | 317477a2463a516d607649754d42c498110ce476 (diff) | |
parent | 909f54c80abb7195c2e82c6e06c414f4526a339e (diff) | |
download | bitcoin-26f59f5054ef4c045e24be0fd222c39e46670c51.tar.xz |
Merge #12992: [wallet] Add wallet name to log messages
909f54c80abb7195c2e82c6e06c414f4526a339e [wallet] Add wallet name to log messages (Pierre Rochard)
Pull request description:
After multiple wallets became supported, wallet-related log messages became ambiguous as to which wallet they were being emitted by.
This pull request adds a `CWallet::WalletLogPrintf` function to be used when logging wallet-specific events. This function prepends the wallet's name to the log message and forwards it to `LogPrintf`
fixes #11317
Tree-SHA512: d258dcc9aa0f1330159bc66b4020f84709c5bba5165bdc62503543557d8999777f0b94a7a82a08823e2b2ceb84f4f8d1cd5493f99c076a13539f1f6155dc55ad
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r-- | src/wallet/wallet.h | 13 |
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. */ |