summaryrefslogtreecommitdiff
path: root/gr-uhd/examples/c++
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2020-04-12 13:00:03 +0200
committerMartin Braun <martin@gnuradio.org>2021-02-18 23:44:18 -0800
commit0c16f319c32ecf8e5bf2328ba844269b21a1332b (patch)
tree05828043c2a0620f3f01429caea91b75d280e9db /gr-uhd/examples/c++
parented733765177902afae7ca8454006c324d2763346 (diff)
uhd/tag_sink_demo: Use log mechanism instead of stdout
I think this is an excellent place to illustrate how to log without overloading new users with complexity. Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Diffstat (limited to 'gr-uhd/examples/c++')
-rw-r--r--gr-uhd/examples/c++/tag_sink_demo.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/gr-uhd/examples/c++/tag_sink_demo.h b/gr-uhd/examples/c++/tag_sink_demo.h
index a35b47c1b6..4d685c7e14 100644
--- a/gr-uhd/examples/c++/tag_sink_demo.h
+++ b/gr-uhd/examples/c++/tag_sink_demo.h
@@ -8,6 +8,7 @@
*/
#include <gnuradio/io_signature.h>
+#include <gnuradio/logger.h>
#include <gnuradio/sync_block.h>
#include <boost/format.hpp>
#include <complex>
@@ -15,13 +16,16 @@
class tag_sink_demo : public gr::sync_block
{
+private:
+ gr::logger_ptr d_logger, d_debug_logger;
+
public:
tag_sink_demo(void)
: sync_block("uhd tag sink demo",
gr::io_signature::make(1, 1, sizeof(std::complex<float>)),
gr::io_signature::make(0, 0, 0))
{
- // NOP
+ gr::configure_default_loggers(d_logger, d_debug_logger, "tag_sink_demo");
}
int work(int ninput_items,
@@ -38,15 +42,15 @@ public:
pmt::string_to_symbol("rx_time"));
// print all tags
+ auto format_string =
+ boost::format("Full seconds %u, Frac seconds %f, abs sample offset %u");
for (const auto& rx_time_tag : rx_time_tags) {
const uint64_t offset = rx_time_tag.offset;
const pmt::pmt_t& value = rx_time_tag.value;
- std::cout << boost::format(
- "Full seconds %u, Frac seconds %f, abs sample offset %u") %
- pmt::to_uint64(pmt::tuple_ref(value, 0)) %
- pmt::to_double(pmt::tuple_ref(value, 1)) % offset
- << std::endl;
+ GR_LOG_INFO(d_logger,
+ format_string % pmt::to_uint64(pmt::tuple_ref(value, 0)) %
+ pmt::to_double(pmt::tuple_ref(value, 1)) % offset);
}
return ninput_items;