diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2020-04-11 00:43:39 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-04-13 15:55:41 +0200 |
commit | 0f88db1ef0569bf6fcd5e9c843da38d487a6f54b (patch) | |
tree | 4c9827377c0e98fe223f39edb0c84c8a49c199e9 /gnuradio-runtime/lib/controlport | |
parent | ec8a92846a388cb0d2982822ea1961910cd552f8 (diff) |
runtime: replace stderr logging by calls to GR's logging facilties
Diffstat (limited to 'gnuradio-runtime/lib/controlport')
-rw-r--r-- | gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc | 16 | ||||
-rw-r--r-- | gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc | 48 |
2 files changed, 45 insertions, 19 deletions
diff --git a/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc b/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc index 74eb12dcc3..2aae09e1d0 100644 --- a/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc +++ b/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc @@ -9,6 +9,7 @@ #include "thrift/gnuradio_types.h" #include <gnuradio/gr_complex.h> +#include <gnuradio/logger.h> #include <gnuradio/rpcpmtconverters_thrift.h> #include <boost/assign/ptr_map_inserter.hpp> #include <iostream> @@ -109,8 +110,12 @@ GNURadio::Knob rpcpmtconverter::from_pmt(const pmt::pmt_t& knob) result.value.__set_a_c32vector(z); return result; } else { - std::cerr << "Error: Don't know how to handle Knob Type (from): " << knob - << std::endl; + // FIXME: Don't get loggers every time we need to log something. + gr::logger_ptr logger, debug_logger; + gr::configure_default_loggers(logger, debug_logger, "rpcpmtconverter"); + std::ostringstream msg; + msg << "ERROR Don't know how to handle Knob Type (from): " << knob; + GR_LOG_ERROR(logger, msg.str()); assert(0); } return GNURadio::Knob(); @@ -250,7 +255,12 @@ rpcpmtconverter::to_pmt_reg<TO_PMT_F>::to_pmt_reg(To_PMT& instance, pmt::pmt_t rpcpmtconverter::to_pmt_f::operator()(const GNURadio::Knob& knob) { - std::cerr << "Error: Don't know how to handle Knob Type: " << knob.type << std::endl; + // FIXME: Don't get loggers every time we need to log something. + gr::logger_ptr logger, debug_logger; + gr::configure_default_loggers(logger, debug_logger, "rpcpmtconverter"); + std::ostringstream msg; + msg << "ERROR Don't know how to handle Knob Type (from): " << knob.type; + GR_LOG_ERROR(debug_logger, msg.str()); assert(0); return pmt::pmt_t(); } diff --git a/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc b/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc index 603f82dee1..c2613c5c80 100644 --- a/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc +++ b/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc @@ -25,12 +25,13 @@ using namespace rpcpmtconverter; rpcserver_thrift::rpcserver_thrift() { - // std::cerr << "rpcserver_thrift::ctor" << std::endl; + gr::configure_default_loggers(logger, debug_logger, "rpcserver_thrift"); + // std::cerr << "rpcserver_thrift::ctor" ; } rpcserver_thrift::~rpcserver_thrift() { - // std::cerr << "rpcserver_thrift::dtor" << std::endl; + // std::cerr << "rpcserver_thrift::dtor" ; } void rpcserver_thrift::registerConfigureCallback(const std::string& id, @@ -43,13 +44,15 @@ void rpcserver_thrift::registerConfigureCallback(const std::string& id, std::stringstream s; s << "rpcserver_thrift:: rpcserver_thrift ERROR registering set, already " "registered: " - << id << std::endl; + << id; throw std::runtime_error(s.str().c_str()); } } if (DEBUG) { - std::cerr << "rpcserver_thrift registering set: " << id << std::endl; + std::ostringstream msg; + msg << "registering set: " << id; + GR_LOG_INFO(d_debug_logger, msg.str()); } d_setcallbackmap.insert(ConfigureCallbackMap_t::value_type(id, callback)); } @@ -62,12 +65,15 @@ void rpcserver_thrift::unregisterConfigureCallback(const std::string& id) std::stringstream s; s << "rpcserver_thrift:: rpcserver_thrift ERROR unregistering set, not " "registered: " - << id << std::endl; + << id; throw std::runtime_error(s.str().c_str()); } - if (DEBUG) - std::cerr << "rpcserver_thrift unregistering set: " << id << std::endl; + if (DEBUG) { + std::ostringstream msg; + msg << "unregistering set: " << id; + GR_LOG_INFO(d_debug_logger, msg.str()); + } d_setcallbackmap.erase(iter); } @@ -82,13 +88,15 @@ void rpcserver_thrift::registerQueryCallback(const std::string& id, std::stringstream s; s << "rpcserver_thrift:: rpcserver_thrift ERROR registering get, already " "registered: " - << id << std::endl; + << id; throw std::runtime_error(s.str().c_str()); } } if (DEBUG) { - std::cerr << "rpcserver_thrift registering get: " << id << std::endl; + std::ostringstream msg; + msg << "registering get: " << id; + GR_LOG_INFO(d_debug_logger, msg.str()); } d_getcallbackmap.insert(QueryCallbackMap_t::value_type(id, callback)); } @@ -100,12 +108,14 @@ void rpcserver_thrift::unregisterQueryCallback(const std::string& id) if (iter == d_getcallbackmap.end()) { std::stringstream s; s << "rpcserver_thrift:: rpcserver_thrift ERROR unregistering get, registered: " - << id << std::endl; + << id; throw std::runtime_error(s.str().c_str()); } if (DEBUG) { - std::cerr << "rpcserver_thrift unregistering get: " << id << std::endl; + std::ostringstream msg; + msg << "unregistering get: " << id; + GR_LOG_INFO(d_debug_logger, msg.str()); } d_getcallbackmap.erase(iter); @@ -122,13 +132,15 @@ void rpcserver_thrift::registerHandlerCallback(const std::string& id, std::stringstream s; s << "rpcserver_thrift:: rpcserver_thrift ERROR registering handler, already " "registered: " - << id << std::endl; + << id; throw std::runtime_error(s.str().c_str()); } } if (DEBUG) { - std::cerr << "rpcserver_thrift registering handler: " << id << std::endl; + std::ostringstream msg; + msg << "registering handler: " << id; + GR_LOG_INFO(d_debug_logger, msg.str()); } d_handlercallbackmap.insert(HandlerCallbackMap_t::value_type(id, callback)); } @@ -141,12 +153,14 @@ void rpcserver_thrift::unregisterHandlerCallback(const std::string& id) std::stringstream s; s << "rpcserver_thrift:: rpcserver_thrift ERROR unregistering handler, " "registered: " - << id << std::endl; + << id; throw std::runtime_error(s.str().c_str()); } if (DEBUG) { - std::cerr << "rpcserver_thrift unregistering handler: " << id << std::endl; + std::ostringstream msg; + msg << "unregistering handler: " << id; + GR_LOG_INFO(d_debug_logger, msg.str()); } d_handlercallbackmap.erase(iter); @@ -258,6 +272,8 @@ void rpcserver_thrift::postMessage(const std::string& alias, void rpcserver_thrift::shutdown() { if (DEBUG) { - std::cerr << "Shutting down..." << std::endl; + std::ostringstream msg; + msg << "shutting down... " << id; + GR_LOG_INFO(d_debug_logger, msg.str()); } } |