diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2018-04-12 18:27:37 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2018-04-12 18:35:26 -0700 |
commit | 5df84de583c900e00fef63bedaef32786f205a33 (patch) | |
tree | c15651b86874da2c54beef14e4c514de464aea1e /src | |
parent | 4ba6da55743a55189164e29e45ac9e73a074d808 (diff) | |
parent | 339730a6d84a3a90ae23d732fbfc1c81af88d435 (diff) |
Merge #12970: logging: bypass timestamp formatting when not logging
339730a6d8 logging: bypass timestamp formatting when not logging (Cory Fields)
Pull request description:
As suggested by @laanwj on IRC:
```
<cfields> whoa
<cfields> Leaving test case "knapsack_solver_test"; testing time: 358694ms
<cfields> i386 + old wine ^^
<cfields> Leaving test case "knapsack_solver_test"; testing time: 6781ms
<cfields> ^^ same, but with the LogPrint commented out
...
<wumpus> if both log-to-file and log-to-console is disabled, it should probably bypass all logging
```
Edit: The painful line commented out being the LogPrintf in CWallet::AddToWallet.
Tree-SHA512: bc6da67dcdf05e9164fff7a7e9980de897e6f1b0d3f6e1ebde2162cbcba7d54a6ec94283534eb5a1ebde7134533d7fe7e496aa35ea3128c567ed6483eae5212c
Diffstat (limited to 'src')
-rw-r--r-- | src/util.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/util.h b/src/util.h index 3952461e48..18d2076a05 100644 --- a/src/util.h +++ b/src/util.h @@ -145,14 +145,16 @@ template<typename T, typename... Args> static inline void MarkUsed(const T& t, c #define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0) #else #define LogPrintf(...) do { \ - std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \ - try { \ - _log_msg_ = tfm::format(__VA_ARGS__); \ - } catch (tinyformat::format_error &fmterr) { \ - /* Original format string will have newline so don't add one here */ \ - _log_msg_ = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \ + if (fPrintToConsole || fPrintToDebugLog) { \ + std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \ + try { \ + _log_msg_ = tfm::format(__VA_ARGS__); \ + } catch (tinyformat::format_error &fmterr) { \ + /* Original format string will have newline so don't add one here */ \ + _log_msg_ = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \ + } \ + LogPrintStr(_log_msg_); \ } \ - LogPrintStr(_log_msg_); \ } while(0) #define LogPrint(category, ...) do { \ |