From 0f88db1ef0569bf6fcd5e9c843da38d487a6f54b Mon Sep 17 00:00:00 2001 From: Marcus Müller <mmueller@gnuradio.org> Date: Sat, 11 Apr 2020 00:43:39 +0200 Subject: runtime: replace stderr logging by calls to GR's logging facilties --- gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc | 27 +++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc') diff --git a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc index 6f9d7e4104..3fc03f66c5 100644 --- a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc +++ b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc @@ -36,13 +36,15 @@ namespace gr { vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size) { #if !defined(HAVE_MMAP) - fprintf(stderr, "gr::vmcircbuf_mmap_tmpfile: mmap or mkstemp is not available\n"); + GR_LOG_ERROR(d_logger, "mmap or mkstemp is not available"); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); #else gr::thread::scoped_lock guard(s_vm_mutex); if (size <= 0 || (size % gr::pagesize()) != 0) { - fprintf(stderr, "gr::vmcircbuf_mmap_tmpfile: invalid size = %d\n", size); + std::stringstream error_msg; + error_msg << "invalid size = " << size; + GR_LOG_ERROR(d_logger, error_msg.str()); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } @@ -62,16 +64,15 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size) if (errno == EEXIST) // File already exists (shouldn't happen). Try again continue; - static std::string msg = - str(boost::format("gr::vmcircbuf_mmap_tmpfile: open [%s]") % seg_name); - perror(msg.c_str()); + static std::string msg = str(boost::format("open [%s]") % seg_name); + GR_LOG_ERROR(d_logger, msg.c_str()); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } break; } if (unlink(seg_name.c_str()) == -1) { - perror("gr::vmcircbuf_mmap_tmpfile: unlink"); + GR_LOG_ERROR(d_logger, "unlink"); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } @@ -79,7 +80,7 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size) // Now set it's length to 2x what we really want and mmap it in. if (ftruncate(seg_fd, (off_t)2 * size) == -1) { close(seg_fd); // cleanup - perror("gr::vmcircbuf_mmap_tmpfile: ftruncate (1)"); + GR_LOG_ERROR(d_logger, "ftruncate (1) failed"); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } @@ -88,14 +89,14 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size) if (first_copy == MAP_FAILED) { close(seg_fd); // cleanup - perror("gr::vmcircbuf_mmap_tmpfile: mmap (1)"); + GR_LOG_ERROR(d_logger, "mmap (1) failed"); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } // unmap the 2nd half if (munmap((char*)first_copy + size, size) == -1) { close(seg_fd); // cleanup - perror("gr::vmcircbuf_mmap_tmpfile: munmap (1)"); + GR_LOG_ERROR(d_logger, "munmap (1) failed"); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } @@ -111,7 +112,7 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size) if (second_copy == MAP_FAILED) { munmap(first_copy, size); // cleanup close(seg_fd); - perror("gr::vmcircbuf_mmap_tmpfile: mmap(2)"); + GR_LOG_ERROR(d_logger, "mmap (2) failed"); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } @@ -120,7 +121,7 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size) munmap(first_copy, size); // cleanup munmap(second_copy, size); close(seg_fd); - perror("gr::vmcircbuf_mmap_tmpfile: non-contiguous second copy"); + GR_LOG_ERROR(d_logger, "non-contiguous second copy"); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } @@ -129,7 +130,7 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size) munmap(first_copy, size); // cleanup munmap(second_copy, size); close(seg_fd); - perror("gr::vmcircbuf_mmap_tmpfile: ftruncate (2)"); + GR_LOG_ERROR(d_logger, "ftruncate (2) failed"); throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile"); } @@ -148,7 +149,7 @@ vmcircbuf_mmap_tmpfile::~vmcircbuf_mmap_tmpfile() gr::thread::scoped_lock guard(s_vm_mutex); if (munmap(d_base, 2 * d_size) == -1) { - perror("gr::vmcircbuf_mmap_tmpfile: munmap(2)"); + GR_LOG_ERROR(d_logger, "munmap (2) failed"); } #endif } -- cgit v1.2.3