aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/trace.h
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2023-05-03 12:13:47 +0300
committerthegeorg <thegeorg@yandex-team.com>2023-05-03 12:13:47 +0300
commitd61cfa00fcd6078cabd02c099e257ec215c496c5 (patch)
tree73b8317aa93a0e66e257fa5e04116c2057a6e84e /util/stream/trace.h
parentf6a12447ecba795d28300e7f709c1abc9acad0cf (diff)
downloadydb-d61cfa00fcd6078cabd02c099e257ec215c496c5.tar.gz
Workaround -Wunused-but-set-variable in Y_DBGTRACE macro
Diffstat (limited to 'util/stream/trace.h')
-rw-r--r--util/stream/trace.h60
1 files changed, 24 insertions, 36 deletions
diff --git a/util/stream/trace.h b/util/stream/trace.h
index 6169246c7d..af5dc10397 100644
--- a/util/stream/trace.h
+++ b/util/stream/trace.h
@@ -1,6 +1,7 @@
#pragma once
#include "debug.h"
+#include <util/system/defaults.h>
/**
* Debug level, as set via `DBGOUT` environment variable.
@@ -19,42 +20,29 @@ enum ETraceLevel: ui8 {
#define Y_ENABLE_TRACE
#endif
-#ifdef Y_ENABLE_TRACE
-
- /**
- * Writes the given data into standard debug stream if current debug level set
- * via `DBGOUT` environment variable permits it.
- *
- * Does nothing in release builds unless `Y_ENABLE_TRACE` is defined.
- *
- * Example usage:
- * @code
- * Y_DBGTRACE(DEBUG, "Advance from " << node1 << " to " << node2);
- * @endcode
- *
- * @param elevel Debug level of this trace command, e.g.
- * `WARN` or `DEBUG`. Basically a suffix of
- * one of the values of `ETraceLevel` enum.
- * @param args Argument chain to be written out into
- * standard debug stream, joined with `<<`
- * operator.
- * @see ETraceLevel
- */
- #define Y_DBGTRACE(elevel, args) Y_DBGTRACE0(int(TRACE_##elevel), args)
- #define Y_DBGTRACE0(level, args) \
- do \
+/**
+ * Writes the given data into standard debug stream if current debug level set
+ * via `DBGOUT` environment variable permits it.
+ *
+ * Example usage:
+ * @code
+ * Y_DBGTRACE(DEBUG, "Advance from " << node1 << " to " << node2);
+ * @endcode
+ *
+ * @param elevel Debug level of this trace command, e.g.
+ * `WARN` or `DEBUG`. Basically a suffix of
+ * one of the values of `ETraceLevel` enum.
+ * @param args Argument chain to be written out into
+ * standard debug stream, joined with `<<`
+ * operator.
+ * @see ETraceLevel
+ */
+#define Y_DBGTRACE(elevel, args) Y_DBGTRACE0(int(TRACE_##elevel), args)
+#define Y_DBGTRACE0(level, args) \
+ do { \
+ if constexpr (Y_IS_DEBUG_BUILD) { \
if ((level) <= StdDbgLevel()) { \
StdDbgStream() << args << Endl; \
} \
- while (false)
-
-#else
-
- #define Y_DBGTRACE(elevel, args) \
- do { \
- } while (false)
- #define Y_DBGTRACE0(level, args) \
- do { \
- } while (false)
-
-#endif
+ } \
+ } while (false)