aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2018-04-12 17:22:49 -0400
committerCory Fields <cory-nospam-@coryfields.com>2018-04-12 18:33:30 -0400
commit339730a6d84a3a90ae23d732fbfc1c81af88d435 (patch)
tree90ebbf6861863f2f48b7b8e2dc46ef3f23757a5e /src/util.h
parent39439e5ab4195bb1abebd2c8b1ac702bc33c2e60 (diff)
logging: bypass timestamp formatting when not logging
This leads to massive speedups under Wine.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h16
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 { \