From 2c9a4f6b41c493a28f3c6c4e8527edff9a71d042 Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Fri, 14 Sep 2018 11:40:44 -0700 Subject: [PATCH] Evaluate debug logging only in debug mode (#2869) This PR makes it so debugging logs are only evaluated during debugging. We found that for the current code, functions called in debug logging code are evaluated even in release mode (even though nothing is printed). --- src/ray/util/logging.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ray/util/logging.h b/src/ray/util/logging.h index 35bb9841d..daaa92369 100644 --- a/src/ray/util/logging.h +++ b/src/ray/util/logging.h @@ -35,7 +35,9 @@ namespace ray { #define RAY_LOG_INTERNAL(level) ::ray::RayLog(__FILE__, __LINE__, level) -#define RAY_LOG(level) RAY_LOG_INTERNAL(RAY_##level) +#define RAY_LOG(level) \ + if (ray::RayLog::IsLevelEnabled(RAY_##level)) RAY_LOG_INTERNAL(RAY_##level) + #define RAY_IGNORE_EXPR(expr) ((void)(expr)) #define RAY_CHECK(condition) \