Go to the documentation of this file. 41 # define SPYLOG_ABORT() std::abort() 47 # define DEBUG_BREAK() DebugBreak() 50 # define DEBUG_BREAK() std::raise(SIGTRAP) 56 # define SPYLOG_ABORT() DEBUG_BREAK() 63 #include <boost/preprocessor/comparison/greater_equal.hpp> 64 #include <boost/preprocessor/control/expr_iif.hpp> 66 # include "fwCore/log/SpyLogger.hpp" 67 # include "fwCore/log/ScopedMessage.hpp" 77 # ifndef __FWCORE_EXPR_BLOCK 78 # define __FWCORE_EXPR_BLOCK(expr) do { expr } while (0) 81 # define __FWCORE_IF(cond, code) if ( cond ) { code } 83 # define OSL_LOG(log, loglevel, message) __FWCORE_EXPR_BLOCK( \ 84 std::stringstream oslStr; \ 86 SL_ ## loglevel(log, oslStr.str()); \ 91 #define __FWCORE_IF_ENABLED( level, expr ) \ 92 BOOST_PP_EXPR_IIF( BOOST_PP_GREATER_EQUAL(SPYLOG_LEVEL, level), expr) 98 # define SL_TRACE(log, message) __FWCORE_IF_ENABLED( 6, \ 99 log.trace(message, __FILE__, __LINE__); \ 101 # define OSL_TRACE(log, message) __FWCORE_IF_ENABLED( 6, \ 102 OSL_LOG(log, TRACE, message); \ 104 # define SL_TRACE_IF(log, message, cond) __FWCORE_IF_ENABLED( 6, \ 105 __FWCORE_IF(cond, log.trace(message, __FILE__, \ 108 # define OSL_TRACE_IF(log, message, cond) __FWCORE_IF_ENABLED( 6, \ 109 __FWCORE_IF(cond, OSL_LOG(log, TRACE, message); ) \ 112 # define SL_DEBUG(log, message) __FWCORE_IF_ENABLED( 5, \ 113 log.debug(message, __FILE__, __LINE__); \ 115 # define OSL_DEBUG(log, message) __FWCORE_IF_ENABLED( 5, \ 116 OSL_LOG(log, DEBUG, message); \ 118 # define SL_DEBUG_IF(log, message, cond) __FWCORE_IF_ENABLED( 5, \ 119 __FWCORE_IF(cond, log.debug(message, __FILE__, \ 122 #define OSL_DEBUG_IF(log, message, cond) __FWCORE_IF_ENABLED( 5, \ 123 __FWCORE_IF(cond, OSL_LOG(log, DEBUG, message); ) \ 126 #define SL_INFO(log, message) __FWCORE_IF_ENABLED( 4, \ 127 log.info(message, __FILE__, __LINE__); \ 129 #define OSL_INFO(log, message) __FWCORE_IF_ENABLED( 4, \ 130 OSL_LOG(log, INFO, message); \ 132 #define SL_INFO_IF(log, message, cond) __FWCORE_IF_ENABLED( 4, \ 133 __FWCORE_IF(cond, log.info(message, __FILE__, __LINE__); ) \ 135 #define OSL_INFO_IF(log, message, cond) __FWCORE_IF_ENABLED( 4, \ 136 __FWCORE_IF(cond, OSL_LOG(log, INFO, message); ) \ 139 #define SL_WARN(log, message) __FWCORE_IF_ENABLED( 3, \ 140 log.warn(message, __FILE__, __LINE__); \ 142 #define OSL_WARN(log, message) __FWCORE_IF_ENABLED( 3, \ 143 OSL_LOG(log, WARN, message); \ 145 #define SL_WARN_IF(log, message, cond) __FWCORE_IF_ENABLED( 3, \ 146 __FWCORE_IF(cond, log.warn(message, __FILE__, __LINE__); ) \ 148 #define OSL_WARN_IF(log, message, cond) __FWCORE_IF_ENABLED( 3, \ 149 __FWCORE_IF(cond, OSL_LOG(log, WARN, message); ) \ 152 #define SL_ERROR(log, message) __FWCORE_IF_ENABLED( 2, \ 153 log.error(message, __FILE__, __LINE__); \ 155 #define OSL_ERROR(log, message) __FWCORE_IF_ENABLED( 2, \ 156 OSL_LOG(log, ERROR, message); \ 158 #define SL_ERROR_IF(log, message, cond) __FWCORE_IF_ENABLED( 2, \ 159 __FWCORE_IF(cond, log.error(message, __FILE__, __LINE__); ) \ 161 #define OSL_ERROR_IF(log, message, cond) __FWCORE_IF_ENABLED( 2, \ 162 __FWCORE_IF(cond, OSL_LOG(log, ERROR, message); ) \ 165 #define SL_FATAL(log, message) __FWCORE_IF_ENABLED( 1, \ 166 log.fatal(message, __FILE__, __LINE__); \ 169 #define OSL_FATAL(log, message) __FWCORE_IF_ENABLED( 1, \ 170 OSL_LOG(log, FATAL, message); \ 173 #define SL_FATAL_IF(log, message, cond) __FWCORE_IF_ENABLED( 1, \ 174 __FWCORE_IF(cond, SL_FATAL(log, message); ) \ 176 #define OSL_FATAL_IF(log, message, cond) __FWCORE_IF_ENABLED( 1, \ 177 __FWCORE_IF(cond, OSL_FATAL(log, message); ) \ 184 # define SL_ASSERT(log, message, cond) __FWCORE_EXPR_BLOCK( \ 185 __FWCORE_IF(!(cond), \ 186 std::stringstream oslStr1; \ 187 oslStr1 << "Assertion '" << \ 188 #cond << "' failed.\n" << message; \ 189 log.fatal(oslStr1.str(), __FILE__, __LINE__); \ 190 _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, NULL, "%s", oslStr1.str().c_str()); \ 194 # define SL_ASSERT(log, message, cond) __FWCORE_EXPR_BLOCK( \ 195 __FWCORE_IF(!(cond), \ 196 std::stringstream oslStr1; \ 197 oslStr1 << "Assertion '" << \ 198 #cond << "' failed: " << message; \ 199 log.fatal(oslStr1.str(), __FILE__, __LINE__); \ 204 # define OSL_ASSERT(log, message, cond) __FWCORE_EXPR_BLOCK( \ 205 __FWCORE_IF(!(cond), \ 206 std::stringstream oslStr; \ 208 SL_ASSERT(log, oslStr.str(), cond); \ 211 # define SL_ASSERT(log, message, cond) // empty 212 # define OSL_ASSERT(log, message, cond) // empty 217 # define _SPYLOG_SPYLOGGER_ \ 218 ::fwCore::log::SpyLogger::getSpyLogger() 228 # define SLM_TRACE(message) SL_TRACE(_SPYLOG_SPYLOGGER_, message) 230 # define OSLM_TRACE(message) OSL_TRACE(_SPYLOG_SPYLOGGER_, message) 232 # define SLM_TRACE_IF(message, cond) SL_TRACE_IF(_SPYLOG_SPYLOGGER_, message, cond) 234 # define OSLM_TRACE_IF(message, cond) OSL_TRACE_IF(_SPYLOG_SPYLOGGER_, message, cond) 239 # define SLM_DEBUG(message) SL_DEBUG(_SPYLOG_SPYLOGGER_, message) 241 # define OSLM_DEBUG(message) OSL_DEBUG(_SPYLOG_SPYLOGGER_, message) 243 # define SLM_DEBUG_IF(message, cond) SL_DEBUG_IF(_SPYLOG_SPYLOGGER_, message, cond) 245 # define OSLM_DEBUG_IF(message, cond) OSL_DEBUG_IF(_SPYLOG_SPYLOGGER_, message, cond) 250 # define SLM_INFO(message) SL_INFO(_SPYLOG_SPYLOGGER_, message) 252 # define OSLM_INFO(message) OSL_INFO(_SPYLOG_SPYLOGGER_, message) 254 # define SLM_INFO_IF(message, cond) SL_INFO_IF(_SPYLOG_SPYLOGGER_, message, cond) 256 # define OSLM_INFO_IF(message, cond) OSL_INFO_IF(_SPYLOG_SPYLOGGER_, message, cond) 261 # define SLM_WARN(message) SL_WARN(_SPYLOG_SPYLOGGER_, message) 263 # define OSLM_WARN(message) OSL_WARN(_SPYLOG_SPYLOGGER_, message) 265 # define SLM_WARN_IF(message, cond) SL_WARN_IF(_SPYLOG_SPYLOGGER_, message, cond) 267 # define OSLM_WARN_IF(message, cond) OSL_WARN_IF(_SPYLOG_SPYLOGGER_, message, cond) 272 # define SLM_ERROR(message) SL_ERROR(_SPYLOG_SPYLOGGER_, message) 274 # define OSLM_ERROR(message) OSL_ERROR(_SPYLOG_SPYLOGGER_, message) 276 # define SLM_ERROR_IF(message, cond) SL_ERROR_IF(_SPYLOG_SPYLOGGER_, message, cond) 278 # define OSLM_ERROR_IF(message, cond) OSL_ERROR_IF(_SPYLOG_SPYLOGGER_, message, cond) 283 # define SLM_FATAL(message) SL_FATAL(_SPYLOG_SPYLOGGER_, message) 285 # define OSLM_FATAL(message) OSL_FATAL(_SPYLOG_SPYLOGGER_, message) 287 # define SLM_FATAL_IF(message, cond) SL_FATAL_IF(_SPYLOG_SPYLOGGER_, message, cond) 289 # define OSLM_FATAL_IF(message, cond) OSL_FATAL_IF(_SPYLOG_SPYLOGGER_, message, cond) 294 #define OSLM_LOG(message) \ 295 __FWCORE_EXPR_BLOCK( \ 296 std::stringstream stream; \ 298 _SPYLOG_SPYLOGGER_.log(stream.str(), __FILE__, __LINE__); \ 308 # define SLM_ASSERT(message, cond) \ 309 SL_ASSERT(_SPYLOG_SPYLOGGER_, message, cond) 310 # define OSLM_ASSERT(message, cond) \ 311 OSL_ASSERT(_SPYLOG_SPYLOGGER_, message, cond) 315 # ifdef __GNUC__ // with GCC 316 # define SLM_PRETTY_FUNC() __PRETTY_FUNCTION__ 317 # elif defined(_MSC_VER) // with MSC 318 # define SLM_PRETTY_FUNC() __FUNCSIG__ 320 # define SLM_PRETTY_FUNC() __func__ 328 # ifndef SPYLOG_TIMER 329 # define SLM_TRACE_FUNC() SLM_TRACE(SLM_PRETTY_FUNC()) 332 # define SLM_TRACE_FUNC() __FWCORE_EXPR_BLOCK( \ 333 ::fwCore::log::ScopedMessage __spylog__scoped__msg__( \ 334 __FILE__, __LINE__, SLM_PRETTY_FUNC()); \ 335 __spylog__scoped__msg__.use(); \ 344 #define FW_DEPRECATED(oldFnName, newFnName, version) \ 345 OSLM_ERROR( "[DEPRECATED] '" << oldFnName << "' is deprecated and will be removed in '" << version << "', use '" \ 346 << newFnName << "' instead. It is still used by '" + this->getClassname() + "'." \ 352 #define FW_DEPRECATED_IF(oldFnName, newFnName, version, condition) \ 353 OSLM_ERROR_IF("[DEPRECATED] '" << oldFnName << "' is deprecated and will be removed in '" << version << "', use '" \ 354 << newFnName << "' instead. It is still used by '" + this->getClassname() + "'.", \ 360 #define FW_DEPRECATED_MSG(message, version) \ 361 OSLM_ERROR( "[DEPRECATED] " << message << " It will be removed in '" << version << "'"); 366 #define FW_DEPRECATED_KEY(newKey, access, version) \ 367 OSLM_ERROR( "[DEPRECATED] The key '" << newKey << "' is not correctly set. Please correct the configuration to " \ 368 "set an '" << access << "' key named '" << newKey << "'. The support of the old key will be removed " \ 369 "in '" << version << "'.");