aboutsummaryrefslogtreecommitdiffstats
path: root/gr-fft
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2020-04-11 01:14:03 +0200
committerMarcus Müller <marcus@hostalia.de>2020-04-13 15:55:41 +0200
commit2a09931c72c58d1d5bd6f6860c13ecf39154ea3d (patch)
treed99263edb5f307ab650eb8ccc23e53dbcf1905e0 /gr-fft
parentfilter: replace stderr logging by calls to GR's logging facilties (diff)
downloadgnuradio-2a09931c72c58d1d5bd6f6860c13ecf39154ea3d.tar.xz
gnuradio-2a09931c72c58d1d5bd6f6860c13ecf39154ea3d.zip
gr-fft: replace stderr logging by calls to GR's logging facilties
Diffstat (limited to 'gr-fft')
-rw-r--r--gr-fft/include/gnuradio/fft/fft.h7
-rw-r--r--gr-fft/lib/ctrlport_probe_psd_impl.cc5
-rw-r--r--gr-fft/lib/fft.cc22
3 files changed, 26 insertions, 8 deletions
diff --git a/gr-fft/include/gnuradio/fft/fft.h b/gr-fft/include/gnuradio/fft/fft.h
index 1a1470b5d..f892b2142 100644
--- a/gr-fft/include/gnuradio/fft/fft.h
+++ b/gr-fft/include/gnuradio/fft/fft.h
@@ -17,6 +17,7 @@
#include <gnuradio/fft/api.h>
#include <gnuradio/gr_complex.h>
+#include <gnuradio/logger.h>
#include <volk/volk_alloc.hh>
#include <boost/thread.hpp>
@@ -58,6 +59,8 @@ class FFT_API fft_complex
volk::vector<gr_complex> d_inbuf;
volk::vector<gr_complex> d_outbuf;
void* d_plan;
+ gr::logger_ptr d_logger;
+ gr::logger_ptr d_debug_logger;
public:
fft_complex(int fft_size, bool forward = true, int nthreads = 1);
@@ -104,6 +107,8 @@ class FFT_API fft_real_fwd
volk::vector<float> d_inbuf;
volk::vector<gr_complex> d_outbuf;
void* d_plan;
+ gr::logger_ptr d_logger;
+ gr::logger_ptr d_debug_logger;
public:
fft_real_fwd(int fft_size, int nthreads = 1);
@@ -150,6 +155,8 @@ class FFT_API fft_real_rev
volk::vector<gr_complex> d_inbuf;
volk::vector<float> d_outbuf;
void* d_plan;
+ gr::logger_ptr d_logger;
+ gr::logger_ptr d_debug_logger;
public:
fft_real_rev(int fft_size, int nthreads = 1);
diff --git a/gr-fft/lib/ctrlport_probe_psd_impl.cc b/gr-fft/lib/ctrlport_probe_psd_impl.cc
index 032bab0bb..f8a6c8f7f 100644
--- a/gr-fft/lib/ctrlport_probe_psd_impl.cc
+++ b/gr-fft/lib/ctrlport_probe_psd_impl.cc
@@ -83,8 +83,9 @@ std::vector<gr_complex> ctrlport_probe_psd_impl::get()
void ctrlport_probe_psd_impl::set_length(int len)
{
if (len > 8191) {
- std::cerr << "probe_psd: length " << len << " exceeds maximum buffer size of 8191"
- << std::endl;
+ std::ostringstream msg;
+ msg << "length " << len << " exceeds maximum buffer size of 8191";
+ GR_LOG_ERROR(d_logger, msg.str());
len = 8191;
}
diff --git a/gr-fft/lib/fft.cc b/gr-fft/lib/fft.cc
index d4610a768..5579f00ef 100644
--- a/gr-fft/lib/fft.cc
+++ b/gr-fft/lib/fft.cc
@@ -109,7 +109,10 @@ static void import_wisdom()
int r = fftwf_import_wisdom_from_file(fp);
fclose(fp);
if (!r) {
- fprintf(stderr, "gr::fft: can't import wisdom from %s\n", filename.c_str());
+ gr::logger_ptr logger, debug_logger;
+ gr::configure_default_loggers(logger, debug_logger, "fft::import_wisdom");
+ GR_LOG_ERROR(logger,
+ boost::format("can't import wisdom from %s") % filename.c_str());
}
}
}
@@ -136,8 +139,10 @@ static void export_wisdom()
fftwf_export_wisdom_to_file(fp);
fclose(fp);
} else {
- fprintf(stderr, "fft_impl_fftw: ");
- perror(filename.c_str());
+ gr::logger_ptr logger, debug_logger;
+ gr::configure_default_loggers(logger, debug_logger, "fft::export_wisdom");
+ GR_LOG_ERROR(logger,
+ boost::format("%s: %s") % filename.c_str() % strerror(errno));
}
}
@@ -146,6 +151,7 @@ static void export_wisdom()
fft_complex::fft_complex(int fft_size, bool forward, int nthreads)
: d_nthreads(nthreads), d_inbuf(fft_size), d_outbuf(fft_size)
{
+ gr::configure_default_loggers(d_logger, d_debug_logger, "fft_complex");
// Hold global mutex during plan construction and destruction.
planner::scoped_lock lock(planner::mutex());
@@ -167,7 +173,7 @@ fft_complex::fft_complex(int fft_size, bool forward, int nthreads)
FFTW_MEASURE);
if (d_plan == NULL) {
- fprintf(stderr, "gr::fft: error creating plan\n");
+ GR_LOG_ERROR(d_logger, "creating plan failed");
throw std::runtime_error("fftwf_plan_dft_1d failed");
}
export_wisdom(); // store new wisdom to disk
@@ -201,6 +207,8 @@ void fft_complex::execute() { fftwf_execute((fftwf_plan)d_plan); }
fft_real_fwd::fft_real_fwd(int fft_size, int nthreads)
: d_nthreads(nthreads), d_inbuf(fft_size), d_outbuf(fft_size / 2 + 1)
{
+ gr::configure_default_loggers(d_logger, d_debug_logger, "fft_real_fwd");
+
// Hold global mutex during plan construction and destruction.
planner::scoped_lock lock(planner::mutex());
@@ -221,7 +229,7 @@ fft_real_fwd::fft_real_fwd(int fft_size, int nthreads)
FFTW_MEASURE);
if (d_plan == NULL) {
- fprintf(stderr, "gr::fft::fft_real_fwd: error creating plan\n");
+ GR_LOG_ERROR(d_logger, "creating plan failed");
throw std::runtime_error("fftwf_plan_dft_r2c_1d failed");
}
export_wisdom(); // store new wisdom to disk
@@ -256,6 +264,8 @@ void fft_real_fwd::execute() { fftwf_execute((fftwf_plan)d_plan); }
fft_real_rev::fft_real_rev(int fft_size, int nthreads)
: d_nthreads(nthreads), d_inbuf(fft_size / 2 + 1), d_outbuf(fft_size)
{
+ gr::configure_default_loggers(d_logger, d_debug_logger, "fft_real_rev");
+
// Hold global mutex during plan construction and destruction.
planner::scoped_lock lock(planner::mutex());
@@ -279,7 +289,7 @@ fft_real_rev::fft_real_rev(int fft_size, int nthreads)
FFTW_MEASURE);
if (d_plan == NULL) {
- fprintf(stderr, "gr::fft::fft_real_rev: error creating plan\n");
+ GR_LOG_ERROR(d_logger, "creating plan failed");
throw std::runtime_error("fftwf_plan_dft_c2r_1d failed");
}
export_wisdom(); // store new wisdom to disk