diff options
Diffstat (limited to 'gnuradio-runtime/include/gnuradio')
4 files changed, 55 insertions, 22 deletions
diff --git a/gnuradio-runtime/include/gnuradio/block_detail.h b/gnuradio-runtime/include/gnuradio/block_detail.h index 7f625e6d27..454945f0f5 100644 --- a/gnuradio-runtime/include/gnuradio/block_detail.h +++ b/gnuradio-runtime/include/gnuradio/block_detail.h @@ -13,6 +13,7 @@ #include <gnuradio/api.h> #include <gnuradio/high_res_timer.h> +#include <gnuradio/logger.h> #include <gnuradio/runtime_types.h> #include <gnuradio/tags.h> #include <gnuradio/tpb_detail.h> @@ -232,6 +233,10 @@ public: int consumed() const; + // necessary because stupidly block_executor.cc's "propagate_tags" is a function, not + // any class member + gr::logger_ptr d_logger, d_debug_logger; + // ---------------------------------------------------------------------------- private: diff --git a/gnuradio-runtime/include/gnuradio/buffer.h b/gnuradio-runtime/include/gnuradio/buffer.h index cb4ac42e28..ef673bf500 100644 --- a/gnuradio-runtime/include/gnuradio/buffer.h +++ b/gnuradio-runtime/include/gnuradio/buffer.h @@ -12,9 +12,11 @@ #define INCLUDED_GR_RUNTIME_BUFFER_H #include <gnuradio/api.h> +#include <gnuradio/logger.h> #include <gnuradio/runtime_types.h> #include <gnuradio/tags.h> #include <gnuradio/thread/thread.h> +#include <boost/weak_ptr.hpp> #include <map> #include <memory> @@ -44,6 +46,9 @@ GR_RUNTIME_API buffer_sptr make_buffer(int nitems, class GR_RUNTIME_API buffer { public: + gr::logger_ptr d_logger; + gr::logger_ptr d_debug_logger; + virtual ~buffer(); /*! diff --git a/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h b/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h index 2c4d75a29e..1271590611 100644 --- a/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h +++ b/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h @@ -13,6 +13,7 @@ #include "thrift/ControlPort.h" #include "thrift/gnuradio_types.h" +#include <gnuradio/logger.h> #include <gnuradio/rpcpmtconverters_thrift.h> #include <gnuradio/rpcserver_base.h> #include <boost/format.hpp> @@ -29,6 +30,9 @@ class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::ControlPortIf { public: + gr::logger_ptr d_logger; + gr::logger_ptr d_debug_logger; + rpcserver_thrift(); virtual ~rpcserver_thrift(); @@ -100,9 +104,11 @@ private: if (cur_priv <= _handlerCallback.priv) { _handlerCallback.callback->post(port, msg); } else { - std::cerr << "Message " << _handlerCallback.description - << " requires PRIVLVL <= " << _handlerCallback.priv - << " to set, currently at: " << cur_priv << std::endl; + std::ostringstream msg; + msg << _handlerCallback.description + << " requires PRIVLVL <= " << _handlerCallback.priv + << " to set, currently at: " << cur_priv; + GR_LOG_ERROR(logger, msg.str()); } } @@ -123,9 +129,11 @@ private: (*iter->second.callback) .post(pmt::PMT_NIL, rpcpmtconverter::To_PMT::instance(p.second)); } else { - std::cerr << "Key " << p.first - << " requires PRIVLVL <= " << iter->second.priv - << " to set, currently at: " << cur_priv << std::endl; + std::ostringstream msg; + msg << "Key " << p.first + << " requires PRIVLVL <= " << iter->second.priv + << " to set, currently at: " << cur_priv; + GR_LOG_ERROR(logger, msg.str()); } } else { throw apache::thrift::TApplicationException(__FILE__ " " S__LINE__); @@ -153,14 +161,16 @@ private: outknobs[p] = rpcpmtconverter::from_pmt((*iter->second.callback).retrieve()); } else { - std::cerr << "Key " << iter->first - << " requires PRIVLVL: <= " << iter->second.priv - << " to get, currently at: " << cur_priv << std::endl; + std::ostringstream msg; + msg << "Key " << iter->first + << " requires PRIVLVL: <= " << iter->second.priv + << " to get, currently at: " << cur_priv; + GR_LOG_ERROR(logger, msg.str()); } } else { - std::stringstream ss; - ss << "Ctrlport Key called with unregistered key (" << p << ")\n"; - std::cerr << ss.str(); + std::ostringstream smsgs; + msg << "Ctrlport Key called with unregistered key (" << p << ")\n"; + GR_LOG_ERROR(logger, ss.str()); throw apache::thrift::TApplicationException(__FILE__ " " S__LINE__); } } @@ -184,8 +194,10 @@ private: outknobs[p.first] = rpcpmtconverter::from_pmt(p.second.callback->retrieve()); } else { - std::cerr << "Key " << p.first << " requires PRIVLVL <= " << p.second.priv - << " to get, currently at: " << cur_priv << std::endl; + std::ostringstream msg; + msg << "Key " << p.first << " requires PRIVLVL: <= " << p.second.priv + << " to get, currently at: " << cur_priv; + GR_LOG_ERROR(logger, msg.str()); } } @@ -216,8 +228,10 @@ private: prop.display = static_cast<uint32_t>(p.second.display); outknobs[p.first] = prop; } else { - std::cerr << "Key " << p.first << " requires PRIVLVL <= " << p.second.priv - << " to get, currently at: " << cur_priv << std::endl; + std::ostringstream msg; + msg << "Key " << p.first << " requires PRIVLVL: <= " << p.second.priv + << " to get, currently at: " << cur_priv; + GR_LOG_ERROR(logger, msg.str()); } } @@ -250,9 +264,11 @@ private: prop.display = static_cast<uint32_t>(iter->second.display); outknobs[p] = prop; } else { - std::cerr << "Key " << iter->first - << " requires PRIVLVL: <= " << iter->second.priv - << " to get, currently at: " << cur_priv << std::endl; + std::ostringstream msg; + msg << "Key " << iter->first + << " requires PRIVLVL: <= " << iter->second.priv + << " to get, currently at: " << cur_priv; + GR_LOG_ERROR(logger, msg.str()); } } else { throw apache::thrift::TApplicationException(__FILE__ " " S__LINE__); diff --git a/gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h b/gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h index fe611e8b13..98d74f1420 100644 --- a/gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h +++ b/gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h @@ -12,6 +12,7 @@ #define INCLUDED_THREAD_BODY_WRAPPER_H #include <gnuradio/api.h> +#include <gnuradio/logger.h> #include <gnuradio/thread/thread.h> #include <exception> #include <iostream> @@ -28,6 +29,8 @@ private: F d_f; std::string d_name; bool d_catch_exceptions; + gr::logger_ptr d_logger; + gr::logger_ptr d_debug_logger; public: explicit thread_body_wrapper(F f, @@ -35,6 +38,7 @@ public: bool catch_exceptions = true) : d_f(f), d_name(name), d_catch_exceptions(catch_exceptions) { + gr::configure_default_loggers(d_logger, d_debug_logger, "thread_body_wrapper"); } void operator()() @@ -46,10 +50,13 @@ public: d_f(); } catch (boost::thread_interrupted const&) { } catch (std::exception const& e) { - std::cerr << "thread[" << d_name << "]: " << e.what() << std::endl; + std::ostringstream msg; + msg << "ERROR thread[" << d_name << "]: " << e.what(); + GR_LOG_ERROR(d_logger, msg.str()); } catch (...) { - std::cerr << "thread[" << d_name << "]: " - << "caught unrecognized exception\n"; + std::ostringstream msg; + msg << "ERROR thread[" << d_name << "]: caught unrecognized exception"; + GR_LOG_ERROR(d_logger, msg.str()); } } else { |