From 29ba06697118653a291257025c5faa106c3ee655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 23 Feb 2015 19:02:01 +0100 Subject: [PATCH] Fix logging on GCC, release variant added --- evmjit/libevmjit/Utils.cpp | 16 ++++++++++++---- evmjit/libevmjit/Utils.h | 21 +++++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/evmjit/libevmjit/Utils.cpp b/evmjit/libevmjit/Utils.cpp index bf3bf93b3..3644def04 100644 --- a/evmjit/libevmjit/Utils.cpp +++ b/evmjit/libevmjit/Utils.cpp @@ -1,13 +1,21 @@ #include "Utils.h" +#include + +#if !defined(NDEBUG) // Debug + namespace dev { -namespace eth +namespace evmjit { -namespace jit -{ - +std::ostream& getLogStream(char const* _channel) +{ + static std::ostream nullStream{nullptr}; + return (llvm::DebugFlag && llvm::isCurrentDebugType(_channel)) ? std::cerr : nullStream; } + } } + +#endif diff --git a/evmjit/libevmjit/Utils.h b/evmjit/libevmjit/Utils.h index 489eed46c..7e10e0c63 100644 --- a/evmjit/libevmjit/Utils.h +++ b/evmjit/libevmjit/Utils.h @@ -2,10 +2,23 @@ #include -#include - // The same as assert, but expression is always evaluated and result returned #define CHECK(expr) (assert(expr), expr) -// FIXME: Disable for NDEBUG mode -#define DLOG(CHANNEL) !(llvm::DebugFlag && llvm::isCurrentDebugType(#CHANNEL)) ? (void)0 : std::cerr +#if !defined(NDEBUG) // Debug + +namespace dev +{ +namespace evmjit +{ + +std::ostream& getLogStream(char const* _channel); + +} +} + +#define DLOG(CHANNEL) ::dev::evmjit::getLogStream(#CHANNEL) + +#else // Release + #define DLOG(CHANNEL) true ? std::cerr : std::cerr +#endif