From 8c2cb4887f73e41bc30d9ef2ae7de9543ba4dba2 Mon Sep 17 00:00:00 2001 From: sjunges Date: Thu, 25 Feb 2016 13:49:36 +0100 Subject: [PATCH] Cmake option to disable debug and trace outputs Former-commit-id: 9758862579554eb3f83af62c09cfef5e4dbcd06c --- CMakeLists.txt | 1 + src/utility/macros.h | 32 ++++++++++++++++++++++++++++++-- storm-config.h.in | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38c216d00..e19b6266d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ option(USE_CARL "Sets whether carl should be included." ON) option(FORCE_COLOR "Force color output" OFF) option(STORM_COMPILE_WITH_CCACHE "Compile using CCache" ON) option(STORM_LOGGING_FRAMEWORK "Use a framework for logging" OFF) +option(STORM_LOG_DISABLE_DEBUG "Disable log and trace message support" OFF) set(GUROBI_ROOT "" CACHE STRING "A hint to the root directory of Gurobi (optional).") set(Z3_ROOT "" CACHE STRING "A hint to the root directory of Z3 (optional).") set(CUDA_ROOT "" CACHE STRING "The root directory of CUDA.") diff --git a/src/utility/macros.h b/src/utility/macros.h index 769825139..db1394380 100644 --- a/src/utility/macros.h +++ b/src/utility/macros.h @@ -16,6 +16,12 @@ extern int storm_runtime_loglevel; #define STORM_LOGLEVEL_DEBUG 3 #define STORM_LOGLEVEL_TRACE 4 +#ifdef STORM_LOG_DISABLE_DEBUG +#define STORM_LOG_DISABLE_TRACE +#endif + + +#ifndef STORM_LOG_DISABLE_DEBUG #define STORM_LOG_DEBUG(message) \ do { \ if(storm_runtime_loglevel >= STORM_LOGLEVEL_DEBUG) { \ @@ -24,15 +30,26 @@ do { \ std::cout << "LOG DBG: " << __ss.str() << std::endl; \ } \ } while (false) +#else +#define STORM_LOG_DEBUG(message) \ +do { \ +} while (false) +#endif +#ifndef STORM_LOG_DISABLE_TRACE #define STORM_LOG_TRACE(message) \ do { \ if(storm_runtime_loglevel >= STORM_LOGLEVEL_TRACE) { \ std::stringstream __ss; \ __ss << message; \ - std::cout << "LOG TRC: " << message << std::endl; \ + std::cout << "LOG TRC: " << __ss.str() << std::endl; \ } \ } while(false) +#else +#define STORM_LOG_TRACE(message) \ +do { \ +} while (false) +#endif // Define STORM_LOG_ASSERT which is only checked when NDEBUG is not set. @@ -112,15 +129,26 @@ do { \ storm_runtime_loglevel = STORM_LOGLEVEL_INFO; \ } while (false) +#ifndef STORM_LOG_DISABLE_DEBUG #define STORM_GLOBAL_LOGLEVEL_DEBUG() \ do { \ storm_runtime_loglevel = STORM_LOGLEVEL_DEBUG; \ } while(false) - +#else +#define STORM_GLOBAL_LOGLEVEL_DEBUG() \ +std::cout << "***** warning ***** loglevel debug is not compiled\n" +#endif + +#ifndef STORM_LOG_DISABLE_TRACE #define STORM_GLOBAL_LOGLEVEL_TRACE() \ do { \ storm_runtime_loglevel = STORM_LOGLEVEL_TRACE; \ } while(false) +#else +#define STORM_GLOBAL_LOGLEVEL_TRACE() \ +std::cout << "***** warning ***** loglevel trace is not compiled\n" +#endif + #else // Include the parts necessary for Log4cplus. diff --git a/storm-config.h.in b/storm-config.h.in index e7fbd50e6..7000bd141 100644 --- a/storm-config.h.in +++ b/storm-config.h.in @@ -46,4 +46,6 @@ #cmakedefine STORM_LOGGING_FRAMEWORK +#cmakedefine STORM_LOG_DISABLE_DEBUG + #endif // STORM_GENERATED_STORMCONFIG_H_