Changeset 9737 for source/ariba/utility/logging/Logging.h
- Timestamp:
- Apr 7, 2011, 4:36:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/logging/Logging.h
r7748 r9737 45 45 46 46 #ifdef HAVE_LOG4CXX_LOGGER_H 47 #include <log4cxx/logger.h>48 #include <log4cxx/basicconfigurator.h>47 #include <log4cxx/logger.h> 48 #include <log4cxx/basicconfigurator.h> 49 49 #endif // HAVE_LOG4CXX_LOGGER_H 50 50 51 51 #ifdef LOGCOLORS 52 53 52 #define colorDefault { std::cout << "\033[0m"; } /*reset*/ 54 53 #define colorDebug { std::cout << "\033[0;33m"; } /*cyan*/ … … 58 57 59 58 #else 60 61 59 #define colorDefault { } 62 60 #define colorDebug { } … … 64 62 #define colorWarn { } 65 63 #define colorError { } 66 67 64 #endif // ENABLE_LOGCOLORS 68 65 … … 83 80 #define logging_fatal(x) {colorError; LOG4CXX_FATAL(logger,x); colorDefault; exit(-1); } 84 81 82 #define logging_rootlevel_debug() {log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug()); } 83 #define logging_rootlevel_info() {log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getInfo() ); } 84 #define logging_rootlevel_warn() {log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getWarn() ); } 85 #define logging_rootlevel_error() {log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getError()); } 86 87 #define logging_classlevel_debug(x) {log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(x)); if(logger != NULL) logger->setLevel(log4cxx::Level::getDebug()); } 88 #define logging_classlevel_info(x) {log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(x)); if(logger != NULL) logger->setLevel(log4cxx::Level::getInfo()); } 89 #define logging_classlevel_warn(x) {log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(x)); if(logger != NULL) logger->setLevel(log4cxx::Level::getWarn()); } 90 #define logging_classlevel_error(x) {log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(x)); if(logger != NULL) logger->setLevel(log4cxx::Level::getError()); } 91 85 92 #else // HAVE_LOG4CXX_LOGGER_H 86 93 87 94 #define use_logging_h(x) 88 89 95 #define use_logging_cpp(x) 90 96 91 97 #define logging_stdout(x) std::cout << x << std::endl; 92 98 93 #define logging_trace(x) 94 #define logging_debug(x) {colorDebug; logging_stdout(x); colorDefault; } 95 #define logging_info(x) {colorInfo; logging_stdout(x); colorDefault; } 96 #define logging_warn(x) {colorWarn; logging_stdout(x); colorDefault; } 97 #define logging_error(x) {colorError; logging_stdout(x); colorDefault; } 98 #define logging_fatal(x) {colorError; logging_stdout(x); colorDefault; exit(-1); } 99 static int __loglevel__ = 2; //default is info 100 101 #define logging_trace(x) { logging_stdout(x); } 102 #define logging_debug(x) {if(__loglevel__ <= 1){ colorDebug; logging_stdout(x); colorDefault; }} 103 #define logging_info(x) {if(__loglevel__ <= 2){ colorInfo; logging_stdout(x); colorDefault; }} 104 #define logging_warn(x) {if(__loglevel__ <= 3){ colorWarn; logging_stdout(x); colorDefault; }} 105 #define logging_error(x) { return; colorError; logging_stdout(x); colorDefault; } 106 #define logging_fatal(x) { return; colorError; logging_stdout(x); colorDefault; exit(-1); } 107 108 #define logging_rootlevel_debug() {__loglevel__ = 1;} 109 #define logging_rootlevel_info() {__loglevel__ = 2;} 110 #define logging_rootlevel_warn() {__loglevel__ = 3;} 111 #define logging_rootlevel_error() {__loglevel__ = 4;} 112 113 #define logging_classlevel_debug(x) {std::cout << "individual class logging only available with log4cxx library" << std::endl;} 114 #define logging_classlevel_info(x) {std::cout << "individual class logging only available with log4cxx library" << std::endl;} 115 #define logging_classlevel_warn(x) {std::cout << "individual class logging only available with log4cxx library" << std::endl;} 116 #define logging_classlevel_error(x) {std::cout << "individual class logging only available with log4cxx library" << std::endl;} 99 117 100 118 #endif // HAVE_LOG4CXX_LOGGER_H
Note:
See TracChangeset
for help on using the changeset viewer.