summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-runtime/lib/logger.cc75
-rw-r--r--gnuradio-runtime/lib/tpb_thread_body.cc29
-rw-r--r--gnuradio-runtime/swig/gr_logger.i8
-rw-r--r--gr-blocks/lib/message_strobe_impl.cc2
4 files changed, 80 insertions, 34 deletions
diff --git a/gnuradio-runtime/lib/logger.cc b/gnuradio-runtime/lib/logger.cc
index 273183d5e0..a7e4a25a40 100644
--- a/gnuradio-runtime/lib/logger.cc
+++ b/gnuradio-runtime/lib/logger.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
/*
* Copyright 2012 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,
@@ -21,13 +21,13 @@
*/
/*******************************************************************************
-* Author: Mark Plett
+* Author: Mark Plett
* Description:
* The gr_log module wraps the log4cpp library for logging in gnuradio.
*******************************************************************************/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include "config.h"
#endif
#include <gnuradio/logger.h>
@@ -36,7 +36,7 @@
#ifdef ENABLE_GR_LOG
-#ifdef HAVE_LOG4CPP
+#ifdef HAVE_LOG4CPP
namespace gr {
@@ -48,25 +48,25 @@ namespace gr {
* watch teh config file for changes.
*/
- // Getters of logger_config
- logger_config&
+ // Getters of logger_config
+ logger_config&
logger_config::get_instance(void)
{
static logger_config instance;
return instance;
}
- std::string
+ std::string
logger_config::get_filename()
{
- logger_config& in=get_instance();
+ logger_config& in=get_instance();
return in.filename;
}
- unsigned int
+ unsigned int
logger_config::get_watch_period()
{
- logger_config& in=get_instance();
+ logger_config& in=get_instance();
return in.watch_period;
}
@@ -108,7 +108,7 @@ namespace gr {
// Stop any file watching thread
if(instance.watch_thread!=NULL)
stop_watch();
- // Load configuration
+ // Load configuration
//std::cout<<"GNURadio Loading logger configuration:"<<instance.filename<<std::endl;
logger_configured = logger_load_config(instance.filename);
// Start watch if required
@@ -125,15 +125,15 @@ namespace gr {
{
logger_config& instance = get_instance();
if(instance.watch_thread) {
- instance.watch_thread->interrupt();
- instance.watch_thread->join();
+ instance.watch_thread->interrupt();
+ instance.watch_thread->join();
delete(instance.watch_thread);
instance.watch_thread=NULL;
}
}
// Method to reset logger configuration
- void
+ void
logger_config::reset_config(void)
{
logger_config& instance = get_instance();
@@ -151,7 +151,7 @@ namespace gr {
/***************** Functions to call log4cpp methods *************************/
- logger_ptr
+ logger_ptr
logger_get_logger(std::string name)
{
if(log4cpp::Category::exists(name)) {
@@ -216,7 +216,7 @@ namespace gr {
logger->setPriority(level);
}
- void
+ void
logger_get_level(logger_ptr logger, std::string &level)
{
log4cpp::Priority::Value levelPtr = logger->getPriority();
@@ -232,13 +232,13 @@ namespace gr {
if(levelPtr == log4cpp::Priority::EMERG) level = "emerg";
}
- void
+ void
logger_get_level(logger_ptr logger,log4cpp::Priority::Value level)
{
level = logger->getPriority();
}
- void
+ void
logger_add_console_appender(logger_ptr logger, std::string target, std::string pattern)
{
log4cpp::PatternLayout* layout = new log4cpp::PatternLayout();
@@ -254,11 +254,11 @@ namespace gr {
}
void
- logger_add_file_appender(logger_ptr logger, std::string filename,
+ logger_add_file_appender(logger_ptr logger, std::string filename,
bool append, std::string pattern)
{
log4cpp::PatternLayout* layout = new log4cpp::PatternLayout();
- log4cpp::Appender* app = new
+ log4cpp::Appender* app = new
log4cpp::FileAppender("FileAppender::"+filename,
filename);
layout->setConversionPattern(pattern);
@@ -266,13 +266,13 @@ namespace gr {
logger->setAppender(app);
}
- void
+ void
logger_add_rollingfile_appender(logger_ptr logger, std::string filename,
size_t filesize, int bkup_index, bool append,
mode_t mode, std::string pattern)
{
log4cpp::PatternLayout* layout = new log4cpp::PatternLayout();
- log4cpp::Appender* app = new
+ log4cpp::Appender* app = new
log4cpp::RollingFileAppender("RollFileAppender::" + filename, filename,
filesize, bkup_index, append, mode);
layout->setConversionPattern(pattern);
@@ -290,7 +290,7 @@ namespace gr {
for(;logger!=loggers->end();logger++) {
names.push_back((*logger)->getName());
}
- return names;
+ return names;
}
} /* namespace gr */
@@ -301,7 +301,7 @@ namespace gr {
void
gr_logger_config(const std::string config_filename, unsigned int watch_period)
{
- GR_CONFIG_AND_WATCH_LOGGER(config_filename, watch_period);
+ GR_CONFIG_AND_WATCH_LOGGER(config_filename, watch_period);
}
std::vector<std::string>
@@ -320,4 +320,25 @@ gr_logger_reset_config(void)
// Remaining capability provided by gr::logger class in gnuradio/logger.h
+#else /* ENABLE_GR_LOGGER */
+
+/****** Start Methods to provide Python the capabilities of the macros ********/
+void
+gr_logger_config(const std::string config_filename, unsigned int watch_period)
+{
+ //NOP
+}
+
+std::vector<std::string>
+gr_logger_get_logger_names(void)
+{
+ return std::vector<std::string>(1, "");
+}
+
+void
+gr_logger_reset_config(void)
+{
+ //NOP
+}
+
#endif /* ENABLE_GR_LOGGER */
diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc b/gnuradio-runtime/lib/tpb_thread_body.cc
index ea5d80a9dc..233bbda9e7 100644
--- a/gnuradio-runtime/lib/tpb_thread_body.cc
+++ b/gnuradio-runtime/lib/tpb_thread_body.cc
@@ -47,6 +47,31 @@ namespace gr {
prefs *p = prefs::singleton();
size_t max_nmsgs = static_cast<size_t>(p->get_long("DEFAULT", "max_messages", 100));
+ // Setup the logger for the scheduler
+#ifdef ENABLE_GR_LOG
+#ifdef HAVE_LOG4CPP
+ #undef LOG
+ std::string config_file = p->get_string("LOG", "log_config", "");
+ std::string log_level = p->get_string("LOG", "log_level", "");
+ std::string log_file = p->get_string("LOG", "log_file", "");
+ GR_LOG_GETLOGGER(LOG, "gr_log.tpb_thread_body");
+ GR_LOG_SET_LEVEL(LOG, log_level);
+ GR_CONFIG_LOGGER(config_file);
+ if(log_file.size() > 0) {
+ if(log_file == "stdout") {
+ 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, "cerr","gr::log :%p: %c{1} - %m%n");
+ }
+ else {
+ GR_LOG_ADD_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n");
+ }
+ }
+#endif /* HAVE_LOG4CPP */
+#endif /* ENABLE_GR_LOG */
+
+
// Set thread affinity if it was set before fg was started.
if(block->processor_affinity().size() > 0) {
gr::thread::thread_bind_to_processor(d->thread, block->processor_affinity());
@@ -119,7 +144,7 @@ namespace gr {
block->dispatch_msg(i.first, msg);
guard.lock();
}
- }
+ }
else {
// leave msg in queue if no handler is defined
// start dropping if we have too many
@@ -152,7 +177,7 @@ namespace gr {
block->dispatch_msg(i.first, msg);
guard.lock();
}
- }
+ }
else {
// leave msg in queue if no handler is defined
// start dropping if we have too many
diff --git a/gnuradio-runtime/swig/gr_logger.i b/gnuradio-runtime/swig/gr_logger.i
index 00e41c3837..7ed59776cf 100644
--- a/gnuradio-runtime/swig/gr_logger.i
+++ b/gnuradio-runtime/swig/gr_logger.i
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
/*
* Copyright 2012 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc
index 3f58fdcaac..bd0ad80142 100644
--- a/gr-blocks/lib/message_strobe_impl.cc
+++ b/gr-blocks/lib/message_strobe_impl.cc
@@ -72,7 +72,7 @@ namespace gr {
void message_strobe_impl::run()
{
while(!d_finished) {
- boost::this_thread::sleep(boost::posix_time::milliseconds(d_period_ms));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(d_period_ms));
if(d_finished) {
return;
}