15 #ifndef __IPSDKUTIL_BASELOG_H__ 16 #define __IPSDKUTIL_BASELOG_H__ 18 #include <log4cplus/logger.h> 19 #include <log4cplus/loglevel.h> 20 #include <log4cplus/loggingmacros.h> 24 #include <IPSDKUtil/Logger/LogMessageFormater.h> 25 #include <IPSDKUtil/Logger/BaseException.h> 26 #include <IPSDKUtil/Logger/UnHandleException.h> 27 #include <boost/preprocessor/seq.hpp> 28 #include <boost/current_function.hpp> 54 #define IPSDK_LOG(libraryName, msg, level) \ 57 log4cplus::Logger usedLogger = (IPSDK_LIB_LOGGER(libraryName)); \ 58 if(usedLogger.isEnabledFor(log4cplus::level) == true) { \ 59 ipsdk::LogMessageFormater msgInternal(IPSDK_LIB_LOG_MSG_MANAGER(libraryName)); \ 61 ipsdk::logMessage(usedLogger, log4cplus::level, msgInternal.string(), \ 62 __FILE__, __LINE__); \ 65 catch (const ipsdk::BaseException& e) { \ 66 std::string errMsg("Exception thrown while processing message"); \ 67 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 68 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, \ 69 __FILE__, __LINE__, e); \ 71 catch (const std::exception& e) { \ 72 std::string errMsg("Exception thrown while processing message"); \ 73 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 74 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, \ 75 __FILE__, __LINE__, e); \ 78 std::string errMsg("Exception thrown while processing message"); \ 79 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 80 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, \ 81 __FILE__, __LINE__, ipsdk::UnHandleException()); \ 88 #define IPSDK_LOG_TRACE(libraryName, msg) \ 89 IPSDK_LOG(libraryName, msg, TRACE_LOG_LEVEL); 94 #define IPSDK_LOG_DEBUG(libraryName, msg) \ 95 IPSDK_LOG(libraryName, msg, DEBUG_LOG_LEVEL); 100 #define IPSDK_LOG_INFO(libraryName, msg) \ 101 IPSDK_LOG(libraryName, msg, INFO_LOG_LEVEL); 106 #define IPSDK_LOG_WARN(libraryName, msg) \ 107 IPSDK_LOG(libraryName, msg, WARN_LOG_LEVEL); 112 #define IPSDK_LOG_ERROR(libraryName, msg) \ 113 IPSDK_LOG(libraryName, msg, ERROR_LOG_LEVEL); 128 #define IPSDK_THROW(libraryName, msg) \ 130 ipsdk::LogMessageFormater msgInternalThrow(IPSDK_LIB_LOG_MSG_MANAGER(libraryName)); \ 132 msgInternalThrow msg; \ 134 catch (const ipsdk::BaseException& e) { \ 135 std::string errMsg("Exception thrown while processing message"); \ 136 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 137 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, e); \ 139 catch (const std::exception& e) { \ 140 std::string errMsg("Exception thrown while processing message"); \ 141 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 142 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, e); \ 145 std::string errMsg("Exception thrown while processing message"); \ 146 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 147 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, \ 148 ipsdk::UnHandleException()); \ 150 IPSDK_LOG_ERROR(libraryName, << msgInternalThrow.string()); \ 151 throw IPSDK_LIB_EXCEPTION(libraryName)(msgInternalThrow.string(), \ 152 BOOST_CURRENT_FUNCTION, __FILE__, __LINE__); \ 158 #define IPSDK_RETHROW(libraryName, msg, previousExcp) \ 160 ipsdk::LogMessageFormater msgInternalReThrow(IPSDK_LIB_LOG_MSG_MANAGER(libraryName)); \ 162 msgInternalReThrow msg; \ 164 catch (const ipsdk::BaseException& e) { \ 165 std::string errMsg("Exception thrown while processing message"); \ 166 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 167 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, e); \ 169 catch (const std::exception& e) { \ 170 std::string errMsg("Exception thrown while processing message"); \ 171 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 172 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, e); \ 175 std::string errMsg("Exception thrown while processing message"); \ 176 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 177 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, \ 178 ipsdk::UnHandleException()); \ 180 IPSDK_LOG_ERROR(libraryName, << msgInternalReThrow.string()); \ 181 throw IPSDK_LIB_EXCEPTION(libraryName)(msgInternalReThrow.string(), \ 182 BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, \ 189 #define IPSDK_CHECK(libraryName, bPredicate, msg) \ 191 if (!(bPredicate)) { \ 192 ipsdk::LogMessageFormater msgInternalCheck(IPSDK_LIB_LOG_MSG_MANAGER(libraryName)); \ 194 msgInternalCheck msg; \ 196 catch (const ipsdk::BaseException& e) { \ 197 std::string errMsg("Exception thrown while processing message"); \ 198 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 199 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, e); \ 201 catch (const std::exception& e) { \ 202 std::string errMsg("Exception thrown while processing message"); \ 203 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 204 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, e); \ 207 std::string errMsg("Exception thrown while processing message"); \ 208 LOG4CPLUS_ERROR(ipsdk::getBaseLogger(), errMsg); \ 209 throw ipsdk::BaseException(errMsg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, \ 210 ipsdk::UnHandleException()); \ 212 IPSDK_LOG_ERROR(libraryName, << msgInternalCheck.string()); \ 213 throw IPSDK_LIB_EXCEPTION(libraryName)(msgInternalCheck.string(), \ 214 BOOST_CURRENT_FUNCTION, __FILE__, __LINE__); \ 223 #endif // __IPSDKUTIL_BASELOG_H__ IPSDKUTIL_API log4cplus::Logger & getBaseLogger()
Recovery of main logger associated to library.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
IPSDKUTIL_API const std::string & getBaseLoggerName()
Recovery of main logger name associated to library.
Utility functions for logging system management.
#define IPSDKUTIL_API
Import/Export macro for library IPSDKUtil.
Definition: IPSDKUtilExports.h:27
Definition of import/export macro for library.