From fde7b71933e809cb1cc7e4d0513db9e4d050065b Mon Sep 17 00:00:00 2001 From: sjunges Date: Thu, 25 Feb 2016 15:20:06 +0100 Subject: [PATCH] Nice printing when no logging framework is enabled Former-commit-id: 783fe7eea12722d4abc1b0187353ddef50ed84e7 --- src/utility/macros.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/utility/macros.h b/src/utility/macros.h index db1394380..4f70b1691 100644 --- a/src/utility/macros.h +++ b/src/utility/macros.h @@ -21,13 +21,19 @@ extern int storm_runtime_loglevel; #endif +#define __SHORT_FORM_OF_FILE__ \ +(strrchr(__FILE__,'/') \ +? strrchr(__FILE__,'/')+1 \ +: __FILE__ \ +) + #ifndef STORM_LOG_DISABLE_DEBUG #define STORM_LOG_DEBUG(message) \ do { \ if(storm_runtime_loglevel >= STORM_LOGLEVEL_DEBUG) { \ std::stringstream __ss; \ __ss << message; \ - std::cout << "LOG DBG: " << __ss.str() << std::endl; \ + std::cout << "DEBUG (" << __SHORT_FORM_OF_FILE__ << ":" << __LINE__ << "): " << __ss.str() << std::endl; \ } \ } while (false) #else @@ -42,7 +48,7 @@ do { \ if(storm_runtime_loglevel >= STORM_LOGLEVEL_TRACE) { \ std::stringstream __ss; \ __ss << message; \ - std::cout << "LOG TRC: " << __ss.str() << std::endl; \ + std::cout << "TRACE (" << __SHORT_FORM_OF_FILE__ << ":" << __LINE__ << "): " << __ss.str() << std::endl; \ } \ } while(false) #else @@ -57,7 +63,7 @@ do { \ #define STORM_LOG_ASSERT(cond, message) \ do { \ if (!(cond)) { \ -std::cout << "ASSERT FAILED: " << message << std::endl; \ +std::cout << "ASSERT FAILED (" << __SHORT_FORM_OF_FILE__ << ":" << __LINE__ << "): " << message << std::endl; \ assert(cond); \ } \ } while (false) @@ -69,7 +75,7 @@ assert(cond); \ #define STORM_LOG_THROW(cond, exception, message) \ do { \ if (!(cond)) { \ - std::cout << "LOG ERR: " << message << std::endl; \ + std::cout << "ERROR (" << __SHORT_FORM_OF_FILE__ << ":" << __LINE__ << "): " << message << std::endl; \ throw exception() << message; \ } \ } while (false) @@ -81,7 +87,7 @@ do { \ if(storm_runtime_loglevel >= STORM_LOGLEVEL_WARN) { \ std::stringstream __ss; \ __ss << message; \ - std::cout << "LOG WRN: " << message << std::endl; \ + std::cout << "WARN (" << __SHORT_FORM_OF_FILE__ << ":" << __LINE__ << "): " << __ss.str() << std::endl; \ } \ } while (false) @@ -97,7 +103,7 @@ do { \ if(storm_runtime_loglevel >= STORM_LOGLEVEL_INFO) { \ std::stringstream __ss; \ __ss << message; \ - std::cout << "LOG INF: " << message << std::endl; \ + std::cout << "INFO (" << __SHORT_FORM_OF_FILE__ << ":" << __LINE__ << "): " << __ss.str() << std::endl; \ } \ } while (false) @@ -113,7 +119,7 @@ do { \ if(storm_runtime_loglevel >= STORM_LOGLEVEL_ERROR) { \ std::stringstream __ss; \ __ss << message; \ - std::cout << "LOG ERR: " << message << std::endl; \ + std::cout << "ERROR (" << __SHORT_FORM_OF_FILE__ << ":" << __LINE__ << "): " << __ss.str() << std::endl; \ } \ } while (false) \