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/buffer.cc | |
parent | ec8a92846a388cb0d2982822ea1961910cd552f8 (diff) |
runtime: replace stderr logging by calls to GR's logging facilties
Diffstat (limited to 'gnuradio-runtime/lib/buffer.cc')
-rw-r--r-- | gnuradio-runtime/lib/buffer.cc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gnuradio-runtime/lib/buffer.cc b/gnuradio-runtime/lib/buffer.cc index 46d704542b..58b291e649 100644 --- a/gnuradio-runtime/lib/buffer.cc +++ b/gnuradio-runtime/lib/buffer.cc @@ -76,6 +76,7 @@ buffer::buffer(int nitems, size_t sizeof_item, block_sptr link) d_done(false), d_last_min_items_read(0) { + gr::configure_default_loggers(d_logger, d_debug_logger, "buffer"); if (!allocate_buffer(nitems, sizeof_item)) throw std::bad_alloc(); @@ -113,21 +114,24 @@ bool buffer::allocate_buffer(int nitems, size_t sizeof_item) // This only happens if sizeof_item is not a power of two. if (nitems > 2 * orig_nitems && nitems * (int)sizeof_item > granularity) { - std::cerr << "gr::buffer::allocate_buffer: warning: tried to allocate\n" - << " " << orig_nitems << " items of size " << sizeof_item - << ". Due to alignment requirements\n" - << " " << nitems - << " were allocated. If this isn't OK, consider padding\n" - << " your structure to a power-of-two bytes.\n" - << " On this platform, our allocation granularity is " << granularity - << " bytes.\n"; + auto msg = + str(boost::format( + "allocate_buffer: tried to allocate" + " %d items of size %d. Due to alignment requirements" + " %d were allocated. If this isn't OK, consider padding" + " your structure to a power-of-two bytes." + " On this platform, our allocation granularity is %d bytes.") % + orig_nitems % sizeof_item % nitems % granularity); + GR_LOG_WARN(d_logger, msg.c_str()); } d_bufsize = nitems; d_vmcircbuf.reset(gr::vmcircbuf_sysconfig::make(d_bufsize * d_sizeof_item)); if (d_vmcircbuf == 0) { - std::cerr << "gr::buffer::allocate_buffer: failed to allocate buffer of size " - << d_bufsize * d_sizeof_item / 1024 << " KB\n"; + std::ostringstream msg; + msg << "gr::buffer::allocate_buffer: failed to allocate buffer of size " + << d_bufsize * d_sizeof_item / 1024 << " KB"; + GR_LOG_ERROR(d_logger, msg.str()); return false; } |