mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
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
This commit is contained in:
parent
e653fb567c
commit
0524dfb93d
16
src/util.h
16
src/util.h
@ -201,14 +201,16 @@ template<typename T, typename... Args> static inline void MarkUsed(const T& t, c
|
|||||||
#define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0)
|
#define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0)
|
||||||
#else
|
#else
|
||||||
#define LogPrintf(...) do { \
|
#define LogPrintf(...) do { \
|
||||||
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
|
if (fPrintToConsole || fPrintToDebugLog) { \
|
||||||
try { \
|
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
|
||||||
_log_msg_ = tfm::format(__VA_ARGS__); \
|
try { \
|
||||||
} catch (tinyformat::format_error &e) { \
|
_log_msg_ = tfm::format(__VA_ARGS__); \
|
||||||
/* Original format string will have newline so don't add one here */ \
|
} catch (tinyformat::format_error &e) { \
|
||||||
_log_msg_ = "Error \"" + std::string(e.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
|
/* Original format string will have newline so don't add one here */ \
|
||||||
|
_log_msg_ = "Error \"" + std::string(e.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
LogPrintStr(_log_msg_); \
|
||||||
} \
|
} \
|
||||||
LogPrintStr(_log_msg_); \
|
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define LogPrint(category, ...) do { \
|
#define LogPrint(category, ...) do { \
|
||||||
|
Loading…
Reference in New Issue
Block a user