From 1eb5ac46ef9338795ed90c7053beb8d10e39ddb2 Mon Sep 17 00:00:00 2001 From: Bastian Bloessl Date: Tue, 1 Sep 2015 08:15:11 +0200 Subject: [PATCH] fix logging --- CMakeLists.txt | 10 ++++++++-- lib/utils.h | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ead850..04ce274 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ set(GR_REQUIRED_COMPONENTS RUNTIME FILTER FFT PMT DIGITAL) find_package(Gnuradio) find_package(CppUnit) find_package(ITPP) +find_package(log4cpp) if(NOT GNURADIO_RUNTIME_FOUND) message(FATAL_ERROR "GnuRadio Runtime required to compile ieee802-11") @@ -97,6 +98,13 @@ if(NOT ITPP_FOUND) message(FATAL_ERROR "ITPP required to compile ieee802-11") endif() +if (LOG4CPP_FOUND) + message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}") + add_definitions("-DGR_IEEE80211_LOG4CPP") +else () + message(STATUS "LOG4CPP not found (not required).") +endif () + ######################################################################## # On Apple only, set install name and use rpath correctly, if not already set ######################################################################## @@ -128,14 +136,12 @@ include_directories( ${CPPUNIT_INCLUDE_DIRS} ${ITPP_INCLUDE_DIR} ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${LOG4CPP_INCLUDE_DIRS} ) link_directories( ${Boost_LIBRARY_DIRS} ${CPPUNIT_LIBRARY_DIRS} ${GNURADIO_RUNTIME_LIBRARY_DIRS} - ${LOG4CPP_LIBRARY_DIRS} ) ######################################################################## diff --git a/lib/utils.h b/lib/utils.h index 1e42242..ac3400d 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -28,8 +28,8 @@ const int MAX_BITS = 1550 * 8 * 2; #define dout d_debug && std::cout -#if defined(HAVE_LOG4CPP) && defined(ENABLE_GR_LOG) -#define mylog(msg) do { if(d_log) { *d_logger << log4cpp::Priority::INFO << msg << log4cpp::eol; }} while(0); +#if defined(HAVE_LOG4CPP) && defined(ENABLE_GR_LOG) && defined(GR_IEEE80211_LOG4CPP) +#define mylog(msg) do { if(d_log) { GR_LOG_INFO(d_logger, msg) }} while(0); #else #define mylog(msg) do { d_log && std::cout << msg << std::endl; } while(0); #endif