diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2020-04-13 18:24:43 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-04-13 22:47:26 +0200 |
commit | c1a91d140919518de18eda1fd5b598b2c11ef0cd (patch) | |
tree | 7fb529f3dd30555008fc62f73901a27dcaf026cd | |
parent | e37033cb512b6189e338e210eea5554dc324c2d5 (diff) |
runtime: move loggers from gr::block to gr::basic_block
No reason to assume only `general_work`-containing blocks would want to
log.
This enables us especially to log in `basic_block` itself.
-rw-r--r-- | gnuradio-runtime/include/gnuradio/basic_block.h | 7 | ||||
-rw-r--r-- | gnuradio-runtime/include/gnuradio/block.h | 5 | ||||
-rw-r--r-- | gnuradio-runtime/lib/basic_block.cc | 5 | ||||
-rw-r--r-- | gnuradio-runtime/lib/block.cc | 2 |
4 files changed, 10 insertions, 9 deletions
diff --git a/gnuradio-runtime/include/gnuradio/basic_block.h b/gnuradio-runtime/include/gnuradio/basic_block.h index 8a906283c3..651fda2136 100644 --- a/gnuradio-runtime/include/gnuradio/basic_block.h +++ b/gnuradio-runtime/include/gnuradio/basic_block.h @@ -13,6 +13,7 @@ #include <gnuradio/api.h> #include <gnuradio/io_signature.h> +#include <gnuradio/logger.h> #include <gnuradio/msg_accepter.h> #include <gnuradio/runtime_types.h> #include <gnuradio/sptr_magic.h> @@ -20,7 +21,6 @@ #include <boost/function.hpp> #include <boost/thread/condition_variable.hpp> #include <deque> -#include <iostream> #include <map> #include <string> @@ -74,6 +74,11 @@ protected: vcolor d_color; bool d_rpc_set; + /*! Used by blocks to access the logger system. + */ + gr::logger_ptr d_logger; //! Default logger + gr::logger_ptr d_debug_logger; //! Verbose logger + msg_queue_map_t msg_queue; std::vector<rpcbasic_sptr> d_rpc_vars; // container for all RPC variables diff --git a/gnuradio-runtime/include/gnuradio/block.h b/gnuradio-runtime/include/gnuradio/block.h index 51c232c44a..2a47a05715 100644 --- a/gnuradio-runtime/include/gnuradio/block.h +++ b/gnuradio-runtime/include/gnuradio/block.h @@ -919,11 +919,6 @@ protected: */ gr::thread::mutex d_setlock; - /*! Used by blocks to access the logger system. - */ - gr::logger_ptr d_logger; - gr::logger_ptr d_debug_logger; - // These are really only for internal use, but leaving them public avoids // having to work up an ever-varying list of friend GR_RUNTIME_APIs diff --git a/gnuradio-runtime/lib/basic_block.cc b/gnuradio-runtime/lib/basic_block.cc index f86051213c..c6ac346d11 100644 --- a/gnuradio-runtime/lib/basic_block.cc +++ b/gnuradio-runtime/lib/basic_block.cc @@ -39,6 +39,7 @@ basic_block::basic_block(const std::string& name, d_rpc_set(false), d_message_subscribers(pmt::make_dict()) { + configure_default_loggers(d_logger, d_debug_logger, d_symbol_name); s_ncurrently_allocated++; } @@ -177,7 +178,9 @@ void basic_block::insert_tail(pmt::pmt_t which_port, pmt::pmt_t msg) if ((msg_queue.find(which_port) == msg_queue.end()) || (msg_queue_ready.find(which_port) == msg_queue_ready.end())) { - std::cout << "target port = " << pmt::symbol_to_string(which_port) << std::endl; + GR_LOG_ERROR(d_logger, + std::string("attempted insertion on invalid queue ") + + pmt::symbol_to_string(which_port)); throw std::runtime_error("attempted to insert_tail on invalid queue!"); } diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc index 96867787bb..ebfeba23ba 100644 --- a/gnuradio-runtime/lib/block.cc +++ b/gnuradio-runtime/lib/block.cc @@ -50,8 +50,6 @@ block::block(const std::string& name, global_block_registry.register_primitive(alias(), this); message_port_register_in(d_system_port); set_msg_handler(d_system_port, boost::bind(&block::system_handler, this, _1)); - - configure_default_loggers(d_logger, d_debug_logger, symbol_name()); } block::~block() { global_block_registry.unregister_primitive(symbol_name()); } |