diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-03-13 18:02:42 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-03-13 18:02:42 -0400 |
commit | 1c9d67fc220737873728310bd679d9e9cfab470a (patch) | |
tree | 5fbf8c157da3e938d9b90ebe720f3efbcef39215 | |
parent | 1d8d1f111c41862d877686a89344a4a74f146cee (diff) | |
parent | 1bacc04f7a8f2f9c868a9934624683c7cefb2300 (diff) |
Merge branch 'master' into next
Conflicts:
gr-audio/lib/CMakeLists.txt
gr-blocks/include/blocks/CMakeLists.txt
gr-blocks/include/blocks/socket_pdu.h
gr-blocks/lib/CMakeLists.txt
gr-blocks/swig/blocks_swig.i
gr-comedi/src/CMakeLists.txt
gr-howto-write-a-block/lib/CMakeLists.txt
gr-noaa/lib/CMakeLists.txt
gr-qtgui/lib/CMakeLists.txt
gr-uhd/lib/CMakeLists.txt
gr-vocoder/lib/CMakeLists.txt
gr-wavelet/lib/CMakeLists.txt
54 files changed, 1555 insertions, 510 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cc507d85ea..64d9d0fb4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ if(MSVC) ) add_definitions(-DHAVE_CONFIG_H) add_definitions(/MP) #build with multiple processors + add_definitions(/bigobj) #allow for larger object files endif(MSVC) ######################################################################## diff --git a/cmake/Modules/FindLog4cpp.cmake b/cmake/Modules/FindLog4cpp.cmake new file mode 100644 index 0000000000..fc314c61a5 --- /dev/null +++ b/cmake/Modules/FindLog4cpp.cmake @@ -0,0 +1,53 @@ +# - Find Log4cpp +# Find the native LOG4CPP includes and library +# +# LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc. +# LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP. +# LOG4CPP_FOUND - True if LOG4CPP found. + + +if (LOG4CPP_INCLUDE_DIR) + # Already in cache, be silent + set(LOG4CPP_FIND_QUIETLY TRUE) +endif () + +find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh + /opt/local/include + /usr/local/include + /usr/include +) + +set(LOG4CPP_NAMES log4cpp) +find_library(LOG4CPP_LIBRARY + NAMES ${LOG4CPP_NAMES} + PATHS /usr/lib /usr/local/lib /opt/local/lib +) + + +if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY) + set(LOG4CPP_FOUND TRUE) + set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIRS ${LOG4CPP_INCLUDE_DIR} CACHE INTERNAL "" FORCE) +else () + 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) + if (NOT LOG4CPP_FIND_QUIETLY) + message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}") + endif () +else () + if (LOG4CPP_FIND_REQUIRED) + message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.") + message(FATAL_ERROR "Could NOT find LOG4CPP library") + endif () +endif () + +mark_as_advanced( + LOG4CPP_LIBRARIES + LOG4CPP_INCLUDE_DIRS +) diff --git a/cmake/Modules/FindLog4cxx.cmake b/cmake/Modules/FindLog4cxx.cmake deleted file mode 100644 index b1e4f6f1f7..0000000000 --- a/cmake/Modules/FindLog4cxx.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# CMake module to find LOG4CXX library - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_LOG4CXX liblog4cxx) - -FIND_PATH( - LOG4CXX_INCLUDE_DIRS - NAMES log4cxx/log4cxx.h - HINTS $ENV{LOG4CXX_DIR}/include - ${PC_LOG4CXX_INCLUDE_DIRS} - PATHS /usr/local/include - /usr/include -) - -FIND_LIBRARY( - LOG4CXX_LIBRARIES - NAMES log4cxx - HINTS $ENV{LOG4CXX_DIR}/lib - ${PC_LOG4CXX_LIBRARIES} - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LOG4CXX DEFAULT_MSG LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) -MARK_AS_ADVANCED(LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake index c7fe77bc88..69ff1f5ddc 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -218,36 +218,37 @@ endfunction(GR_GEN_TARGET_DEPS) # Can manually set with -DENABLE_GR_LOG=0|1 ######################################################################## function(GR_LOGGING) - find_package(Log4cxx) + find_package(Log4cpp) OPTION(ENABLE_GR_LOG "Use gr_logger" ON) if(ENABLE_GR_LOG) # If gr_logger is enabled, make it usable add_definitions( -DENABLE_GR_LOG ) - # also test LOG4CXX; if we have it, use this version of the logger + # also test LOG4CPP; if we have it, use this version of the logger # otherwise, default to the stdout/stderr model. - if(LOG4CXX_FOUND) - SET(HAVE_LOG4CXX True CACHE INTERNAL "" FORCE) - add_definitions( -DHAVE_LOG4CXX ) - else(LOG4CXX_FOUND) - SET(HAVE_LOG4CXX False CACHE INTERNAL "" FORCE) - SET(LOG4CXX_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) - SET(LOG4CXX_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) - SET(LOG4CXX_LIBRARIES "" CACHE INTERNAL "" FORCE) - endif(LOG4CXX_FOUND) + if(LOG4CPP_FOUND) + SET(HAVE_LOG4CPP True CACHE INTERNAL "" FORCE) + add_definitions( -DHAVE_LOG4CPP ) + else(not LOG4CPP_FOUND) + SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE) + SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) + endif(LOG4CPP_FOUND) SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE) else(ENABLE_GR_LOG) - SET(HAVE_LOG4CXX False CACHE INTERNAL "" FORCE) - SET(LOG4CXX_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) - SET(LOG4CXX_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) - SET(LOG4CXX_LIBRARIES "" CACHE INTERNAL "" FORCE) + SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE) + SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) endif(ENABLE_GR_LOG) message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.") - message(STATUS "HAVE_LOG4CXX set to ${HAVE_LOG4CXX}.") + message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.") + message(STATUS "LOG4CPP_LIBRARIES set to ${LOG4CPP_LIBRARIES}.") endfunction(GR_LOGGING) diff --git a/config.h.in b/config.h.in index e46177e863..5e73835ea8 100644 --- a/config.h.in +++ b/config.h.in @@ -26,6 +26,6 @@ #cmakedefine GR_PERFORMANCE_COUNTERS #cmakedefine GR_CTRLPORT #cmakedefine ENABLE_GR_LOG -#cmakedefine HAVE_LOG4CXX +#cmakedefine HAVE_LOG4CPP #endif /* GNURADIO_CONFIG_H */ diff --git a/docs/doxygen/other/extra_pages.dox b/docs/doxygen/other/extra_pages.dox index 44cdf9d483..94c741864d 100644 --- a/docs/doxygen/other/extra_pages.dox +++ b/docs/doxygen/other/extra_pages.dox @@ -80,7 +80,7 @@ audio-osx and audio-windows to be either satisfied or built. \li comedilib (>= 0.8) http://www.comedi.org/ \subsection dep_gr_log gr-log: Logging Tools (Optional) -\li log4cxx (>= 0.10.0) http://logging.apache.org/log4cxx +\li log4cpp (>= 1.0) http://log4cpp.sourceforge.net/ \section build_gr_cmake Building GNU Radio diff --git a/docs/doxygen/other/logger.dox b/docs/doxygen/other/logger.dox index f98a64657b..9a97172ed0 100644 --- a/docs/doxygen/other/logger.dox +++ b/docs/doxygen/other/logger.dox @@ -4,20 +4,23 @@ GNU Radio has a logging interface to enable various levels of logging information to be printed to the console or a file. The logger derives -from log4cxx (http://logging.apache.org/log4cxx) which is readily +from log4cpp (http://log4cpp.sourceforge.net/) which is readily available in most Linux distributions. This is an optional dependency and GNU Radio will work without it. When configuring GNU Radio, the -DENABLE_GR_LOG=On|Off option to cmake will allow the user to toggle use of the logger on and off. The logger -defaults to "on" and will use log4cxx if it is available. If log4cxx +defaults to "on" and will use log4cpp if it is available. If log4cpp is not found, the default logging will output to standard output or standard error, depending on the level of the log message. Logging is useful for blocks to print out certain amounts of data at different levels. These levels are: - TRACE < DEBUG < INFO < WARN < ERROR < FATAL +<pre> + DEBUG < INFO < WARN < TRACE < ERROR < ALERT < CRIT < FATAL < EMERG +</pre> + The order here determines the level of output. These levels are hierarchical in that specifying any level also includes any level @@ -42,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. @@ -111,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 log4cxx library is not found, then TRACE, -DEBUG, and INFO levels go to stdout and the rest to stderr. +logging is enabled but the log4cpp library is not found, then TRACE, +INFO, and NOTICE levels go to stdout and the rest to stderr. \subsection adv_config Advanced Configuration Options @@ -133,11 +137,10 @@ If not using the simplified settings discussed above, where we can direct the logger messages to either a file or one of the standard outputs, we must use a more complicated configuration file. We do this by specifying the "log_config" option in the [LOG] section. The -log4cxx documentation (found through -http://logging.apache.org/log4cxx/) will provide more information on -how configuration works and looks. Mostly, a default configuration -script provided with GNU Radio can be used. After installation, the -default configuration script is located at: +log4cpp documentation will provide more information on how +configuration works and looks. Mostly, a default configuration script +provided with GNU Radio can be used. After installation, the default +configuration script is located at: <pre> $prefix/etc/gnuradio/gr_log_default.xml @@ -149,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 @@ -163,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 @@ -196,7 +199,7 @@ except we would use "gr_log_debug." in the GR_LOG_GETLOGGER call): \endcode This creates a pointer called LOG (which is instantiated as a -log4cxx:LoggerPtr in the macro) that we can now use locally as the -input to our logging macros like 'GR_LOG_TRACE(LOG, "message")'. +log4cpp:LoggerPtr in the macro) that we can now use locally as the +input to our logging macros like 'GR_LOG_INFO(LOG, "message")'. */ diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index c7ecb3d6ab..60fd11dd31 100644 --- a/gnuradio-core/CMakeLists.txt +++ b/gnuradio-core/CMakeLists.txt @@ -44,6 +44,7 @@ GR_REGISTER_COMPONENT("gnuradio-core" ENABLE_GR_CORE ) include(GrMiscUtils) + GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/runtime ${CMAKE_CURRENT_BINARY_DIR}/src/lib/general @@ -59,6 +60,8 @@ GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/hier ) +list(APPEND GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_BINARY_DIR}) + GR_SET_GLOBAL(GNURADIO_CORE_SWIG_INCLUDE_DIRS ${GNURADIO_CORE_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig @@ -144,13 +147,13 @@ install( COMPONENT "core_runtime" ) -if(ENABLE_GR_LOG AND HAVE_LOG4CXX) +if(ENABLE_GR_LOG AND HAVE_LOG4CPP) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_log_default.xml DESTINATION ${GR_CONF_DIR}/gnuradio COMPONENT "core_runtime" ) -endif(ENABLE_GR_LOG AND HAVE_LOG4CXX) +endif(ENABLE_GR_LOG AND HAVE_LOG4CPP) ######################################################################## # Add subdirectories diff --git a/gnuradio-core/gnuradio-core.conf.in b/gnuradio-core/gnuradio-core.conf.in index 0db837a377..d41801aa23 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 89371a8b80..72b9f9bdeb 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -66,25 +66,25 @@ link_directories( ${FFTW3F_LIBRARY_DIRS} ) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Setup library ######################################################################## -# Only use if log4cxx is installed +# Only use if log4cpp is installed # Define ENABLE_GR_LOG so .h and .cc files can turn actual # logging and insert dummy functions. -#if(LOG4CXX_FOUND) +#if(LOG4CPP_FOUND) # add_definitions(-DENABLE_GR_LOG) -#endif(LOG4CXX_FOUND) +#endif(LOG4CPP_FOUND) list(APPEND gnuradio_core_libs gruel ${Boost_LIBRARIES} ${FFTW3F_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) if(FFTW3F_THREADS_LIBRARIES) @@ -161,6 +161,6 @@ include_directories(${CPPUNIT_INCLUDE_DIRS}) link_directories(${CPPUNIT_LIBRARY_DIRS}) add_library(test-gnuradio-core SHARED ${test_gnuradio_core_sources}) -target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CXX_LIBRARIES}) +target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES}) endif(ENABLE_TESTING) diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index 2ff9cfb750..cb38df27a8 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2009,2010 Free Software Foundation, Inc. + * Copyright 2004,2009,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -53,7 +53,7 @@ gr_block::gr_block (const std::string &name, global_block_registry.register_primitive(alias(), this); #ifdef ENABLE_GR_LOG -#ifdef HAVE_LOG4CXX +#ifdef HAVE_LOG4CPP gr_prefs *p = gr_prefs::singleton(); std::string config_file = p->get_string("LOG", "log_config", ""); std::string log_level = p->get_string("LOG", "log_level", "off"); @@ -67,13 +67,13 @@ gr_block::gr_block (const std::string &name, GR_LOG_SET_LEVEL(LOG, log_level); if(log_file.size() > 0) { if(log_file == "stdout") { - GR_LOG_ADD_CONSOLE_APPENDER(LOG, "gr::log :%p: %c{1} - %m%n", "System.out"); + GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cout","gr::log :%p: %c{1} - %m%n"); } else if(log_file == "stderr") { - GR_LOG_ADD_CONSOLE_APPENDER(LOG, "gr::log :%p: %c{1} - %m%n", "System.err"); + GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cerr","gr::log :%p: %c{1} - %m%n"); } else { - GR_LOG_ADD_FILE_APPENDER(LOG, "%r :%p: %c{1} - %m%n", log_file, ""); + GR_LOG_ADD_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n"); } } d_logger = LOG; @@ -82,17 +82,17 @@ gr_block::gr_block (const std::string &name, GR_LOG_SET_LEVEL(DLOG, debug_level); if(debug_file.size() > 0) { if(debug_file == "stdout") { - GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "gr::debug :%p: %c{1} - %m%n", "System.out"); + GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "cout","gr::debug :%p: %c{1} - %m%n"); } else if(debug_file == "stderr") { - GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "gr::debug :%p: %c{1} - %m%n", "System.err"); + GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "cerr", "gr::debug :%p: %c{1} - %m%n"); } else { - GR_LOG_ADD_FILE_APPENDER(DLOG, "%r :%p: %c{1} - %m%n", debug_file, ""); + GR_LOG_ADD_FILE_APPENDER(DLOG, debug_file, true, "%r :%p: %c{1} - %m%n"); } } d_debug_logger = DLOG; -#endif /* HAVE_LOG4CXX */ +#endif /* HAVE_LOG4CPP */ #else /* ENABLE_GR_LOG */ d_logger = NULL; d_debug_logger = NULL; diff --git a/gnuradio-core/src/lib/runtime/gr_logger.cc b/gnuradio-core/src/lib/runtime/gr_logger.cc index e337920a33..530c66f964 100644 --- a/gnuradio-core/src/lib/runtime/gr_logger.cc +++ b/gnuradio-core/src/lib/runtime/gr_logger.cc @@ -21,63 +21,70 @@ */ /******************************************************************************* -* Copyright 2011 Johns Hopkins University Applied Physics Lab * Author: Mark Plett * Description: -* The gr_log module wraps the log4cxx library for logging in gnuradio. +* The gr_log module wraps the log4cpp library for logging in gnuradio. *******************************************************************************/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +//#ifdef HAVE_CONFIG_H +//#include "config.h" +//#endif #include <gr_logger.h> #include <stdexcept> #include <algorithm> #ifdef ENABLE_GR_LOG -#ifdef HAVE_LOG4CXX +#ifdef HAVE_LOG4CPP bool gr_logger_configured(false); void logger_load_config(const std::string &config_filename) { - if(!gr_logger_configured) { + if(!gr_logger_configured){ gr_logger_configured = true; - if(config_filename.size() > 0) { - if(config_filename.find(".xml") != std::string::npos) { - log4cxx::xml::DOMConfigurator::configure(config_filename); - } - else { - log4cxx::PropertyConfigurator::configure(config_filename); - } - } - } + if(config_filename.size() != 0) { + try + { + log4cpp::PropertyConfigurator::configure(config_filename); + } + catch( log4cpp::ConfigureFailure &e ) + { + std::cout << "Logger config failed :" << e.what() << std::endl; + } + }; + }; } void logger_load_config_and_watch(const std::string &config_filename, unsigned int watch_period) { - if(!gr_logger_configured) { +// NOTE:: NEEDS CODE TO WATCH FILE HERE + if(!gr_logger_configured){ gr_logger_configured = true; - if(config_filename.size() > 0) { - if(config_filename.find(".xml") != std::string::npos) { - log4cxx::xml::DOMConfigurator::configureAndWatch(config_filename, watch_period); - } - else { - log4cxx::PropertyConfigurator::configureAndWatch(config_filename, watch_period); - } - } - } + if(config_filename.size() != 0) { + try + { + log4cpp::PropertyConfigurator::configure(config_filename); + } + catch( log4cpp::ConfigureFailure &e ) + { + std::cout << "Logger config failed :" << e.what() << std::endl; + } + }; + }; } void -logger_reset_config(void) -{ - log4cxx::LogManager::resetConfiguration(); - gr_logger_configured=false; +logger_reset_config(void){ + std::vector<log4cpp::Category*> *loggers = log4cpp::Category::getCurrentCategories(); + std::vector<log4cpp::Category*>::iterator logger = loggers->begin(); +// We can't destroy categories but we can neuter them by removing all appenders. + for (;logger!=loggers->end();logger++){ + (*logger)->removeAllAppenders(); + }; } void @@ -85,105 +92,113 @@ logger_set_level(gr_logger_ptr logger, const std::string &level) { std::string nocase = level; std::transform(level.begin(), level.end(), nocase.begin(), ::tolower); - - if(nocase == "off") - logger_set_level(logger, log4cxx::Level::getOff()); - else if(nocase == "all") - logger_set_level(logger, log4cxx::Level::getAll()); - else if(nocase == "trace") - logger_set_level(logger, log4cxx::Level::getTrace()); + + if(nocase == "off" || nocase == "notset") + logger_set_level(logger, log4cpp::Priority::NOTSET); else if(nocase == "debug") - logger_set_level(logger, log4cxx::Level::getDebug()); + logger_set_level(logger, log4cpp::Priority::DEBUG); else if(nocase == "info") - logger_set_level(logger, log4cxx::Level::getInfo()); + logger_set_level(logger, log4cpp::Priority::INFO); + else if(nocase == "notice") + logger_set_level(logger, log4cpp::Priority::NOTICE); else if(nocase == "warn") - logger_set_level(logger, log4cxx::Level::getWarn()); + logger_set_level(logger, log4cpp::Priority::WARN); else if(nocase == "error") - logger_set_level(logger, log4cxx::Level::getError()); - else if(nocase == "fatal") - logger_set_level(logger, log4cxx::Level::getFatal()); + logger_set_level(logger, log4cpp::Priority::ERROR); + else if(nocase == "crit") + logger_set_level(logger, log4cpp::Priority::CRIT); + else if(nocase == "alert") + logger_set_level(logger, log4cpp::Priority::ALERT); + else if(nocase=="fatal") + logger_set_level(logger, log4cpp::Priority::FATAL); + else if(nocase == "all" || nocase == "emerg") + logger_set_level(logger, log4cpp::Priority::EMERG); else throw std::runtime_error("logger_set_level: Bad level type.\n"); } void -logger_set_level(gr_logger_ptr logger, log4cxx::LevelPtr level) +logger_set_level(gr_logger_ptr logger, log4cpp::Priority::Value level) { - logger->setLevel(level); + logger->setPriority(level); } void logger_get_level(gr_logger_ptr logger, std::string &level) { - log4cxx::LevelPtr levelPtr = logger->getLevel(); - if(levelPtr == log4cxx::Level::getOff()) level = "off"; - if(levelPtr == log4cxx::Level::getAll()) level = "all"; - if(levelPtr == log4cxx::Level::getTrace()) level = "trace"; - if(levelPtr == log4cxx::Level::getDebug()) level = "debug"; - if(levelPtr == log4cxx::Level::getInfo()) level = "info"; - if(levelPtr == log4cxx::Level::getWarn()) level = "warn"; - if(levelPtr == log4cxx::Level::getError()) level = "error"; - if(levelPtr == log4cxx::Level::getFatal()) level = "fatal"; + log4cpp::Priority::Value levelPtr = logger->getPriority(); + if(levelPtr == log4cpp::Priority::NOTSET) level = "noset"; + if(levelPtr == log4cpp::Priority::DEBUG) level = "debug"; + if(levelPtr == log4cpp::Priority::INFO) level = "info"; + if(levelPtr == log4cpp::Priority::NOTICE) level = "notice"; + if(levelPtr == log4cpp::Priority::WARN) level = "warn"; + if(levelPtr == log4cpp::Priority::ERROR) level = "error"; + if(levelPtr == log4cpp::Priority::CRIT) level = "crit"; + if(levelPtr == log4cpp::Priority::ALERT) level = "alert"; + if(levelPtr == log4cpp::Priority::FATAL) level = "fatal"; + if(levelPtr == log4cpp::Priority::EMERG) level = "emerg"; }; void -logger_get_level(gr_logger_ptr logger, log4cxx::LevelPtr level) +logger_get_level(gr_logger_ptr logger,log4cpp::Priority::Value level) { - level = logger->getLevel(); + level = logger->getPriority(); } void -logger_add_console_appender(gr_logger_ptr logger, std::string layout, - std::string target) +logger_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern) { - log4cxx::PatternLayout *playout = - new log4cxx::PatternLayout(layout); - log4cxx::ConsoleAppender *appender = - new log4cxx::ConsoleAppender(log4cxx::LayoutPtr(playout), target); - log4cxx::helpers::Pool p; - appender->activateOptions(p); - logger->addAppender(appender); + + log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); + log4cpp::Appender* app; + if(target=="cout") + app = new log4cpp::OstreamAppender("ConsoleAppender::",&std::cout); + else + app = new log4cpp::OstreamAppender("ConsoleAppender::",&std::cerr); + + layout->setConversionPattern(pattern); + app->setLayout(layout); + logger->setAppender(app); + } void -logger_add_file_appender(gr_logger_ptr logger, std::string layout, - std::string filename, bool append) +logger_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern) { - log4cxx::PatternLayout *playout = - new log4cxx::PatternLayout(layout); - log4cxx::FileAppender *appender = - new log4cxx::FileAppender(log4cxx::LayoutPtr(playout), filename, append); - log4cxx::helpers::Pool p; - appender->activateOptions(p); - logger->addAppender(appender); + + log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); + log4cpp::Appender* app = new + log4cpp::FileAppender("FileAppender::"+filename, + filename); + layout->setConversionPattern(pattern); + app->setLayout(layout); + logger->setAppender(app); + } void -logger_add_rollingfile_appender(gr_logger_ptr logger, std::string layout, - std::string filename, bool append, - int bkup_index, std::string filesize) +logger_add_rollingfile_appender(gr_logger_ptr logger,std::string filename, + size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern) { - log4cxx::PatternLayout *playout = - new log4cxx::PatternLayout(layout); - log4cxx::RollingFileAppender *appender = - new log4cxx::RollingFileAppender(log4cxx::LayoutPtr(playout), filename, append); - appender->setMaxBackupIndex(bkup_index); - appender->setMaxFileSize(filesize); - log4cxx::helpers::Pool p; - appender->activateOptions(p); - logger->addAppender(appender); + log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); + log4cpp::Appender* app = new + log4cpp::RollingFileAppender("RollFileAppender::"+filename,filename,filesize,bkup_index,append,mode); + layout->setConversionPattern(pattern); + app->setLayout(layout); + logger->setAppender(app); } void -logger_get_logger_names(std::vector<std::string>& names) -{ - log4cxx::LoggerList list = log4cxx::LogManager::getCurrentLoggers(); - log4cxx::LoggerList::iterator logger = list.begin(); +logger_get_logger_names(std::vector<std::string>& names){ + std::vector<log4cpp::Category*> *loggers = log4cpp::Category::getCurrentCategories(); + std::vector<log4cpp::Category*>::iterator logger = loggers->begin(); + names.clear(); - for(; logger != list.end(); logger++) { + for (;logger!=loggers->end();logger++){ names.push_back((*logger)->getName()); - } + }; + } -#endif /* HAVE_LOG4CXX */ +#endif /* HAVE_LOG4CPP */ #endif /* ENABLE_GR_LOGGER */ diff --git a/gnuradio-core/src/lib/runtime/gr_logger.h b/gnuradio-core/src/lib/runtime/gr_logger.h index 40684ec9d0..13f31d60b8 100644 --- a/gnuradio-core/src/lib/runtime/gr_logger.h +++ b/gnuradio-core/src/lib/runtime/gr_logger.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2012 Free Software Foundation, Inc. + * Copyright 2012-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,10 +21,9 @@ */ /******************************************************************************* -* Copyright 2011 Johns Hopkins University Applied Physics Lab * Author: Mark Plett * Description: -* The gr_logger module wraps the log4cxx library for logging in gnuradio +* The gr_logger module wraps the log4cpp library for logging in gnuradio *******************************************************************************/ #ifndef INCLUDED_GR_LOGGER_H @@ -33,18 +32,30 @@ /*! * \file gr_logger.h * \ingroup logging -* \brief GNURADIO logging wrapper for log4cxx library (C++ port of log4j) +* \brief GNURADIO logging wrapper for log4cpp library (C++ port of log4j) * */ +#ifndef ENABLE_GR_LOG +#include "config.h" +//#define GR_LOG_CONFIG_H +#endif + #include <gr_core_api.h> #include <assert.h> #include <iostream> +//#ifndef ENABLE_GR_LOG +//#define ENABLE_GR_LOG 1 +//#endif +//#ifndef HAVE_LOG4CPP +//#define HAVE_LOG4CPP 2 +//#endif + #ifdef ENABLE_GR_LOG // We have three configurations... first logging to stdout/stderr -#ifndef HAVE_LOG4CXX +#ifndef HAVE_LOG4CPP //#warning GR logging Enabled and using std::cout typedef std::string gr_logger_ptr; @@ -52,69 +63,70 @@ typedef std::string gr_logger_ptr; #define GR_LOG_DECLARE_LOGPTR(logger) #define GR_LOG_ASSIGN_LOGPTR(logger,name) #define GR_CONFIG_LOGGER(config) -#define GR_CONFIG_AND_WATCH_LOGGER(config) +#define GR_CONFIG_AND_WATCH_LOGGER(config,period) #define GR_LOG_GETLOGGER(logger, name) #define GR_SET_LEVEL(name, level) #define GR_LOG_SET_LEVEL(logger, level) #define GR_GET_LEVEL(name, level) #define GR_LOG_GET_LEVEL(logger, level) -#define GR_ADD_CONSOLE_APPENDER(logger,layout) -#define GR_LOG_ADD_CONSOLE_APPENDER(logger,layout) -#define GR_ADD_FILE_APPENDER(logger,layout,filename,append) -#define GR_LOG_ADD_FILE_APPENDER(logger,layout,filename,append) -#define GR_ADD_ROLLINGFILE_APPENDER(logger,layout,filename,append,bkup_index,filesize) -#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,layout,filename,append,bkup_index,filesize) +#define GR_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_TRACE(name, msg) std::cout<<"TRACE:"<<msg<<std::endl -#define GR_DEBUG(name, msg) std::cout<<"DEBUG:"<<msg<<std::endl -#define GR_INFO(name, msg) std::cout<<"INFO:"<<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_FATAL(name, msg) std::cerr<<"FATAL:"<<msg<<std::endl -#define GR_ERRORIF(name, cond, msg) if((cond)) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_ASSERT(name, cond, msg) std::cerr<<"ERROR:"<<msg<<std::endl; assert(cond) -#define GR_LOG_SET_LEVEL(logger, level) -#define GR_LOG_GET_LEVEL(logger, level) -#define GR_LOG_TRACE(logger, msg) std::cout<<"TRACE:"<<msg<<std::endl -#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_WARN(logger, msg) std::cerr<<"WARN:"<<msg<<std::endl -#define GR_LOG_ERROR(logger, msg) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_LOG_FATAL(logger, msg) std::cerr<<"FATAL:"<<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_LOG4CXX */ -// Second configuration...logging to log4cxx -//#warning GR logging Enabled and using LOG4CXX - -#include <log4cxx/logger.h> -#include <log4cxx/logmanager.h> -#include <log4cxx/basicconfigurator.h> -#include <log4cxx/xml/domconfigurator.h> -#include <log4cxx/propertyconfigurator.h> -#include <log4cxx/helpers/pool.h> -#include <log4cxx/fileappender.h> -#include <log4cxx/rollingfileappender.h> -#include <log4cxx/consoleappender.h> -#include <log4cxx/patternlayout.h> +#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 + +#include <log4cpp/Category.hh> +#include <log4cpp/PropertyConfigurator.hh> +#include <log4cpp/FileAppender.hh> +#include <log4cpp/RollingFileAppender.hh> +#include <log4cpp/OstreamAppender.hh> +#include <log4cpp/PatternLayout.hh> /*! * \brief GR_LOG macros * \ingroup logging * - * These macros wrap the standard LOG4CXX_LEVEL macros. The availablie macros + * These macros wrap the standard LOG4CPP_LEVEL macros. The availablie macros * are: - * GR_LOG_TRACE * GR_LOG_DEBUG * GR_LOG_INFO * GR_LOG_WARN + * GR_LOG_TRACE * GR_LOG_ERROR + * GR_LOG_ALERT + * GR_LOG_CRIT * GR_LOG_FATAL + * GR_LOG_EMERG */ - -typedef log4cxx::LoggerPtr gr_logger_ptr; +typedef log4cpp::Category* gr_logger_ptr; /* Macros for Programmatic Configuration */ #define GR_LOG_DECLARE_LOGPTR(logger) \ @@ -130,42 +142,42 @@ typedef log4cxx::LoggerPtr gr_logger_ptr; logger_load_config_and_watch(config,period) #define GR_LOG_GETLOGGER(logger, name) \ - log4cxx::LoggerPtr logger = gr_logger::getLogger(name); + gr_logger_ptr logger = gr_logger::getLogger(name); #define GR_SET_LEVEL(name, level){ \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - logger_set_level(logger, level);} + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_set_level(logger,level);} #define GR_LOG_SET_LEVEL(logger, level) \ logger_set_level(logger, level); #define GR_GET_LEVEL(name, level){ \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ logger_get_level(logger,level);} #define GR_LOG_GET_LEVEL(logger, level) \ logger_get_level(logger,level); -#define GR_ADD_CONSOLE_APPENDER(name,layout,terget){d \ - gr_logger_ptr logger = log4cxx::Logger::getLogger(name); \ - logger_add_console_appender(logger,layout, target);} +#define GR_ADD_CONSOLE_APPENDER(name,target,pattern){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_add_console_appender(logger,target,pattern);} -#define GR_LOG_ADD_CONSOLE_APPENDER(logger,layout,target){ \ - logger_add_console_appender(logger,layout,target);} +#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern){\ + logger_add_console_appender(logger,target,pattern);} -#define GR_ADD_FILE_APPENDER(name,layout,filename,append){\ - gr_logger_ptr logger = log4cxx::Logger::getLogger(name); \ - logger_add_file_appender(logger,layout,filename,append);} +#define GR_ADD_FILE_APPENDER(name,filename,append,pattern){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_add_file_appender(logger,filename,append,pattern);} -#define GR_LOG_ADD_FILE_APPENDER(logger,layout,filename,append){\ - logger_add_file_appender(logger,layout,filename,append);} +#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern){\ + logger_add_file_appender(logger,filename,append,pattern);} -#define GR_ADD_ROLLINGFILE_APPENDER(name,layout,filename,append,bkup_index,filesize){\ - gr_logger_ptr logger = log4cxx::Logger::getLogger(name); \ - logger_add_rollingfile_appender(logger,layout,filename,append,bkup_index,filesize);} +#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);} -#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,layout,filename,append,bkup_index,filesize){\ - logger_add_rollingfile_appender(logger,layout,filename,append,bkup_index,filesize);} +#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern){\ + logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);} #define GR_GET_LOGGER_NAMES(names){ \ logger_get_logger_names(names);} @@ -174,64 +186,94 @@ typedef log4cxx::LoggerPtr gr_logger_ptr; logger_reset_config();} /* Logger name referenced macros */ -#define GR_TRACE(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_TRACE(logger, msg);} - #define GR_DEBUG(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_DEBUG(logger, msg);} + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::DEBUG << msg << log4cpp::eol;} #define GR_INFO(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_INFO(logger, msg);} + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::INFO << msg << log4cpp::eol;} + +#define GR_NOTICE(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger << log4cpp::Priority::NOTICE << msg;} #define GR_WARN(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_WARN(logger, msg);} + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::WARN << msg << log4cpp::eol;} #define GR_ERROR(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_ERROR(logger, msg);} + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;} + +#define GR_CRIT(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::CRIT << msg << log4cpp::eol;} + +#define GR_ALERT(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::ALERT << msg << log4cpp::eol;} #define GR_FATAL(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_FATAL(logger, msg);} + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::FATAL << msg << log4cpp::eol;} + +#define GR_EMERG(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;} #define GR_ERRORIF(name, cond, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_ASSERT(logger, !(cond), msg);} +if((cond)){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;};\ +}; #define GR_ASSERT(name, cond, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_ASSERT(logger, (cond), msg); \ - assert((cond));} +if((!cond)){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;};\ + assert(0);\ +}; /* LoggerPtr Referenced Macros */ -#define GR_LOG_TRACE(logger, msg) { \ - LOG4CXX_TRACE(logger, msg);} - #define GR_LOG_DEBUG(logger, msg) { \ - LOG4CXX_DEBUG(logger, msg);} + *logger << log4cpp::Priority::DEBUG << msg << log4cpp::eol;} #define GR_LOG_INFO(logger, msg) { \ - LOG4CXX_INFO(logger, msg);} + *logger << log4cpp::Priority::INFO << msg << log4cpp::eol;} + +#define GR_LOG_NOTICE(logger, msg) { \ + *logger << log4cpp::Priority::NOTICE << msg << log4cpp::eol;} #define GR_LOG_WARN(logger, msg) { \ - LOG4CXX_WARN(logger, msg);} + *logger << log4cpp::Priority::WARN << msg << log4cpp::eol;} #define GR_LOG_ERROR(logger, msg) { \ - LOG4CXX_ERROR(logger, msg);} + *logger << log4cpp::Priority::ERROR << msg << log4cpp::eol;} + +#define GR_LOG_CRIT(logger, msg) { \ + *logger << log4cpp::Priority::CRIT << msg << log4cpp::eol;} + +#define GR_LOG_ALERT(logger, msg) { \ + *logger << log4cpp::Priority::ALERT << msg << log4cpp::eol;} #define GR_LOG_FATAL(logger, msg) { \ - LOG4CXX_FATAL(logger, msg);} + *logger << log4cpp::Priority::FATAL << msg << log4cpp::eol;} + +#define GR_LOG_EMERG(logger, msg) { \ + *logger << log4cpp::Priority::EMERG << msg << log4cpp::eol;} #define GR_LOG_ERRORIF(logger,cond, msg) { \ - LOG4CXX_ASSERT(logger, !(cond), msg);} +if((!cond)){\ + *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;};\ + assert(0);\ +}; #define GR_LOG_ASSERT(logger, cond, msg) { \ - LOG4CXX_ASSERT(logger, (cond), msg); \ - assert((cond));} +if((!cond)){\ + *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;};\ + assert(0);\ +}; /*! * \brief Load logger's configuration file. @@ -256,14 +298,16 @@ GR_CORE_API void logger_reset_config(void); * Sets the level of the logger. This takes a string that is * translated to the standard levels and can be (case insensitive): * - * \li off - * \li all - * \li trace + * \li off , notset * \li debug * \li info + * \li notice * \li warn * \li error + * \li crit + * \li alert * \li fatal + * \li emerg * * \param logger the logger to set the level of. * \param level string to set the level to. @@ -273,22 +317,24 @@ GR_CORE_API void logger_set_level(gr_logger_ptr logger, const std::string &level /*! * \brief Set the logger's output level. * - * Sets the level of the logger. This takes the actual Log4cxx::Level + * Sets the level of the logger. This takes the actual Log4cpp::Priority * data type, which can be: * - * \li log4cxx::Level::getOff() - * \li log4cxx::Level::getAll() - * \li log4cxx::Level::getTrace() - * \li log4cxx::Level::getDebug() - * \li log4cxx::Level::getInfo() - * \li log4cxx::Level::getWarn() - * \li log4cxx::Level::getError() - * \li log4cxx::Level::getFatal() + * \li log4cpp::Priority::NOTSET + * \li log4cpp::Priority::DEBUG + * \li log4cpp::Priority::INFO + * \li log4cpp::Priority::NOTICE + * \li log4cpp::Priority::WARN + * \li log4cpp::Priority::ERROR + * \li log4cpp::Priority::CRIT + * \li log4cpp::Priority::ALERT + * \li log4cpp::Priority::FATAL + * \li log4cpp::Priority::EMERG * * \param logger the logger to set the level of. - * \param level new logger level of type Log4cxx::Level + * \param level new logger level of type Log4cpp::Priority */ -GR_CORE_API void logger_set_level(gr_logger_ptr logger, log4cxx::LevelPtr level); +void logger_set_level(gr_logger_ptr logger, log4cpp::Priority::Value level); /*! @@ -297,14 +343,16 @@ GR_CORE_API void logger_set_level(gr_logger_ptr logger, log4cxx::LevelPtr level) * Gets the level of the logger. This returns a string that * corresponds to the standard levels and can be (case insensitive): * - * \li off - * \li all - * \li trace + * \li notset * \li debug * \li info + * \li notice * \li warn * \li error + * \li crit + * \li alert * \li fatal + * \li emerg * * \param logger the logger to get the level of. * \param level string to get the level into. @@ -314,32 +362,31 @@ GR_CORE_API void logger_get_level(gr_logger_ptr logger, std::string &level); /*! * \brief Get the logger's output level. * - * Gets the level of the logger. This returns the actual Log4cxx::Level + * Gets the level of the logger. This returns the actual Log4cpp::Level * data type, which can be: * - * \li log4cxx::Level::getOff() - * \li log4cxx::Level::getAll() - * \li log4cxx::Level::getTrace() - * \li log4cxx::Level::getDebug() - * \li log4cxx::Level::getInfo() - * \li log4cxx::Level::getWarn() - * \li log4cxx::Level::getError() - * \li log4cxx::Level::getFatal() + * \li log4cpp::Priority::NOTSET + * \li log4cpp::Priority::DEBUG + * \li log4cpp::Priority::INFO + * \li log4cpp::Priority::NOTICE + * \li log4cpp::Priority::WARN + * \li log4cpp::Priority::ERROR + * \li log4cpp::Priority::CRIT + * \li log4cpp::Priority::ALERT + * \li log4cpp::Priority::FATAL + * \li log4cpp::Priority::EMERG * * \param logger the logger to get the level of. + * \param level of the logger. */ -GR_CORE_API void logger_get_level(gr_logger_ptr logger, log4cxx::LevelPtr level); +GR_CORE_API void logger_get_level(gr_logger_ptr logger, log4cpp::Priority::Value &level); +GR_CORE_API void logger_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern); -GR_CORE_API void logger_add_console_appender(gr_logger_ptr logger, std::string layout, - std::string target); +GR_CORE_API void logger_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern); -GR_CORE_API void logger_add_file_appender(gr_logger_ptr logger, std::string layout, - std::string filename, bool append); - -GR_CORE_API void logger_add_rollingfile_appender(gr_logger_ptr logger, std::string layout, - std::string filename, bool append, - int bkup_index, std::string filesize); +GR_CORE_API void logger_add_rollingfile_appender(gr_logger_ptr logger,std::string filename, + size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern); GR_CORE_API void logger_get_logger_names(std::vector<std::string>& names); @@ -366,25 +413,22 @@ class gr_logger gr_logger(std::string config_filename, int watchPeriodSec) { // Load configuration file - if(config_filename.find(".xml")!=std::string::npos) { - log4cxx::xml::DOMConfigurator::configureAndWatch(config_filename, watchPeriodSec); - } - else { - log4cxx::PropertyConfigurator::configureAndWatch(config_filename, watchPeriodSec); - } + logger_load_config_and_watch(config_filename,watchPeriodSec); + }; - static log4cxx::LoggerPtr getLogger(std::string name) + static gr_logger_ptr getLogger(std::string name) { - if(log4cxx::LogManager::exists(name)) { - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); - return logger; - } - else { - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); - logger->setLevel(log4cxx::Level::getOff()); - return logger; - }; + if(log4cpp::Category::exists(name)){ + gr_logger_ptr logger = &log4cpp::Category::getInstance(name); + return logger; + } + else + { + gr_logger_ptr logger = &log4cpp::Category::getInstance(name); + logger->setPriority(log4cpp::Priority::NOTSET); + return logger; + }; }; // Wrappers for logging macros @@ -394,64 +438,82 @@ class gr_logger /*! \brief inline function, wrapper to get the logger level */ void get_level(std::string name,std::string &level){GR_GET_LEVEL(name,level);} - /*! \brief inline function, wrapper for LOG4CXX_TRACE for TRACE message */ - void trace(std::string name,std::string msg){GR_TRACE(name,msg);}; - - /*! \brief inline function, wrapper for LOG4CXX_DEBUG for DEBUG message */ + /*! \brief inline function, wrapper for DEBUG message */ void debug(std::string name,std::string msg){GR_DEBUG(name,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_INFO for INFO message */ + /*! \brief inline function, wrapper for INFO message */ void info(std::string name,std::string msg){GR_INFO(name,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_WARN for WARN message */ + /*! \brief inline function, wrapper for NOTICE message */ + void notice(std::string name,std::string msg){GR_NOTICE(name,msg);}; + + /*! \brief inline function, wrapper for WARN message */ void warn(std::string name,std::string msg){GR_WARN(name,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_ERROR for ERROR message */ + /*! \brief inline function, wrapper for ERROR message */ void error(std::string name,std::string msg){GR_ERROR(name,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_FATAL for FATAL message */ + /*! \brief inline function, wrapper for CRIT message */ + void crit(std::string name,std::string msg){GR_CRIT(name,msg);}; + + /*! \brief inline function, wrapper for ALERT message */ + void alert(std::string name,std::string msg){GR_ALERT(name,msg);}; + + /*! \brief inline function, wrapper for FATAL message */ void fatal(std::string name,std::string msg){GR_FATAL(name,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_ASSERT for conditional ERROR message */ + /*! \brief inline function, wrapper for EMERG message */ + void emerg(std::string name,std::string msg){GR_EMERG(name,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */ void errorIF(std::string name,bool cond,std::string msg){GR_ERRORIF(name,cond,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_ASSERT for conditional ERROR message */ + /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */ void gr_assert(std::string name,bool cond,std::string msg){GR_ASSERT(name,cond,msg);}; // Wrappers for Logger Pointer referenced functions /*! \brief inline function, wrapper to set the logger level */ - void set_log_level(log4cxx::LoggerPtr logger,std::string level){GR_LOG_SET_LEVEL(logger,level);} + void set_log_level(gr_logger_ptr logger,std::string level){GR_LOG_SET_LEVEL(logger,level);} /*! \brief inline function, wrapper to get the logger level */ - void get_log_level(log4cxx::LoggerPtr logger,std::string &level){GR_LOG_GET_LEVEL(logger,level);} + void get_log_level(gr_logger_ptr logger,std::string &level){GR_LOG_GET_LEVEL(logger,level);} + + /*! \brief inline function, wrapper for LOG4CPP_DEBUG for DEBUG message */ + void log_debug(gr_logger_ptr logger,std::string msg){GR_LOG_DEBUG(logger,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_TRACE for TRACE message */ - void log_trace(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_TRACE(logger,msg);}; + /*! \brief inline function, wrapper for LOG4CPP_INFO for INFO message */ + void log_info(gr_logger_ptr logger,std::string msg){GR_LOG_INFO(logger,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_DEBUG for DEBUG message */ - void log_debug(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_DEBUG(logger,msg);}; + /*! \brief inline function, wrapper for NOTICE message */ + void log_notice(gr_logger_ptr logger,std::string msg){GR_LOG_NOTICE(logger,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_INFO for INFO message */ - void log_info(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_INFO(logger,msg);}; + /*! \brief inline function, wrapper for LOG4CPP_WARN for WARN message */ + void log_warn(gr_logger_ptr logger,std::string msg){GR_LOG_WARN(logger,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_WARN for WARN message */ - void log_warn(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_WARN(logger,msg);}; + /*! \brief inline function, wrapper for LOG4CPP_ERROR for ERROR message */ + void log_error(gr_logger_ptr logger,std::string msg){GR_LOG_ERROR(logger,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_ERROR for ERROR message */ - void log_error(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_ERROR(logger,msg);}; + /*! \brief inline function, wrapper for NOTICE message */ + void log_crit(gr_logger_ptr logger,std::string msg){GR_LOG_CRIT(logger,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_FATAL for FATAL message */ - void log_fatal(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_FATAL(logger,msg);}; + /*! \brief inline function, wrapper for ALERT message */ + void log_alert(gr_logger_ptr logger,std::string msg){GR_LOG_ALERT(logger,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_ASSERT for conditional ERROR message */ - void log_errorIF(log4cxx::LoggerPtr logger,bool cond,std::string msg){GR_LOG_ERRORIF(logger,cond,msg);}; + /*! \brief inline function, wrapper for FATAL message */ + void log_fatal(gr_logger_ptr logger,std::string msg){GR_LOG_FATAL(logger,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_ASSERT for conditional ERROR message */ - void log_assert(log4cxx::LoggerPtr logger,bool cond,std::string msg){GR_LOG_ASSERT(logger,cond,msg);}; + /*! \brief inline function, wrapper for EMERG message */ + void log_emerg(gr_logger_ptr logger,std::string msg){GR_LOG_EMERG(logger,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */ + void log_errorIF(gr_logger_ptr logger,bool cond,std::string msg){GR_LOG_ERRORIF(logger,cond,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */ + void log_assert(gr_logger_ptr logger,bool cond,std::string msg){GR_LOG_ASSERT(logger,cond,msg);}; }; -#endif /* HAVE_LOG4CXX */ +#endif /* HAVE_LOG4CPP */ // If Logger disable do nothing #else /* ENABLE_GR_LOG */ @@ -461,36 +523,40 @@ typedef void* gr_logger_ptr; #define GR_LOG_DECLARE_LOGPTR(logger) #define GR_LOG_ASSIGN_LOGPTR(logger,name) #define GR_CONFIG_LOGGER(config) -#define GR_CONFIG_AND_WATCH_LOGGER(config) +#define GR_CONFIG_AND_WATCH_LOGGER(config,period) #define GR_LOG_GETLOGGER(logger, name) #define GR_SET_LEVEL(name, level) #define GR_LOG_SET_LEVEL(logger, level) #define GR_GET_LEVEL(name, level) #define GR_LOG_GET_LEVEL(logger, level) -#define GR_ADD_CONSOLE_APPENDER(logger,layout) -#define GR_LOG_ADD_CONSOLE_APPENDER(logger,layout) -#define GR_ADD_FILE_APPENDER(logger,layout,filename,append) -#define GR_LOG_ADD_FILE_APPENDER(logger,layout) -#define GR_ADD_ROLLINGFILE_APPENDER(logger,layout,filename,append,bkup_index,filesize) -#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,layout) +#define GR_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_TRACE(name, msg) #define GR_DEBUG(name, msg) #define GR_INFO(name, msg) -#define GR_WARN(name, msg) -#define GR_ERROR(name, msg) -#define GR_FATAL(name, msg) +#define GR_NOTICE(name, msg) +#define GR_WARN(name, msg) +#define GR_ERROR(name, msg) +#define GR_ALERT(name, msg) +#define GR_CRIT(name, msg) +#define GR_FATAL(name, msg) +#define GR_EMERG(name, msg) #define GR_ERRORIF(name, cond, msg) #define GR_ASSERT(name, cond, msg) -#define GR_LOG_SET_LEVEL(logger, level) -#define GR_LOG_GET_LEVEL(logger, level) -#define GR_LOG_TRACE(logger, msg) #define GR_LOG_DEBUG(logger, msg) -#define GR_LOG_INFO(logger, msg) -#define GR_LOG_WARN(logger, msg) -#define GR_LOG_ERROR(logger, msg) -#define GR_LOG_FATAL(logger, msg) +#define GR_LOG_INFO(logger, msg) +#define GR_LOG_NOTICE(logger, msg) +#define GR_LOG_WARN(logger, msg) +#define GR_LOG_ERROR(logger, msg) +#define GR_LOG_ALERT(logger, msg) +#define GR_LOG_CRIT(logger, msg) +#define GR_LOG_FATAL(logger, msg) +#define GR_LOG_EMERG(logger, msg) #define GR_LOG_ERRORIF(logger, cond, msg) #define GR_LOG_ASSERT(logger, cond, msg) diff --git a/gnuradio-core/src/lib/runtime/gr_logger.i b/gnuradio-core/src/lib/runtime/gr_logger.i index 1eedf3d60d..70e50e02b3 100644 --- a/gnuradio-core/src/lib/runtime/gr_logger.i +++ b/gnuradio-core/src/lib/runtime/gr_logger.i @@ -23,7 +23,7 @@ * Copyright 2011 Johns Hopkins University Applied Physics Lab * Author: Mark Plett * Description: -* SWIG interface generator file for gr_logger module. gr_logger wraps log4cxx logging +* SWIG interface generator file for gr_logger module. gr_logger wraps log4cpp logging * for gnuradio. *******************************************************************************/ @@ -40,23 +40,22 @@ //----------------------------------- #ifdef ENABLE_GR_LOG -#ifdef HAVE_LOG4CXX +#ifdef HAVE_LOG4CPP %{ // The .h files #include <gr_logger.h> -#include <log4cxx/logger.h> -#include <log4cxx/logmanager.h> +#include <log4cpp/Category.hh> %} -namespace log4cxx{ +namespace log4cpp{ class LoggerPtr { public: ~LoggerPtr(); }; }; void logger_load_config(const std::string &config_filename); -void logger_set_level(log4cxx::LoggerPtr logger, const std::string &level); +void logger_set_level(log4cpp::LoggerPtr logger, const std::string &level); %rename(log) gr_logger; @@ -69,28 +68,42 @@ public: gr_logger(std::string config_filename,int watchPeriodSec); void set_level(std::string name,std::string level); void get_level(std::string name,std::string &level); - void trace(std::string name,std::string msg); + void add_console_appender(std::string name,std::string target,std::string pattern); + void add_file_appender(std::string name,std::string filename,bool append,std::string patter); + void add_rollingfile_appender(std::string name,std::string filename,size_t filesize,int bkup_indx,bool append,mode_t mode,std::string pattern); + + void notice(std::string name,std::string msg); void debug(std::string name,std::string msg); void info(std::string name,std::string msg); void warn(std::string name,std::string msg); void error(std::string name,std::string msg); - void fatal(std::string name,std::string msg); + void emerg(std::string name,std::string msg); + void crit(std::string name,std::string msg); void errorIF(std::string name,bool cond,std::string msg); void gr_assert(std::string name,bool cond,std::string msg); - static log4cxx::LoggerPtr getLogger(std::string name); - - void set_log_level(log4cxx::LoggerPtr logger,std::string level); - void get_log_level(log4cxx::LoggerPtr logger,std::string &level); - void log_trace(log4cxx::LoggerPtr logger,std::string msg); - void log_debug(log4cxx::LoggerPtr logger,std::string msg); - void log_info(log4cxx::LoggerPtr logger,std::string msg); - void log_warn(log4cxx::LoggerPtr logger,std::string msg); - void log_error(log4cxx::LoggerPtr logger,std::string msg); - void log_fatal(log4cxx::LoggerPtr logger,std::string msg); - void log_errorIF(log4cxx::LoggerPtr logger,bool cond,std::string msg); - void log_assert(log4cxx::LoggerPtr logger,bool cond,std::string msg); + static gr_logger_ptr getLogger(std::string name); + + void log_set_level(gr_logger_ptr logger,std::string level); + void log_get_level(gr_logger_ptr logger,std::string &level); + void log_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern); + void log_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern); + void log_add_rollingfile_appender(gr_logger_ptr logger,std::string filename,size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern); + + void log_notice(gr_logger_ptr logger,std::string msg); + void log_debug(gr_logger_ptr logger,std::string msg); + void log_info(gr_logger_ptr logger,std::string msg); + void log_warn(gr_logger_ptr logger,std::string msg); + void log_error(gr_logger_ptr logger,std::string msg); + void log_crit(gr_logger_ptr logger,std::string msg); + void log_emerg(gr_logger_ptr logger,std::string msg); + void log_errorIF(gr_logger_ptr logger,bool cond,std::string msg); + void log_assert(gr_logger_ptr logger,bool cond,std::string msg); + + void get_logger_names(std::vector<std::string>& names); + void reset_configuration(); + }; -#endif /* HAVE_LOG4CXX */ +#endif /* HAVE_LOG4CPP */ #endif /* ENABLE_GR_LOG */ diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc index 3d21c1f305..a8e4a1d766 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc +++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc @@ -38,14 +38,15 @@ qa_gr_logger::t1() #ifdef ENABLE_GR_LOG // This doesn't really test anything, more just // making sure nothing's gone horribly wrong. - GR_LOG_GETLOGGER(LOG,"errLoggerRoot"); - GR_LOG_TRACE(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_GETLOGGER(LOG,"main"); + GR_ADD_CONSOLE_APPENDER("main","cout","%d{%H:%M:%S} : %m%n"); + 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 } diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index 1be70f5c8f..2132e2ca09 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -25,15 +25,15 @@ set(GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) set(GR_SWIG_LIBRARIES gnuradio-core - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) -# Only use if log4cxx is installed +# Only use if log4cpp is installed # Define ENABLE_GR_LOG for the .i file to ignore it. if(ENABLE_GR_LOG) SET(GR_SWIG_FLAGS "-DENABLE_GR_LOG") diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt index 60f394a967..ef58cf9ef5 100644 --- a/gnuradio-core/src/tests/CMakeLists.txt +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -36,8 +36,8 @@ link_directories( ${CPPUNIT_LIBRARY_DIRS} ) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Build benchmarks and non-registered tests diff --git a/gr-atsc/src/lib/CMakeLists.txt b/gr-atsc/src/lib/CMakeLists.txt index 30e78d709a..52375eef2f 100644 --- a/gr-atsc/src/lib/CMakeLists.txt +++ b/gr-atsc/src/lib/CMakeLists.txt @@ -33,8 +33,8 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Generate viterbi mux source @@ -122,7 +122,7 @@ list(APPEND atsc_libs gnuradio-fec gnuradio-blocks ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-atsc SHARED ${gr_atsc_sources}) diff --git a/gr-audio/lib/CMakeLists.txt b/gr-audio/lib/CMakeLists.txt index 86c553c735..36acd8f43b 100644 --- a/gr-audio/lib/CMakeLists.txt +++ b/gr-audio/lib/CMakeLists.txt @@ -25,15 +25,15 @@ include_directories( ${GR_AUDIO_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) -list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES} ${LOG4CXX_LIBRARIES}) -list(APPEND gr_audio_sources audio_registry.cc) +list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES}) +list(APPEND gr_audio_sources gr_audio_registry.cc) list(APPEND gr_audio_confs ${CMAKE_CURRENT_SOURCE_DIR}/gr-audio.conf) if(ENABLE_GR_CTRLPORT) diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index ddbeba0d61..42adc804a8 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -133,6 +133,7 @@ <cat> <name>Misc (New) </name> <block>blocks_throttle</block> + <block>blocks_probe_rate</block> </cat> <cat> <name>Networking</name> diff --git a/gr-blocks/grc/blocks_probe_rate.xml b/gr-blocks/grc/blocks_probe_rate.xml new file mode 100644 index 0000000000..08df23e0d2 --- /dev/null +++ b/gr-blocks/grc/blocks_probe_rate.xml @@ -0,0 +1,66 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Probe Rate +################################################### + --> +<block> + <name>Probe Rate</name> + <key>blocks_probe_rate</key> + <import>from gnuradio import blocks</import> + <make>blocks.probe_rate($type.size*$vlen, $mintime, $alpha)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Min Update Time (ms)</name> + <key>mintime</key> + <value>500.0</value> + <type>real</type> + </param> + <param> + <name>Update Alpha</name> + <key>alpha</key> + <value>0.15</value> + <type>real</type> + </param> + <check>$vlen >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_udp_source.xml b/gr-blocks/grc/blocks_udp_source.xml new file mode 100644 index 0000000000..bca1dff8b8 --- /dev/null +++ b/gr-blocks/grc/blocks_udp_source.xml @@ -0,0 +1,79 @@ +<?xml version="1.0"?> +<!-- +################################################### +##UDP Source +################################################### + --> +<block> + <name>UDP Source</name> + <key>blocks_udp_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.udp_source($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make> + <callback>set_mtu($mtu)</callback> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>IP Address</name> + <key>ipaddr</key> + <value>127.0.0.1</value> + <type>string</type> + </param> + <param> + <name>Port</name> + <key>port</key> + <value>1234</value> + <type>int</type> + </param> + <param> + <name>Payload Size</name> + <key>psize</key> + <value>1472</value> + <type>int</type> + </param> + <param> + <name>Null Pkt is EOF</name> + <key>eof</key> + <value>True</value> + <type>bool</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index 648adccdbb..82d4179c72 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -124,9 +124,6 @@ install(FILES conjugate_cc.h deinterleave.h delay.h - file_descriptor_sink.h - file_descriptor_source.h - file_sink.h file_source.h file_meta_sink.h file_meta_source.h @@ -157,6 +154,7 @@ install(FILES pdu_to_tagged_stream.h peak_detector2_fb.h random_pdu.h + probe_rate.h regenerate_bb.h repeat.h rms_cf.h diff --git a/gr-blocks/include/blocks/fxpt_nco.h b/gr-blocks/include/blocks/fxpt_nco.h index 0faa731763..7db20fbb3a 100644 --- a/gr-blocks/include/blocks/fxpt_nco.h +++ b/gr-blocks/include/blocks/fxpt_nco.h @@ -41,7 +41,7 @@ namespace gr { * to the fxpt_vco can also be used to set or adjust the current * phase. */ - class BLOCKS_API fxpt_nco + class fxpt_nco { private: uint32_t d_phase; diff --git a/gr-blocks/include/blocks/mute_XX.h.t b/gr-blocks/include/blocks/mute_XX.h.t index 3033248c4e..2b1c8b9a4d 100644 --- a/gr-blocks/include/blocks/mute_XX.h.t +++ b/gr-blocks/include/blocks/mute_XX.h.t @@ -41,10 +41,10 @@ namespace gr { // gr::blocks::@NAME@::sptr typedef boost::shared_ptr<@NAME@> sptr; - static sptr make(bool mute); + static sptr make(bool mute=false); virtual bool mute() const = 0; - virtual void set_mute(bool mute) = 0; + virtual void set_mute(bool mute=false) = 0; }; } /* namespace blocks */ diff --git a/gr-blocks/include/blocks/peak_detector_XX.h.t b/gr-blocks/include/blocks/peak_detector_XX.h.t index 1c8ba0652f..fead53d208 100644 --- a/gr-blocks/include/blocks/peak_detector_XX.h.t +++ b/gr-blocks/include/blocks/peak_detector_XX.h.t @@ -38,7 +38,7 @@ namespace gr { * If a peak is detected, this block outputs a 1, * or it outputs 0's. */ - class GR_CORE_API @NAME@ : virtual public gr_sync_block + class BLOCKS_API @NAME@ : virtual public gr_sync_block { public: // gr::blocks::@NAME@::sptr diff --git a/gr-blocks/include/blocks/probe_rate.h b/gr-blocks/include/blocks/probe_rate.h new file mode 100644 index 0000000000..3401d2acd1 --- /dev/null +++ b/gr-blocks/include/blocks/probe_rate.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_PROBE_RATE_H +#define INCLUDED_BLOCKS_PROBE_RATE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief throughput measurement + */ + class BLOCKS_API probe_rate : virtual public gr_sync_block + { + public: + // gr::blocks::probe_rate::sptr + typedef boost::shared_ptr<probe_rate> sptr; + + /*! + * \brief Make a throughput measurement block + * \param itemsize size of each stream item + * \param update_rate_ms minimum update time in milliseconds + * \param alpha gain for running average filter + */ + static sptr make(size_t itemsize, double update_rate_ms = 500.0, double alpha = 0.0001); + + virtual void set_alpha(double alpha) = 0; + + virtual double rate() = 0; + + virtual bool start() = 0; + virtual bool stop() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_PROBE_RATE_H */ diff --git a/gr-blocks/include/blocks/udp_source.h b/gr-blocks/include/blocks/udp_source.h new file mode 100644 index 0000000000..b72db30db0 --- /dev/null +++ b/gr-blocks/include/blocks/udp_source.h @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_UDP_SOURCE_H +#define INCLUDED_GR_UDP_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Read stream from an UDP socket. + * \ingroup source_blk + */ + class BLOCKS_API udp_source : virtual public gr_sync_block + { + public: + // gr::blocks::udp_source::sptr + typedef boost::shared_ptr<udp_source> sptr; + + /*! + * \brief UDP Source Constructor + * + * \param itemsize The size (in bytes) of the item datatype + * \param host The name or IP address of the receiving host; can be + * NULL, None, or "0.0.0.0" to allow reading from any + * interface on the host + * \param port The port number on which to receive data; use 0 to + * have the system assign an unused port number + * \param payload_size UDP payload size by default set to 1472 = + * (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param eof Interpret zero-length packet as EOF (default: true) + */ + static sptr make(size_t itemsize, + const std::string &host, int port, + int payload_size=1472, + bool eof=true); + + /*! \brief Change the connection to a new destination + * + * \param host The name or IP address of the receiving host; use + * NULL or None to break the connection without closing + * \param port Destination port to connect to on receiving host + * + * Calls disconnect() to terminate any current connection first. + */ + virtual void connect(const std::string &host, int port) = 0; + + /*! \brief Cut the connection if we have one set up. + */ + virtual void disconnect() = 0; + + /*! \brief return the PAYLOAD_SIZE of the socket */ + virtual int payload_size() = 0; + + /*! \brief return the port number of the socket */ + virtual int get_port() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UDP_SOURCE_H */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index ac47f9b50e..c7a7b6362f 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -198,6 +198,7 @@ list(APPEND gr_blocks_sources pdu_to_tagged_stream_impl.cc peak_detector2_fb_impl.cc random_pdu_impl.cc + probe_rate_impl.cc regenerate_bb_impl.cc repeat_impl.cc rms_cf_impl.cc diff --git a/gr-blocks/lib/probe_rate_impl.cc b/gr-blocks/lib/probe_rate_impl.cc new file mode 100644 index 0000000000..37749c85e3 --- /dev/null +++ b/gr-blocks/lib/probe_rate_impl.cc @@ -0,0 +1,119 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "probe_rate_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + probe_rate::sptr + probe_rate::make(size_t itemsize, double update_rate_ms, double alpha) + { + return gnuradio::get_initial_sptr + (new probe_rate_impl(itemsize,update_rate_ms,alpha)); + } + + probe_rate_impl::probe_rate_impl(size_t itemsize, double update_rate_ms, double alpha) : + gr_sync_block("probe_rate", + gr_make_io_signature(1,1,itemsize), + gr_make_io_signature(0,0,itemsize)), + d_alpha(alpha), + d_beta(1.0-alpha), + d_avg(0), + d_min_update_time(update_rate_ms), + d_lastthru(0), + d_itemsize(itemsize) + { + } + + probe_rate_impl::~probe_rate_impl(){} + + int probe_rate_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items){ + d_lastthru += noutput_items; + boost::posix_time::ptime now(boost::posix_time::microsec_clock::local_time()); + boost::posix_time::time_duration diff = now - d_last_update; + double diff_ms = diff.total_milliseconds(); + if(diff_ms >= d_min_update_time){ + double rate_this_update = d_lastthru *1e3 / diff_ms; + d_lastthru = 0; + d_last_update = now; + if(d_avg == 0){ + d_avg = rate_this_update; + } else { + d_avg = rate_this_update*d_alpha + d_avg*d_beta; + } + } + return noutput_items; + } + + void probe_rate_impl::setup_rpc(){ +#ifdef GR_CTRLPORT + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<probe_rate_impl, double >( + alias(), "rate_items", + &probe_rate_impl::rate, + pmt::mp(0), pmt::mp(1e6), pmt::mp(1), + "items/sec", "Item rate", + RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<probe_rate_impl, double >( + alias(), "timesincelast", + &probe_rate_impl::timesincelast, + pmt::mp(0), pmt::mp(d_min_update_time*2), pmt::mp(0), + "ms", "Time since last update", + RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); +#endif + } + + void probe_rate_impl::set_alpha(double alpha){ d_alpha = alpha; } + + double probe_rate_impl::rate(){ return d_avg; } + + double probe_rate_impl::timesincelast(){ + boost::posix_time::ptime now(boost::posix_time::microsec_clock::local_time()); + boost::posix_time::time_duration diff = now - d_last_update; + return diff.total_milliseconds(); + } + + bool probe_rate_impl::start(){ + d_avg = 0; + d_lastthru = 0; + d_last_update = boost::posix_time::microsec_clock::local_time(); + return true; + } + + bool probe_rate_impl::stop(){ + return true; + } + + + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/probe_rate_impl.h b/gr-blocks/lib/probe_rate_impl.h new file mode 100644 index 0000000000..81f7b4e138 --- /dev/null +++ b/gr-blocks/lib/probe_rate_impl.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_PROBE_RATE_IMPL_H +#define INCLUDED_GR_PROBE_RATE_IMPL_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <blocks/probe_rate.h> + +namespace gr { + namespace blocks { + + class probe_rate_impl : public probe_rate + { + private: + double d_alpha, d_beta, d_avg; + double d_min_update_time; + boost::posix_time::ptime d_last_update; + uint64_t d_lastthru; + size_t d_itemsize; + void setup_rpc(); + + public: + probe_rate_impl(size_t itemsize, double update_rate_ms, double alpha = 0.0001); + ~probe_rate_impl(); + void set_alpha(double alpha); + double rate(); + double timesincelast(); + bool start(); + bool stop(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + }; // end class + + } /* namespace blocks */ +} /* namespace gr */ + +#endif diff --git a/gr-blocks/lib/udp_source_impl.cc b/gr-blocks/lib/udp_source_impl.cc new file mode 100644 index 0000000000..16ed72ca21 --- /dev/null +++ b/gr-blocks/lib/udp_source_impl.cc @@ -0,0 +1,199 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "udp_source_impl.h" +#include <gr_io_signature.h> +#include <gr_math.h> +#include <stdexcept> +#include <errno.h> +#include <stdio.h> +#include <string.h> + +namespace gr { + namespace blocks { + + udp_source::sptr + udp_source::make(size_t itemsize, + const std::string &ipaddr, int port, + int payload_size, bool eof) + { + return gnuradio::get_initial_sptr + (new udp_source_impl(itemsize, ipaddr, port, + payload_size, eof)); + } + + udp_source_impl::udp_source_impl(size_t itemsize, + const std::string &host, int port, + int payload_size, bool eof) + : gr_sync_block("udp_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_payload_size(payload_size), + d_eof(eof), d_connected(false), d_residual(0), d_sent(0), d_offset(0) + { + // Give us some more room to play. + d_rxbuf = new char[4*d_payload_size]; + d_residbuf = new char[50*d_payload_size]; + + connect(host, port); + } + + udp_source_impl::~udp_source_impl() + { + if(d_connected) + disconnect(); + + delete [] d_rxbuf; + delete [] d_residbuf; + } + + void + udp_source_impl::connect(const std::string &host, int port) + { + if(d_connected) + disconnect(); + + d_host = host; + d_port = static_cast<unsigned short>(port); + + if(host.size() > 0) { + d_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), d_port); + d_socket = new boost::asio::ip::udp::socket(d_io_service, d_endpoint); + + boost::asio::socket_base::linger loption(true, 0); + d_socket->set_option(loption); + + boost::asio::socket_base::reuse_address roption(true); + d_socket->set_option(roption); + + start_receive(); + d_udp_thread = gruel::thread(boost::bind(&udp_source_impl::run_io_service, this)); + d_connected = true; + } + } + + void + udp_source_impl::disconnect() + { + gruel::scoped_lock lock(d_setlock); + + if(!d_connected) + return; + + d_io_service.stop(); + + d_socket->close(); + delete d_socket; + + d_connected = false; + } + + // Return port number of d_socket + int + udp_source_impl::get_port(void) + { + return d_endpoint.port(); + } + + void + udp_source_impl::start_receive() + { + d_socket->async_receive_from(boost::asio::buffer((void*)d_rxbuf, d_payload_size), d_endpoint_rcvd, + boost::bind(&udp_source_impl::handle_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + + void + udp_source_impl::handle_read(const boost::system::error_code& error, + size_t bytes_transferred) + { + if(!error) { + { + boost::lock_guard<gruel::mutex> lock(d_udp_mutex); + if(d_eof && (bytes_transferred == 1) && (d_rxbuf[0] == 0x00)) { + // If we are using EOF notification, test for it and don't + // add anything to the output. + d_residual = 0; + } + else { + // Make sure we never go beyond the boundary of the + // residual buffer. This will just drop the last bit of + // data in the buffer if we've run out of room. + if((int)(d_residual + bytes_transferred) > (50*d_payload_size)) { + GR_LOG_WARN(d_logger, "Too much data; dropping packet."); + } + else { + // otherwise, copy receid data into local buffer for + // copying later. + memcpy(d_residbuf+d_residual, d_rxbuf, bytes_transferred); + d_residual += bytes_transferred; + } + } + d_cond_wait.notify_one(); + } + } + start_receive(); + } + + int + udp_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gruel::scoped_lock l(d_setlock); + + char *out = (char*)output_items[0]; + + // Use async receive_from to get data from UDP buffer and wait + // on a conditional signal before proceeding. We use this + // because the conditional wait is interruptable while a + // synchronous receive_from is not. + boost::unique_lock<boost::mutex> lock(d_udp_mutex); + d_cond_wait.wait(lock); + + int to_be_sent = (int)(d_residual - d_sent); + int to_send = std::min(noutput_items, to_be_sent); + + // Copy the received data in the residual buffer to the output stream + memcpy(out, d_residbuf+d_sent, to_send); + int nitems = to_send/d_itemsize; + + // Keep track of where we are if we don't have enough output + // space to send all the data in the residbuf. + if(to_send == to_be_sent) { + d_residual = 0; + d_sent = 0; + } + else { + d_sent += to_send; + } + + return nitems; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/udp_source_impl.h b/gr-blocks/lib/udp_source_impl.h new file mode 100644 index 0000000000..8927f5f933 --- /dev/null +++ b/gr-blocks/lib/udp_source_impl.h @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_UDP_SOURCE_IMPL_H +#define INCLUDED_GR_UDP_SOURCE_IMPL_H + +#include <blocks/udp_source.h> +#include <boost/asio.hpp> +#include <boost/format.hpp> +#include <gruel/thread.h> + +namespace gr { + namespace blocks { + + class udp_source_impl : public udp_source + { + private: + size_t d_itemsize; + int d_payload_size; // maximum transmission unit (packet length) + bool d_eof; // look for an EOF signal + bool d_connected; // are we connected? + char *d_rxbuf; // get UDP buffer items + char *d_residbuf; // hold buffer between calls + ssize_t d_residual; // hold information about number of bytes stored in residbuf + ssize_t d_sent; // track how much of d_residbuf we've outputted + size_t d_offset; // point to residbuf location offset + + std::string d_host; + unsigned short d_port; + + boost::asio::ip::udp::socket *d_socket; + boost::asio::ip::udp::endpoint d_endpoint; + boost::asio::ip::udp::endpoint d_endpoint_rcvd; + boost::asio::io_service d_io_service; + + gruel::condition_variable d_cond_wait; + gruel::mutex d_udp_mutex; + gruel::thread d_udp_thread; + + void start_receive(); + void handle_read(const boost::system::error_code& error, + size_t bytes_transferred); + void run_io_service() { d_io_service.run(); } + + public: + udp_source_impl(size_t itemsize, + const std::string &host, int port, + int payload_size, bool eof); + ~udp_source_impl(); + + void connect(const std::string &host, int port); + void disconnect(); + + int payload_size() { return d_payload_size; } + int get_port(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UDP_SOURCE_H */ diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i index fe85519f38..b12f26bad9 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig.i @@ -135,6 +135,7 @@ #include "blocks/peak_detector_ib.h" #include "blocks/peak_detector_sb.h" #include "blocks/peak_detector2_fb.h" +#include "blocks/probe_rate.h" #include "blocks/probe_signal_b.h" #include "blocks/probe_signal_s.h" #include "blocks/probe_signal_i.h" @@ -313,6 +314,7 @@ %include "blocks/peak_detector_sb.h" %include "blocks/peak_detector2_fb.h" %include "blocks/random_pdu.h" +%include "blocks/probe_rate.h" %include "blocks/regenerate_bb.h" %include "blocks/repeat.h" %include "blocks/rms_cf.h" @@ -458,6 +460,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_ib); GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_sb); GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector2_fb); GR_SWIG_BLOCK_MAGIC2(blocks, pdu_to_tagged_stream); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_rate); GR_SWIG_BLOCK_MAGIC2(blocks, or_bb); GR_SWIG_BLOCK_MAGIC2(blocks, or_ss); GR_SWIG_BLOCK_MAGIC2(blocks, or_ii); diff --git a/gr-blocks/tests/CMakeLists.txt b/gr-blocks/tests/CMakeLists.txt index 8f7ba2f64f..6a4f9d4c54 100644 --- a/gr-blocks/tests/CMakeLists.txt +++ b/gr-blocks/tests/CMakeLists.txt @@ -37,8 +37,8 @@ link_directories( ${CPPUNIT_LIBRARY_DIRS} ) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Build benchmarks and non-registered tests diff --git a/gr-comedi/src/CMakeLists.txt b/gr-comedi/src/CMakeLists.txt new file mode 100644 index 0000000000..0dc0960016 --- /dev/null +++ b/gr-comedi/src/CMakeLists.txt @@ -0,0 +1,121 @@ +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${GR_COMEDI_INCLUDE_DIRS} + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${COMEDI_INCLUDE_DIRS} +) + +link_directories( + ${Boost_LIBRARY_DIRS} + ${COMEDI_LIBRARY_DIRS} +) + +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + +######################################################################## +# Setup library +######################################################################## +list(APPEND gr_comedi_sources + comedi_sink_s.cc + comedi_source_s.cc + gri_comedi.cc +) + +list(APPEND comedi_libs + gnuradio-core + ${Boost_LIBRARIES} + ${COMEDI_LIBRARIES} + ${LOG4CPP_LIBRARIES} +) + +add_library(gnuradio-comedi SHARED ${gr_comedi_sources}) +target_link_libraries(gnuradio-comedi ${comedi_libs}) +GR_LIBRARY_FOO(gnuradio-comedi RUNTIME_COMPONENT "comedi_runtime" DEVEL_COMPONENT "comedi_devel") + +######################################################################## +# Install public header files +######################################################################## +install(FILES + comedi_sink_s.h + comedi_source_s.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "comedi_devel" +) + +######################################################################## +# Setup swig generation +######################################################################## +if(ENABLE_PYTHON) +include(GrPython) +include(GrSwig) + +set(GR_SWIG_INCLUDE_DIRS + ${GR_COMEDI_INCLUDE_DIRS} + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} +) + +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/comedi_swig_doc.i) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) + +set(GR_SWIG_LIBRARIES gnuradio-comedi) + +GR_SWIG_MAKE(comedi comedi.i) + +GR_SWIG_INSTALL( + TARGETS comedi + DESTINATION ${GR_PYTHON_DIR}/gnuradio + COMPONENT "comedi_python" +) + +install( + FILES comedi.i + ${CMAKE_CURRENT_BINARY_DIR}/comedi_swig_doc.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "comedi_swig" +) + +endif(ENABLE_PYTHON) + +######################################################################## +# Handle the unit tests +######################################################################## +if(ENABLE_TESTING AND ENABLE_PYTHON) + +list(APPEND GR_TEST_PYTHON_DIRS + ${CMAKE_BINARY_DIR}/gr-comedi/src +) +list(APPEND GR_TEST_TARGET_DEPS gnuradio-comedi) + +include(GrTest) +file(GLOB py_qa_test_files "qa_*.py") +foreach(py_qa_test_file ${py_qa_test_files}) + get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) + GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) +endforeach(py_qa_test_file) +endif(ENABLE_TESTING AND ENABLE_PYTHON) diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index d47e7fb1f3..74141f46af 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -29,12 +29,12 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${VOLK_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) if(ENABLE_GR_CTRLPORT) ADD_DEFINITIONS(-DGR_CTRLPORT) @@ -178,7 +178,7 @@ list(APPEND digital_libs gnuradio-blocks gnuradio-analog ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) diff --git a/gr-fcd/lib/CMakeLists.txt b/gr-fcd/lib/CMakeLists.txt index 12d14b4f71..35cefedffb 100644 --- a/gr-fcd/lib/CMakeLists.txt +++ b/gr-fcd/lib/CMakeLists.txt @@ -45,8 +45,8 @@ if(ENABLE_GR_CTRLPORT) include_directories(${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Setup library @@ -92,7 +92,7 @@ add_library(gnuradio-fcd SHARED ${gr_fcd_sources}) if (LINUX) list(APPEND fcd_libs rt) endif() -target_link_libraries(gnuradio-fcd ${fcd_libs} ${LOG4CXX_LIBRARIES}) +target_link_libraries(gnuradio-fcd ${fcd_libs} ${LOG4CPP_LIBRARIES}) GR_LIBRARY_FOO(gnuradio-fcd RUNTIME_COMPONENT "fcd_runtime" DEVEL_COMPONENT "fcd_devel") diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt index c855881579..5fa06701d7 100644 --- a/gr-filter/lib/CMakeLists.txt +++ b/gr-filter/lib/CMakeLists.txt @@ -97,13 +97,13 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${VOLK_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories( ${Boost_LIBRARY_DIRS} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) if(ENABLE_GR_CTRLPORT) diff --git a/gr-howto-write-a-block/CMakeLists.txt b/gr-howto-write-a-block/CMakeLists.txt index cd7e447f6f..760a7b62ea 100644 --- a/gr-howto-write-a-block/CMakeLists.txt +++ b/gr-howto-write-a-block/CMakeLists.txt @@ -110,7 +110,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${CPPUNIT_INCLUDE_DIRS} ) @@ -118,7 +118,7 @@ include_directories( link_directories( ${GNURADIO_CORE_LIBRARY_DIRS} ${GRUEL_LIBRARY_DIRS} - ${LOG4CXX_LIBRARY_DIRS} + ${LOG4CPP_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${CPPUNIT_LIBRARY_DIRS} ) diff --git a/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake b/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake new file mode 100644 index 0000000000..0b7208630f --- /dev/null +++ b/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake @@ -0,0 +1,58 @@ +# - Find Log4cpp +# Find the native LOG4CPP includes and library +# +# LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc. +# LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP. +# LOG4CPP_FOUND - True if LOG4CPP found. + + +if (LOG4CPP_INCLUDE_DIR) + # Already in cache, be silent + set(LOG4CPP_FIND_QUIETLY TRUE) +endif () + +find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh + /opt/local/include + /usr/local/include + /usr/include +) + +set(LOG4CPP_NAMES log4cpp) +find_library(LOG4CPP_LIBRARY + NAMES ${LOG4CPP_NAMES} + 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} ) +else () + set(LOG4CPP_FOUND FALSE) + set(LOG4CPP_LIBRARIES ) +endif () + +if (LOG4CPP_FOUND) + if (NOT LOG4CPP_FIND_QUIETLY) + message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}") + endif () +else () + if (LOG4CPP_FIND_REQUIRED) + message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.") + message(FATAL_ERROR "Could NOT find LOG4CPP library") + endif () +endif () + +message("internal libs: ${LOG4CPP_LIBRARIES}") + +mark_as_advanced( + LOG4CPP_LIBRARY + LOG4CPP_LIBRARIES + LOG4CPP_INCLUDE_DIR + ) diff --git a/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake b/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake deleted file mode 100644 index b1e4f6f1f7..0000000000 --- a/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# CMake module to find LOG4CXX library - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_LOG4CXX liblog4cxx) - -FIND_PATH( - LOG4CXX_INCLUDE_DIRS - NAMES log4cxx/log4cxx.h - HINTS $ENV{LOG4CXX_DIR}/include - ${PC_LOG4CXX_INCLUDE_DIRS} - PATHS /usr/local/include - /usr/include -) - -FIND_LIBRARY( - LOG4CXX_LIBRARIES - NAMES log4cxx - HINTS $ENV{LOG4CXX_DIR}/lib - ${PC_LOG4CXX_LIBRARIES} - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LOG4CXX DEFAULT_MSG LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) -MARK_AS_ADVANCED(LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) diff --git a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake index 685ac3c879..876e71687f 100644 --- a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake +++ b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake @@ -219,35 +219,35 @@ endfunction(GR_GEN_TARGET_DEPS) # Can manually set with -DENABLE_GR_LOG=0|1 ######################################################################## function(GR_LOGGING) - find_package(Log4cxx) + find_package(Log4cpp) OPTION(ENABLE_GR_LOG "Use gr_logger" ON) if(ENABLE_GR_LOG) # If gr_logger is enabled, make it usable add_definitions( -DENABLE_GR_LOG ) - # also test LOG4CXX; if we have it, use this version of the logger + # also test LOG4CPP; if we have it, use this version of the logger # otherwise, default to the stdout/stderr model. - if(LOG4CXX_FOUND) - SET(HAVE_LOG4CXX True) - add_definitions( -DHAVE_LOG4CXX ) - else(LOG4CXX_FOUND) - SET(HAVE_LOG4CXX False) - SET(LOG4CXX_INCLUDE_DIRS "") - SET(LOG4CXX_LIBRARY_DIRS "") - SET(LOG4CXX_LIBRARIES "") - endif(LOG4CXX_FOUND) + if(LOG4CPP_FOUND) + SET(HAVE_LOG4CPP True) + add_definitions( -DHAVE_LOG4CPP ) + else(LOG4CPP_FOUND) + SET(HAVE_LOG4CPP False) + SET(LOG4CPP_INCLUDE_DIRS "") + SET(LOG4CPP_LIBRARY_DIRS "") + SET(LOG4CPP_LIBRARIES "") + endif(LOG4CPP_FOUND) SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE) else(ENABLE_GR_LOG) - SET(HAVE_LOG4CXX False) - SET(LOG4CXX_INCLUDE_DIRS) - SET(LOG4CXX_LIBRARY_DIRS) - SET(LOG4CXX_LIBRARIES) + SET(HAVE_LOG4CPP False) + SET(LOG4CPP_INCLUDE_DIRS) + SET(LOG4CPP_LIBRARY_DIRS) + SET(LOG4CPP_LIBRARIES) endif(ENABLE_GR_LOG) message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.") - message(STATUS "HAVE_LOG4CXX set to ${HAVE_LOG4CXX}.") + message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.") endfunction(GR_LOGGING) diff --git a/gr-howto-write-a-block/lib/CMakeLists.txt b/gr-howto-write-a-block/lib/CMakeLists.txt index 2c995b868b..826138bf91 100644 --- a/gr-howto-write-a-block/lib/CMakeLists.txt +++ b/gr-howto-write-a-block/lib/CMakeLists.txt @@ -25,13 +25,12 @@ include(GrPlatform) #define LIB_SUFFIX include_directories(${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARY_DIRS}) -add_library(gnuradio-howto SHARED square_ff_impl.cc square2_ff_impl.cc) -target_link_libraries(gnuradio-howto - ${Boost_LIBRARIES} - ${GRUEL_LIBRARIES} - ${GNURADIO_CORE_LIBRARIES} - ${LOG4CXX_LIBRARIES} -) +add_library(gnuradio-howto SHARED howto_square_ff.cc howto_square2_ff.cc) +target_link_libraries(gnuradio-howto + ${Boost_LIBRARIES} + ${GRUEL_LIBRARIES} + ${GNURADIO_CORE_LIBRARIES} + ${LOG4CPP_LIBRARIES}) set_target_properties(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS") diff --git a/gr-noaa/lib/CMakeLists.txt b/gr-noaa/lib/CMakeLists.txt index baa4c732a2..df0eafb0f3 100644 --- a/gr-noaa/lib/CMakeLists.txt +++ b/gr-noaa/lib/CMakeLists.txt @@ -24,12 +24,12 @@ include_directories( ${GR_NOAA_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) if(ENABLE_GR_CTRLPORT) ADD_DEFINITIONS(-DGR_CTRLPORT) @@ -62,7 +62,7 @@ endif(MSVC) list(APPEND noaa_libs gnuradio-core ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-noaa SHARED ${noaa_sources}) diff --git a/gr-pager/lib/CMakeLists.txt b/gr-pager/lib/CMakeLists.txt index 3c5ffc8177..3349d2d785 100644 --- a/gr-pager/lib/CMakeLists.txt +++ b/gr-pager/lib/CMakeLists.txt @@ -30,8 +30,8 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Setup library @@ -65,7 +65,7 @@ list(APPEND pager_libs gnuradio-core gnuradio-blocks ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-pager SHARED ${pager_sources}) diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt index 2395136e08..ff1e64ce31 100644 --- a/gr-qtgui/lib/CMakeLists.txt +++ b/gr-qtgui/lib/CMakeLists.txt @@ -109,7 +109,7 @@ include_directories( ${QWT_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} ${FFTW3F_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ) @@ -117,7 +117,7 @@ include_directories( link_directories( ${QWT_LIBRARY_DIRS} ${FFTW3F_LIBRARY_DIRS} - ${LOG4CXX_LIBRARY_DIRS} + ${LOG4CPP_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ) @@ -140,7 +140,7 @@ list(APPEND qtgui_libs ${QT_LIBRARIES} ${PYTHON_LIBRARIES} ${FFTW3F_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_definitions(-DQWT_DLL) #setup QWT library linkage diff --git a/gr-shd/lib/CMakeLists.txt b/gr-shd/lib/CMakeLists.txt index c5691a61cd..0f75726ad8 100644 --- a/gr-shd/lib/CMakeLists.txt +++ b/gr-shd/lib/CMakeLists.txt @@ -31,8 +31,8 @@ include_directories( link_directories(${SHD_LIBRARY_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Setup library @@ -60,7 +60,7 @@ list(APPEND shd_libs gnuradio-core ${Boost_LIBRARIES} ${SHD_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-shd SHARED ${gr_shd_sources}) diff --git a/gr-trellis/src/lib/CMakeLists.txt b/gr-trellis/src/lib/CMakeLists.txt index 8515aa21a4..d2e5fb19ff 100644 --- a/gr-trellis/src/lib/CMakeLists.txt +++ b/gr-trellis/src/lib/CMakeLists.txt @@ -32,8 +32,8 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # generate the python helper script which calls into the build utils @@ -167,7 +167,7 @@ endif(MSVC) list(APPEND trellis_libs gnuradio-core ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-trellis SHARED ${gr_trellis_sources}) diff --git a/gr-uhd/lib/CMakeLists.txt b/gr-uhd/lib/CMakeLists.txt index a6bd4e98b7..07ea657093 100644 --- a/gr-uhd/lib/CMakeLists.txt +++ b/gr-uhd/lib/CMakeLists.txt @@ -41,6 +41,9 @@ if(ENABLE_GR_CTRLPORT) include_directories(${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -68,7 +71,7 @@ list(APPEND uhd_libs gnuradio-core ${Boost_LIBRARIES} ${UHD_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-uhd SHARED ${gr_uhd_sources}) diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py index 706017cc21..87eb9f470c 100644 --- a/gr-utils/python/modtool/templates.py +++ b/gr-utils/python/modtool/templates.py @@ -275,7 +275,7 @@ ${str_to_python_comment($license)} #if $blocktype in ('sync', 'sink', 'source') #set $parenttype = 'gr.sync_block' #else -#set $parenttype = {'hier': 'gr.hier_block2', 'interpolator': 'gr.interp_block', 'decimator': 'gr.decim_block', 'general': 'gr.block'}[$blocktype] +#set $parenttype = {'hier': 'gr.hier_block2', 'interpolator': 'gr.interp_block', 'decimator': 'gr.decim_block', 'general': 'gr.basic_block'}[$blocktype] #end if #if $blocktype != 'hier' import numpy @@ -338,7 +338,7 @@ class ${blockname}(${parenttype}): def general_work(self, input_items, output_items): output_items[0][:] = input_items[0] - consume(0, len(input_items[0]) + consume(0, len(input_items[0])) \#self.consume_each(len(input_items[0])) return len(output_items[0]) #stop diff --git a/gr-video-sdl/src/CMakeLists.txt b/gr-video-sdl/src/CMakeLists.txt index 1e37505acc..8053182239 100644 --- a/gr-video-sdl/src/CMakeLists.txt +++ b/gr-video-sdl/src/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ) @@ -57,7 +57,7 @@ list(APPEND video_sdl_libs gnuradio-core ${Boost_LIBRARIES} ${SDL_LIBRARY} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-video-sdl SHARED ${gr_video_sdl_sources}) diff --git a/gr-vocoder/lib/CMakeLists.txt b/gr-vocoder/lib/CMakeLists.txt index 3b4fb859b5..32f1ef0fb1 100644 --- a/gr-vocoder/lib/CMakeLists.txt +++ b/gr-vocoder/lib/CMakeLists.txt @@ -36,6 +36,9 @@ if(ENABLE_GR_CTRLPORT) include_directories(${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -82,7 +85,7 @@ GR_INCLUDE_SUBDIRECTORY(gsm) list(APPEND vocoder_libs gnuradio-core ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-vocoder SHARED ${gr_vocoder_sources}) diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt index 090392f584..a78a24e22a 100644 --- a/gr-wavelet/lib/CMakeLists.txt +++ b/gr-wavelet/lib/CMakeLists.txt @@ -44,6 +44,10 @@ if(ENABLE_GR_CTRLPORT) include_directories(${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + + ######################################################################## # Setup library ######################################################################## @@ -73,7 +77,7 @@ list(APPEND wavelet_libs ${Boost_LIBRARIES} ${WAVELET_LIBRARIES} ${GSL_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-wavelet SHARED ${gr_wavelet_sources}) |