|
|
@ -18,92 +18,110 @@ extern int storm_runtime_loglevel; |
|
|
|
|
|
|
|
#define STORM_LOG_DEBUG(message) \ |
|
|
|
do { \ |
|
|
|
if(storm_runtime_loglevel <= STORM_LOGLEVEL_DEBUG) { \ |
|
|
|
std::cout << "LOG DBG: " << message << std::endl; \ |
|
|
|
if(storm_runtime_loglevel >= STORM_LOGLEVEL_DEBUG) { \ |
|
|
|
std::stringstream __ss; \ |
|
|
|
__ss << message; \ |
|
|
|
std::cout << "LOG DBG: " << __ss.str() << std::endl; \ |
|
|
|
} \ |
|
|
|
} while (false) |
|
|
|
|
|
|
|
#define STORM_LOG_TRACE(message) \ |
|
|
|
do { \ |
|
|
|
std::cout << "LOG TRC: " << message << std::endl; \ |
|
|
|
#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; \ |
|
|
|
} \ |
|
|
|
} while(false) |
|
|
|
|
|
|
|
|
|
|
|
// Define STORM_LOG_ASSERT which is only checked when NDEBUG is not set. |
|
|
|
#ifndef NDEBUG |
|
|
|
#define STORM_LOG_ASSERT(cond, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
std::cout << "LOG ERR: " << message << std::endl; \ |
|
|
|
assert(cond); \ |
|
|
|
} \ |
|
|
|
} while (false) \ |
|
|
|
#define STORM_LOG_ASSERT(cond, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
std::cout << "ASSERT FAILED: " << message << std::endl; \ |
|
|
|
assert(cond); \ |
|
|
|
} \ |
|
|
|
} while (false) |
|
|
|
|
|
|
|
#else |
|
|
|
#define STORM_LOG_ASSERT(cond, message) |
|
|
|
#endif |
|
|
|
// Define STORM_LOG_THROW to always throw the exception with the given message if the condition fails to hold. |
|
|
|
#define STORM_LOG_THROW(cond, exception, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
#define STORM_LOG_THROW(cond, exception, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
std::cout << "LOG ERR: " << message << std::endl; \ |
|
|
|
throw exception() << message; \ |
|
|
|
} \ |
|
|
|
} while (false) \ |
|
|
|
throw exception() << message; \ |
|
|
|
} \ |
|
|
|
} while (false) |
|
|
|
|
|
|
|
|
|
|
|
// Define STORM_LOG_WARN, STORM_LOG_ERROR and STORM_LOG_INFO to log the given message with the corresponding log levels. |
|
|
|
#define STORM_LOG_WARN(message) \ |
|
|
|
do { \ |
|
|
|
std::cout << "LOG WRN: " << message << std::endl; \ |
|
|
|
} while (false) \ |
|
|
|
|
|
|
|
#define STORM_LOG_WARN_COND(cond, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
std::cout << "LOG WRN: " << message << std::endl; \ |
|
|
|
} \ |
|
|
|
} while (false) \ |
|
|
|
|
|
|
|
#define STORM_LOG_INFO(message) \ |
|
|
|
do { \ |
|
|
|
std::cout << "LOG INF: " << message << std::endl; \ |
|
|
|
} while (false) \ |
|
|
|
|
|
|
|
#define STORM_LOG_INFO_COND(cond, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
std::cout << "LOG INF: " << message << std::endl; \ |
|
|
|
} \ |
|
|
|
} while (false) \ |
|
|
|
|
|
|
|
#define STORM_LOG_ERROR(message) \ |
|
|
|
do { \ |
|
|
|
std::stringstream __ss; \ |
|
|
|
__ss << message; \ |
|
|
|
std::cout << "LOG ERR: " << __ss.str() << std::endl; \ |
|
|
|
} while (false) \ |
|
|
|
#define STORM_LOG_WARN(message) \ |
|
|
|
do { \ |
|
|
|
if(storm_runtime_loglevel >= STORM_LOGLEVEL_WARN) { \ |
|
|
|
std::stringstream __ss; \ |
|
|
|
__ss << message; \ |
|
|
|
std::cout << "LOG WRN: " << message << std::endl; \ |
|
|
|
} \ |
|
|
|
} while (false) |
|
|
|
|
|
|
|
#define STORM_LOG_WARN_COND(cond, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
STORM_LOG_WARN(message); \ |
|
|
|
} \ |
|
|
|
} while (false) |
|
|
|
|
|
|
|
#define STORM_LOG_INFO(message) \ |
|
|
|
do { \ |
|
|
|
if(storm_runtime_loglevel >= STORM_LOGLEVEL_INFO) { \ |
|
|
|
std::stringstream __ss; \ |
|
|
|
__ss << message; \ |
|
|
|
std::cout << "LOG INF: " << message << std::endl; \ |
|
|
|
} \ |
|
|
|
} while (false) |
|
|
|
|
|
|
|
#define STORM_LOG_INFO_COND(cond, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
STORM_LOG_INFO(message); \ |
|
|
|
} \ |
|
|
|
} while (false) |
|
|
|
|
|
|
|
#define STORM_LOG_ERROR(message) \ |
|
|
|
do { \ |
|
|
|
if(storm_runtime_loglevel >= STORM_LOGLEVEL_ERROR) { \ |
|
|
|
std::stringstream __ss; \ |
|
|
|
__ss << message; \ |
|
|
|
std::cout << "LOG ERR: " << message << std::endl; \ |
|
|
|
} \ |
|
|
|
} while (false) \ |
|
|
|
|
|
|
|
#define STORM_LOG_ERROR_COND(cond, message) \ |
|
|
|
do { \ |
|
|
|
if (!(cond)) { \ |
|
|
|
STORM_LOG_ERROR(message) \ |
|
|
|
STORM_LOG_ERROR(message); \ |
|
|
|
} \ |
|
|
|
} while (false) \ |
|
|
|
|
|
|
|
#define STORM_GLOBAL_LOGLEVEL_INFO() \ |
|
|
|
do { \ |
|
|
|
#define STORM_GLOBAL_LOGLEVEL_INFO() \ |
|
|
|
do { \ |
|
|
|
storm_runtime_loglevel = STORM_LOGLEVEL_INFO; \ |
|
|
|
} while (false) |
|
|
|
|
|
|
|
#define STORM_GLOBAL_LOGLEVEL_DEBUG() \ |
|
|
|
do { \ |
|
|
|
#define STORM_GLOBAL_LOGLEVEL_DEBUG() \ |
|
|
|
do { \ |
|
|
|
storm_runtime_loglevel = STORM_LOGLEVEL_DEBUG; \ |
|
|
|
} while(false) |
|
|
|
|
|
|
|
#define STORM_GLOBAL_LOGLEVEL_TRACE() \ |
|
|
|
do { \ |
|
|
|
#define STORM_GLOBAL_LOGLEVEL_TRACE() \ |
|
|
|
do { \ |
|
|
|
storm_runtime_loglevel = STORM_LOGLEVEL_TRACE; \ |
|
|
|
} while(false) |
|
|
|
|
|
|
|
|
|
|
|
#else |
|
|
|
// Include the parts necessary for Log4cplus. |
|
|
|
#include "log4cplus/logger.h" |
|
|
|