diff options
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | cmake/Modules/FindLog4cpp.cmake | 23 | ||||
-rw-r--r-- | cmake/Modules/GrMiscUtils.cmake | 2 | ||||
-rw-r--r-- | docs/doxygen/other/logger.dox | 25 | ||||
-rw-r--r-- | gnuradio-core/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-core/gnuradio-core.conf.in | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/CMakeLists.txt | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_logger.h | 46 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/qa_gr_logger.cc | 13 |
9 files changed, 54 insertions, 68 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index edfd269a2e..2c0a4e9096 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,10 +231,7 @@ endif(ENABLE_VOLK) # Handle gr_log enable/disable GR_LOGGING() -set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY}) -message("First Libs: ${LOG4CPP_LIBRARIES}") -message("First Lib: ${LOG4CPP_LIBRARY}") ######################################################################## # Distribute the README file ######################################################################## diff --git a/cmake/Modules/FindLog4cpp.cmake b/cmake/Modules/FindLog4cpp.cmake index 0b7208630f..fc314c61a5 100644 --- a/cmake/Modules/FindLog4cpp.cmake +++ b/cmake/Modules/FindLog4cpp.cmake @@ -23,19 +23,17 @@ find_library(LOG4CPP_LIBRARY PATHS /usr/lib /usr/local/lib /opt/local/lib ) -message("#####################") -message("LOG INCLEUDE :${LOG4CPP_INCLUDE_DIR}") -message("LOG LIBRARY :${LOG4CPP_LIBRARY}") - - -message("#####################") if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY) set(LOG4CPP_FOUND TRUE) - set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} ) + set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIRS ${LOG4CPP_INCLUDE_DIR} CACHE INTERNAL "" FORCE) else () - set(LOG4CPP_FOUND FALSE) - set(LOG4CPP_LIBRARIES ) + set(LOG4CPP_FOUND FALSE CACHE INTERNAL "" FORCE) + set(LOG4CPP_LIBRARY "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIR "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) endif () if (LOG4CPP_FOUND) @@ -49,10 +47,7 @@ else () endif () endif () -message("internal libs: ${LOG4CPP_LIBRARIES}") - mark_as_advanced( - LOG4CPP_LIBRARY LOG4CPP_LIBRARIES - LOG4CPP_INCLUDE_DIR - ) + LOG4CPP_INCLUDE_DIRS +) diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake index 65b0b5a8c8..69ff1f5ddc 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -220,8 +220,6 @@ endfunction(GR_GEN_TARGET_DEPS) function(GR_LOGGING) find_package(Log4cpp) - message(STATUS "LOG4CPP_LIBRARIES First set to ${LOG4CPP_LIBRARIES}.") - OPTION(ENABLE_GR_LOG "Use gr_logger" ON) if(ENABLE_GR_LOG) # If gr_logger is enabled, make it usable diff --git a/docs/doxygen/other/logger.dox b/docs/doxygen/other/logger.dox index e0f8ac4965..9a97172ed0 100644 --- a/docs/doxygen/other/logger.dox +++ b/docs/doxygen/other/logger.dox @@ -18,7 +18,7 @@ Logging is useful for blocks to print out certain amounts of data at different levels. These levels are: <pre> - DEBUG < INFO < WARN < TRACE < ERROR < ALERT < CRIT < FATAL <EMERG + DEBUG < INFO < WARN < TRACE < ERROR < ALERT < CRIT < FATAL < EMERG </pre> @@ -45,14 +45,14 @@ stream or file. The four main configure options are: <pre> - log_level = all - debug_level = all + log_level = debug + debug_level = debug log_file = stdout debug_file = stderr </pre> This establishes the two loggers as having access to all levels of -logging events (TRACE through FATAL). They are also configured not to +logging events (DEBUG through EMERG). They are also configured not to use files but instead output to the console. The standard logger will output to standard out while the debug logger outputs to standard error. @@ -114,20 +114,21 @@ The various logging macros are defined in gr_logger.h. Here are some simple examples of using them: \code - GR_LOG_TRACE(LOG, "TRACE message"); GR_LOG_DEBUG(LOG, "DEBUG message"); GR_LOG_INFO(LOG, "INFO message"); + GR_LOG_NOTICE(LOG, "NOTICE message"); GR_LOG_WARN(LOG, "WARNING message"); GR_LOG_ERROR(LOG, "ERROR message"); - GR_FATAL(LOG, "FATAL message"); - GR_ERRORIF(LOG, a>b, "CONDITIONAL ERROR message"); - GR_ASSERT(LOG, a>b, "ASSERT error message"); + GR_LOG_CRIT(LOG, "CRIT message"); + GR_LOG_ALERT(LOG, "ALERT message"); + GR_LOG_FATAL(LOG, "FATAL message"); + GR_LOG_EMERG(LOG, "EMERG message"); \endcode If the logger is not enabled, then these macros become nops and do nothing (and d_logger and d_debug_logger are NULL pointers). If logging is enabled but the log4cpp library is not found, then TRACE, -DEBUG, and INFO levels go to stdout and the rest to stderr. +INFO, and NOTICE levels go to stdout and the rest to stderr. \subsection adv_config Advanced Configuration Options @@ -151,7 +152,7 @@ For the following examples, we will assume that our local \code [LOG] log_config = /opt/gr/etc/gnuadio/gr_log_default.xml -log_level = All +log_level = debug debug_level = Off \endcode @@ -165,7 +166,7 @@ specified in the XML file. Here, we have turned on the standard logger (d_debug_logger). So even if the debug logger is used in the code, it will not actually output any information. Conversely, any level of output passed to the standard logger will output because we have -turned this value to "all." +turned this value to the lowest level "debug." If both an XML configuration file is set and the "log_file" or "debug_file" options are set at the same time, both systems are @@ -199,6 +200,6 @@ except we would use "gr_log_debug." in the GR_LOG_GETLOGGER call): This creates a pointer called LOG (which is instantiated as a log4cpp:LoggerPtr in the macro) that we can now use locally as the -input to our logging macros like 'GR_LOG_TRACE(LOG, "message")'. +input to our logging macros like 'GR_LOG_INFO(LOG, "message")'. */ diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index 97ca11e0a9..97e94cbc16 100644 --- a/gnuradio-core/CMakeLists.txt +++ b/gnuradio-core/CMakeLists.txt @@ -63,7 +63,6 @@ GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS ) list(APPEND GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_BINARY_DIR}) -message("GNURADIO_CORE_INCLUDE_DIRS ARE: ${GNURADIO_CORE_INCLUDE_DIRS}") GR_SET_GLOBAL(GNURADIO_CORE_SWIG_INCLUDE_DIRS ${GNURADIO_CORE_INCLUDE_DIRS} diff --git a/gnuradio-core/gnuradio-core.conf.in b/gnuradio-core/gnuradio-core.conf.in index 4de97e1ea5..25abedb253 100644 --- a/gnuradio-core/gnuradio-core.conf.in +++ b/gnuradio-core/gnuradio-core.conf.in @@ -12,9 +12,9 @@ max_messages = 100 [LOG] # Levels can be (case insensitive): -# trace, debug, info, warn, error, fatal -log_level = all -debug_level = all +# DEBUG, INFO, WARN, TRACE, ERROR, ALERT, CRIT, FATAL, EMERG +log_level = debug +debug_level = emerg # These file names can either be 'stdout' to output to standard output # or 'stderr' to output to standard error. Any other string will diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index b69b858ad0..da6de8ed1b 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -82,9 +82,6 @@ link_directories(${LOG4CPP_LIBRARY_DIRS}) #if(LOG4CPP_FOUND) # add_definitions(-DENABLE_GR_LOG) #endif(LOG4CPP_FOUND) -message("******************************************") -message("LOG4CPP LIBRARIES are ${LOG4CPP_LIBRARIES}") -message("******************************************") list(APPEND gnuradio_core_libs gruel diff --git a/gnuradio-core/src/lib/runtime/gr_logger.h b/gnuradio-core/src/lib/runtime/gr_logger.h index 2aadc3c936..13f31d60b8 100644 --- a/gnuradio-core/src/lib/runtime/gr_logger.h +++ b/gnuradio-core/src/lib/runtime/gr_logger.h @@ -70,35 +70,35 @@ typedef std::string gr_logger_ptr; #define GR_GET_LEVEL(name, level) #define GR_LOG_GET_LEVEL(logger, level) #define GR_ADD_CONSOLE_APPENDER(logger,target,pattern) -#define GR_LOG_ADD_CONSOLE_APPENDER(logger,,target,pattern) +#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern) #define GR_ADD_FILE_APPENDER(name,filename,append,pattern) #define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern) #define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern) #define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern) #define GR_GET_LOGGER_NAMES(names) #define GR_RESET_CONFIGURATION() -#define GR_DEBUG(name, msg) std::cout<<"DEBUG:"<<msg<<std::endl -#define GR_INFO(name, msg) std::cout<<"INFO:"<<msg<<std::endl -#define GR_NOTICE(name, msg) std::cout<<"NOTICE:"<<msg<<std::endl -#define GR_WARN(name, msg) std::cerr<<"WARN:"<<msg<<std::endl -#define GR_ERROR(name, msg) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_ALERT(name, msg) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_CRIT(name, msg) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_FATAL(name, msg) std::cerr<<"FATAL:"<<msg<<std::endl -#define GR_EMERG(name, msg) std::cerr<<"EMERG:"<<msg<<std::endl -#define GR_ERRORIF(name, cond, msg) if((cond)) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_ASSERT(name, cond, msg) if(!(cond)) std::cerr<<"ERROR:"<<msg<<std::endl; assert(cond) -#define GR_LOG_DEBUG(logger, msg) std::cout<<"DEBUG:"<<msg<<std::endl -#define GR_LOG_INFO(logger, msg) std::cout<<"INFO:"<<msg<<std::endl -#define GR_LOG_NOTICE(logger, msg) std::cout<<"NOTICE:"<<msg<<std::endl -#define GR_LOG_WARN(logger, msg) std::cerr<<"WARN:"<<msg<<std::endl -#define GR_LOG_ERROR(logger, msg) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_LOG_ALERT(logger, msg) std::cerr<<"ALERT:"<<msg<<std::endl -#define GR_LOG_CRIT(logger, msg) std::cerr<<"CRIT:"<<msg<<std::endl -#define GR_LOG_FATAL(logger, msg) std::cerr<<"FATAL:"<<msg<<std::endl -#define GR_LOG_EMERG(logger, msg) std::cerr<<"EMERG:"<<msg<<std::endl -#define GR_LOG_ERRORIF(logger, cond, msg) if((cond)) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_LOG_ASSERT(logger, cond, msg) std::cerr<<"ERROR:"<<msg<<std::endl; assert(cond) +#define GR_DEBUG(name, msg) std::cout<<"DEBUG: "<<msg<<std::endl +#define GR_INFO(name, msg) std::cout<<"INFO: "<<msg<<std::endl +#define GR_NOTICE(name, msg) std::cout<<"NOTICE: "<<msg<<std::endl +#define GR_WARN(name, msg) std::cerr<<"WARN: "<<msg<<std::endl +#define GR_ERROR(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_ALERT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_CRIT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_FATAL(name, msg) std::cerr<<"FATAL: "<<msg<<std::endl +#define GR_EMERG(name, msg) std::cerr<<"EMERG: "<<msg<<std::endl +#define GR_ERRORIF(name, cond, msg) if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_ASSERT(name, cond, msg) if(!(cond)) std::cerr<<"ERROR: "<<msg<<std::endl; assert(cond) +#define GR_LOG_DEBUG(logger, msg) std::cout<<"DEBUG: "<<msg<<std::endl +#define GR_LOG_INFO(logger, msg) std::cout<<"INFO: "<<msg<<std::endl +#define GR_LOG_NOTICE(logger, msg) std::cout<<"NOTICE: "<<msg<<std::endl +#define GR_LOG_WARN(logger, msg) std::cerr<<"WARN: "<<msg<<std::endl +#define GR_LOG_ERROR(logger, msg) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_LOG_ALERT(logger, msg) std::cerr<<"ALERT: "<<msg<<std::endl +#define GR_LOG_CRIT(logger, msg) std::cerr<<"CRIT: "<<msg<<std::endl +#define GR_LOG_FATAL(logger, msg) std::cerr<<"FATAL: "<<msg<<std::endl +#define GR_LOG_EMERG(logger, msg) std::cerr<<"EMERG: "<<msg<<std::endl +#define GR_LOG_ERRORIF(logger, cond, msg) if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_LOG_ASSERT(logger, cond, msg) std::cerr<<"ERROR: "<<msg<<std::endl; assert(cond) #else /* HAVE_LOG4CPP */ // Second configuration...logging to log4cpp diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc index e409c6aea7..a8e4a1d766 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc +++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc @@ -41,13 +41,12 @@ qa_gr_logger::t1() GR_LOG_GETLOGGER(LOG,"main"); GR_ADD_CONSOLE_APPENDER("main","cout","%d{%H:%M:%S} : %m%n"); - GR_LOG_NOTICE(LOG,"test from c++ 1"); - GR_LOG_DEBUG(LOG,"test from c++ 1"); - GR_LOG_INFO(LOG,"test from c++ 1"); - GR_LOG_WARN(LOG,"test from c++ 1"); - GR_LOG_ERROR(LOG,"test from c++ 1"); - GR_LOG_FATAL(LOG,"test from c++ 1"); - GR_LOG_ERRORIF(LOG,2>1,"test from c++ 1"); + GR_LOG_NOTICE(LOG,"test from c++ NOTICE"); + GR_LOG_DEBUG(LOG,"test from c++ DEBUG"); + GR_LOG_INFO(LOG,"test from c++ INFO"); + GR_LOG_WARN(LOG,"test from c++ WARN"); + GR_LOG_ERROR(LOG,"test from c++ ERROR"); + GR_LOG_FATAL(LOG,"test from c++ FATAL"); CPPUNIT_ASSERT(true); #endif } |